Commits

Anonymous committed 503f244

Patch by ++amk - Launchpad bug #385394

Patch to remove builtins dropped from 3.x

Python 3.0 dropped a number of built-in functions. Using the list from
Python 3.1's code, this patch removes the built-ins that no longer need
to be supported.

Comments (0)

Files changed (2)

Lib/test/parrot/builtins.py

 if len(str(861)) == 3: print('success: len/str')
 else: print('failure: len/str')
 
-#cmp
-print('test: cmp (equal)')
-if cmp(5, 5) == 0: print('success: cmp (equal)')
-else: print('failure: cmp (equal)')
-
-print('test: cmp (gt)')
-if cmp(5, 0) > 0: print('success: cmp (gt)')
-else: print('failure: cmp (gt)')
-
-print('test: cmp (lt)')
-if cmp(0, 5) < 0: print('success: cmp (lt)')
-else: print('failure: cmp (lt)')
-
 #max
 print('test: max (simple)')
 if max(range(5)) == 4: print('success: max (simple)')

src/builtins/funcs.pir

 .end
 
 
-=item basestring()
-
-This abstract type is the superclass for str and unicode. It cannot be called
-or instantiated, but it can be used to test whether an object is an instance
-of str or unicode. isinstance(obj, basestring) is equivalent to
-isinstance(obj, (str, unicode)). New in version 2.3.
-
-=cut
-
-.sub 'basestring'
-    $P0 = new 'Exception'
-    $P0 = 'NotImplementedError'      # XXX
-    throw $P0
-.end
-
 =item bool([x])
 
 Convert a value to a Boolean, using the standard truth testing procedure.
 .end
 
 
-=item callable(object)
-
-Return true if the object argument appears callable, false if not.
-If this returns true, it is still possible that a call fails, but
-if it is false, calling object will never succeed. Note that classes
-are callable (calling a class returns a new instance); class instances
-are callable if they have a __call__() method.
-
-=cut
-
-.sub 'callable'
-    .param pmc obj
-    .local int result
-    result = isa obj, 'Sub'
-    .return (result)
-.end
-
 =item chr(i)
 
 Return a string of one character whose ASCII code is the integer i.
 .end
 
 
-=item cmp(x, y)
-
-Compare the two objects x and y and return an integer according to the outcome.
-The return value is negative if x < y, zero if x == y and strictly positive if x > y.
-
-=cut
-
-.sub 'cmp'
-    .param pmc x
-    .param pmc y
-	$I0 = cmp x, y
-	$P0 = new 'Integer'
-	$P0 = $I0
-	.return ($P0)
-.end
-
-
 =item compile(string, filename, kind[, flags[, dont_inherit]])
 
 Compile the string into a code object. Code objects can be executed by an exec
     throw $P0
 .end
 
-=item execfile(filename[, globals[, locals]])
-
-This function is similar to the exec statement, but parses a file instead
-of a string. It is different from the import statement in that it does
-not use the module administration -- it reads the file unconditionally
-and does not create a new module.2.2
-
-The arguments are a file name and two optional dictionaries. The file
-is parsed and evaluated as a sequence of Python statements (similarly to a module)
-using the globals and locals dictionaries as global and local namespace.
-If provided, locals can be any mapping object. Changed in version 2.4:
-formerly locals was required to be a dictionary. If the locals dictionary
-is omitted it defaults to the globals dictionary. If both dictionaries are
-omitted, the expression is executed in the environment where execfile() is
-called. The return value is None.
-
-Warning: The default locals act as described for function locals() below:
-modifications to the default locals dictionary should not be attempted.
-Pass an explicit locals dictionary if you need to see effects of the code
-on locals after function execfile() returns. execfile() cannot be used
-reliably to modify a function's locals.
-
-=cut
-
-.sub 'execfile'
-    .param pmc filename
-    .param pmc globals :optional
-    .param pmc locals  :optional
-
-    $P0 = new 'Exception'
-    $P0 = 'NotImplementedError'      # XXX
-    throw $P0
-.end
-
-
 =item file(filename[, mode[, bufsize]])
 
 Constructor function for the file type, described further in section 3.9,
 .end
 
 
-=item raw_input([prompt])
-
-If the prompt argument is present, it is written to standard output without a
-trailing newline. The function then reads a line from input, converts it to a
-string (stripping a trailing newline), and returns that. When EOF is read,
-EOFError is raised. Example:
-
-  >>> s = raw_input('--> ')
-  --> Monty Python's Flying Circus
-  >>> s
-  "Monty Python's Flying Circus"
-
-If the readline module was loaded, then raw_input() will use it to provide
-elaborate line editing and history features.
-
-=cut
-
-.sub 'raw_input'
-    .param pmc prompt :optional
-
-    $P0 = new 'Exception'
-    $P0 = 'NotImplementedError'      # XXX
-    throw $P0
-.end
-
-
-=item reduce(function, sequence[, initializer])
-
-Apply function of two arguments cumulatively to the items of sequence, from
-left to right, so as to reduce the sequence to a single value. For example,
-reduce(lambda x, y: x+y, [1, 2, 3, 4, 5]) calculates ((((1+2)+3)+4)+5).
-The left argument, x, is the accumulated value and the right argument,
-y, is the update value from the sequence. If the optional initializer is
-present, it is placed before the items of the sequence in the calculation,
-and serves as a default when the sequence is empty. If initializer is not
-given and sequence contains only one item, the first item is returned.
-
-=cut
-
-.sub 'reduce'
-    .param pmc function
-    .param pmc sequence
-    .param pmc initializer :optional
-
-    $P0 = new 'Exception'
-    $P0 = 'NotImplementedError'      # XXX
-    throw $P0
-.end
-
-
-=item reload(module)
-
-Reload a previously imported module. The argument must be a module object, so
-it must have been successfully imported before. This is useful if you have
-edited the module source file using an external editor and want to try out the
-new version without leaving the Python interpreter. The return value is the
-module object (the same as the module argument).
-
-When reload(module) is executed:
-
-    * Python modules' code is recompiled and the module-level code reexecuted,
-    defining a new set of objects which are bound to names in the module's
-    dictionary. The init function of extension modules is not called a second time.
-
-    * As with all other objects in Python the old objects are only reclaimed
-    after their reference counts drop to zero.
-
-    * The names in the module namespace are updated to point to any
-    new or changed objects.
-
-    * Other references to the old objects (such as names external to the module)
-    are not rebound to refer to the new objects and must be updated in each
-    namespace where they occur if that is desired.
-
-There are a number of other caveats:
-
-If a module is syntactically correct but its initialization fails, the first
-import statement for it does not bind its name locally, but does store a
-(partially initialized) module object in sys.modules. To reload the module you
-must first import it again (this will bind the name to the partially initialized
-module object) before you can reload() it.
-
-When a module is reloaded, its dictionary (containing the module's global variables)
-is retained. Redefinitions of names will override the old definitions, so this is
-generally not a problem. If the new version of a module does not define a name that
-was defined by the old version, the old definition remains. This feature can be
-used to the module's advantage if it maintains a global table or cache of objects
--- with a try statement it can test for the table's presence and skip its
-initialization if desired:
-
-  try:
-      cache
-  except NameError:
-      cache = {}
-
-It is legal though generally not very useful to reload built-in or
-dynamically loaded modules, except for sys, __main__ and __builtin__.
-In many cases, however, extension modules are not designed to be initialized
-more than once, and may fail in arbitrary ways when reloaded.
-
-If a module imports objects from another module using from ... import ...,
-calling reload() for the other module does not redefine the objects imported
-from it -- one way around this is to re-execute the from statement, another
-is to use import and qualified names (module.name) instead.
-
-If a module instantiates instances of a class, reloading the module that
-defines the class does not affect the method definitions of the instances
--- they continue to use the old class definition. The same is true for
-derived classes.
-
-=cut
-
-
-.sub 'reload'
-    .param pmc module
-
-    $P0 = new 'Exception'
-    $P0 = 'NotImplementedError'      # XXX
-    throw $P0
-.end
-
-
-
 =item repr(object)
 
 Return a string containing a printable representation of an object. This is
 .end
 
 
-=item unichr(i)
-
-Return the Unicode string of one character whose Unicode code is the integer i.
-For example, unichr(97) returns the string u'a'. This is the inverse of ord()
-for Unicode strings. The valid range for the argument depends how Python was
-configured - it may be either UCS2 [0..0xFFFF] or UCS4 [0..0x10FFFF].
-ValueError is raised otherwise. New in version 2.0.
-
-=cut
-
-.sub 'unichr'
-    .param int i
-
-    $P0 = new 'Exception'
-    $P0 = 'NotImplementedError'      # XXX
-    throw $P0
-.end
-
-
-=item unicode([object[, encoding [, errors]]])
-
-Return the Unicode string version of object using one of the following modes:
-
-If encoding and/or errors are given, unicode() will decode the object which
-can either be an 8-bit string or a character buffer using the codec for encoding.
-The encoding parameter is a string giving the name of an encoding; if the encoding
-is not known, LookupError is raised. Error handling is done according to errors;
-this specifies the treatment of characters which are invalid in the input encoding.
-If errors is 'strict' (the default), a ValueError is raised on errors, while a
-value of 'ignore' causes errors to be silently ignored, and a value of 'replace'
-causes the official Unicode replacement character, U+FFFD, to be used to replace
-input characters which cannot be decoded. See also the codecs module.
-
-If no optional parameters are given, unicode() will mimic the behaviour of str()
-except that it returns Unicode strings instead of 8-bit strings. More precisely,
-if object is a Unicode string or subclass it will return that Unicode string
-without any additional decoding applied.
-
-For objects which provide a __unicode__() method, it will call this method
-without arguments to create a Unicode string. For all other objects, the
-8-bit string version or representation is requested and then converted to
-a Unicode string using the codec for the default encoding in 'strict' mode.
-
-New in version 2.0. Changed in version 2.2: Support for __unicode__() added.
-
-=cut
-
-.sub 'unicode'
-    .param pmc obj      :optional
-    .param pmc encoding :optional
-    .param pmc errors   :optional
-
-    $P0 = new 'Exception'
-    $P0 = 'NotImplementedError'      # XXX
-    throw $P0
-.end
-
 =item vars([object])
 
 Without arguments, return a dictionary corresponding to the current
 .end
 
 
-=item xrange([start,] stop[, step])
-
-This function is very similar to range(), but returns an ``xrange object''
-instead of a list. This is an opaque sequence type which yields the same
-values as the corresponding list, without actually storing them all
-simultaneously. The advantage of xrange() over range() is minimal
-(since xrange() still has to create the values when asked for them)
-except when a very large range is used on a memory-starved machine or
-when all of the range's elements are never used (such as when the
-loop is usually terminated with break).
-
-Note: xrange() is intended to be simple and fast. Implementations
-may impose restrictions to achieve this. The C implementation of Python
-restricts all arguments to native C longs ("short" Python integers),
-and also requires that the number of elements fit in a native C long.
-
-=cut
-
-.sub 'xrange'
-    .param pmc start #:optional?
-    .param pmc stop
-    .param pmc step :optional
-
-    $P0 = new 'Exception'
-    $P0 = 'NotImplementedError'      # XXX
-    throw $P0
-.end
-
-
-
 =item zip([iterable, ...])
 
 This function returns a list of tuples, where the i-th tuple contains the