diff --git a/Doc/c-api/exceptions.rst b/Doc/c-api/exceptions.rst index 819e22e02c8..2214c4d8e9a 100644 --- a/Doc/c-api/exceptions.rst +++ b/Doc/c-api/exceptions.rst @@ -446,6 +446,36 @@ Exception Objects This steals a reference to *ctx*. +Recursion Control +================= + +These two functions provide a way to perform safe recursive calls at the C +level, both in the core and in extension modules. They are needed if the +recursive code does not necessarily invoke Python code (which tracks its +recursion depth automatically). + +.. cfunction:: int Py_EnterRecursiveCall(char *where) + + Marks a point where a recursive C-level call is about to be performed. + + If :const:`USE_STACKCHECK` is defined, this function checks if the the OS + stack overflowed using :cfunc:`PyOS_CheckStack`. In this is the case, it + sets a :exc:`MemoryError` and returns a nonzero value. + + The function then checks if the recursion limit is reached. If this is the + case, a :exc:`RuntimeError` is set and a nonzero value is returned. + Otherwise, zero is returned. + + *where* should be a string such as ``" in instance check"`` to be + concatenated to the :exc:`RuntimeError` message caused by the recursion depth + limit. + +.. cfunction:: void Py_LeaveRecursiveCall() + + Ends a :cfunc:`Py_EnterRecursiveCall`. Must be called once for each + *successful* invocation of :cfunc:`Py_EnterRecursiveCall`. + + .. _standardexceptions: Standard Exceptions diff --git a/Doc/c-api/gcsupport.rst b/Doc/c-api/gcsupport.rst index 4f4d27d0017..1a280c823ab 100644 --- a/Doc/c-api/gcsupport.rst +++ b/Doc/c-api/gcsupport.rst @@ -28,7 +28,7 @@ include the :const:`Py_TPFLAGS_HAVE_GC` and provide an implementation of the Constructors for container types must conform to two rules: #. The memory for the object must be allocated using :cfunc:`PyObject_GC_New` - or :cfunc:`PyObject_GC_VarNew`. + or :cfunc:`PyObject_GC_NewVar`. #. Once all the fields which may contain references to other containers are initialized, it must call :cfunc:`PyObject_GC_Track`. diff --git a/Doc/c-api/typeobj.rst b/Doc/c-api/typeobj.rst index 378bfe1d893..eb8a83e179c 100644 --- a/Doc/c-api/typeobj.rst +++ b/Doc/c-api/typeobj.rst @@ -182,7 +182,7 @@ type objects) *must* have the :attr:`ob_size` field. instance; this is normally :cfunc:`PyObject_Del` if the instance was allocated using :cfunc:`PyObject_New` or :cfunc:`PyObject_VarNew`, or :cfunc:`PyObject_GC_Del` if the instance was allocated using - :cfunc:`PyObject_GC_New` or :cfunc:`PyObject_GC_VarNew`. + :cfunc:`PyObject_GC_New` or :cfunc:`PyObject_GC_NewVar`. This field is inherited by subtypes. diff --git a/Doc/extending/newtypes.rst b/Doc/extending/newtypes.rst index 074a603fc0f..63ea2a65dcd 100644 --- a/Doc/extending/newtypes.rst +++ b/Doc/extending/newtypes.rst @@ -236,7 +236,7 @@ This version of the module has a number of changes. We've added an extra include:: - #include "structmember.h" + #include This include provides declarations that we use to handle attributes, as described a bit later. diff --git a/Doc/faq/windows.rst b/Doc/faq/windows.rst index 2a19c981fc5..5a5b7edf2e4 100644 --- a/Doc/faq/windows.rst +++ b/Doc/faq/windows.rst @@ -445,13 +445,15 @@ present, and ``getch()`` which gets one character without echoing it. How do I emulate os.kill() in Windows? -------------------------------------- -Use win32api:: +To terminate a process, you can use ctypes:: + + import ctypes def kill(pid): """kill function for Win32""" - import win32api - handle = win32api.OpenProcess(1, 0, pid) - return (0 != win32api.TerminateProcess(handle, 0)) + kernel32 = ctypes.windll.kernel32 + handle = kernel32.OpenProcess(1, 0, pid) + return (0 != kernel32.TerminateProcess(handle, 0)) Why does os.path.isdir() fail on NT shared directories? diff --git a/Doc/library/codecs.rst b/Doc/library/codecs.rst index 8e4f71e15ab..b495c6fa932 100644 --- a/Doc/library/codecs.rst +++ b/Doc/library/codecs.rst @@ -1063,11 +1063,13 @@ particular, the following variants typically exist: +-----------------+--------------------------------+--------------------------------+ | iso8859_10 | iso-8859-10, latin6, L6 | Nordic languages | +-----------------+--------------------------------+--------------------------------+ -| iso8859_13 | iso-8859-13 | Baltic languages | +| iso8859_13 | iso-8859-13, latin7, L7 | Baltic languages | +-----------------+--------------------------------+--------------------------------+ | iso8859_14 | iso-8859-14, latin8, L8 | Celtic languages | +-----------------+--------------------------------+--------------------------------+ -| iso8859_15 | iso-8859-15 | Western Europe | +| iso8859_15 | iso-8859-15, latin9, L9 | Western Europe | ++-----------------+--------------------------------+--------------------------------+ +| iso8859_16 | iso-8859-16, latin10, L10 | South-Eastern Europe | +-----------------+--------------------------------+--------------------------------+ | johab | cp1361, ms1361 | Korean | +-----------------+--------------------------------+--------------------------------+ diff --git a/Doc/library/datetime.rst b/Doc/library/datetime.rst index 6ead309b3fe..5899ba7a95c 100644 --- a/Doc/library/datetime.rst +++ b/Doc/library/datetime.rst @@ -1460,8 +1460,8 @@ Example :class:`tzinfo` classes: Note that there are unavoidable subtleties twice per year in a :class:`tzinfo` subclass accounting for both standard and daylight time, at the DST transition points. For concreteness, consider US Eastern (UTC -0500), where EDT begins the -minute after 1:59 (EST) on the first Sunday in April, and ends the minute after -1:59 (EDT) on the last Sunday in October:: +minute after 1:59 (EST) on the second Sunday in March, and ends the minute after +1:59 (EDT) on the first Sunday in November:: UTC 3:MM 4:MM 5:MM 6:MM 7:MM 8:MM EST 22:MM 23:MM 0:MM 1:MM 2:MM 3:MM diff --git a/Doc/library/doctest.rst b/Doc/library/doctest.rst index cea570bdbb6..2cf5fdcf912 100644 --- a/Doc/library/doctest.rst +++ b/Doc/library/doctest.rst @@ -633,7 +633,7 @@ example. Use ``+`` to enable the named behavior, or ``-`` to disable it. For example, this test passes:: - >>> print(range(20)) #doctest: +NORMALIZE_WHITESPACE + >>> print(list(range(20))) #doctest: +NORMALIZE_WHITESPACE [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19] @@ -642,28 +642,28 @@ two blanks before the single-digit list elements, and because the actual output is on a single line. This test also passes, and also requires a directive to do so:: - >>> print(range(20)) # doctest: +ELLIPSIS + >>> print(list(range(20))) # doctest: +ELLIPSIS [0, 1, ..., 18, 19] Multiple directives can be used on a single physical line, separated by commas:: - >>> print(range(20)) # doctest: +ELLIPSIS, +NORMALIZE_WHITESPACE + >>> print(list(range(20))) # doctest: +ELLIPSIS, +NORMALIZE_WHITESPACE [0, 1, ..., 18, 19] If multiple directive comments are used for a single example, then they are combined:: - >>> print(range(20)) # doctest: +ELLIPSIS - ... # doctest: +NORMALIZE_WHITESPACE + >>> print(list(range(20))) # doctest: +ELLIPSIS + ... # doctest: +NORMALIZE_WHITESPACE [0, 1, ..., 18, 19] As the previous example shows, you can add ``...`` lines to your example containing only directives. This can be useful when an example is too long for a directive to comfortably fit on the same line:: - >>> print(range(5) + range(10,20) + range(30,40) + range(50,60)) + >>> print(list(range(5)) + list(range(10, 20)) + list(range(30, 40))) ... # doctest: +ELLIPSIS - [0, ..., 4, 10, ..., 19, 30, ..., 39, 50, ..., 59] + [0, ..., 4, 10, ..., 19, 30, ..., 39] Note that since all options are disabled by default, and directives apply only to the example they appear in, enabling options (via ``+`` in a directive) is diff --git a/Doc/library/stdtypes.rst b/Doc/library/stdtypes.rst index 1e2c47cd7f5..ee27f74c267 100644 --- a/Doc/library/stdtypes.rst +++ b/Doc/library/stdtypes.rst @@ -1639,6 +1639,10 @@ The :class:`frozenset` type is immutable and :term:`hashable` --- its contents c altered after it is created; it can therefore be used as a dictionary key or as an element of another set. +Non-empty sets (not frozensets) can be created by placing a comma-separated list +of elements within braces, for example: ``{'jack', 'sjoerd'}``, in addition to the +:class:`set` constructor. + The constructors for both classes work the same: .. class:: set([iterable]) diff --git a/Doc/library/subprocess.rst b/Doc/library/subprocess.rst index 698e5351707..3aaa6c6fa43 100644 --- a/Doc/library/subprocess.rst +++ b/Doc/library/subprocess.rst @@ -396,6 +396,9 @@ The following attributes are also available: The process ID of the child process. + Note that if you set the *shell* argument to ``True``, this is the process ID + of the spawned shell. + .. attribute:: Popen.returncode diff --git a/Doc/library/sys.rst b/Doc/library/sys.rst index f0e551ea155..5d40d5e763b 100644 --- a/Doc/library/sys.rst +++ b/Doc/library/sys.rst @@ -127,13 +127,12 @@ always available. .. index:: object: traceback - If no exception is being handled anywhere on the stack, a tuple containing three - ``None`` values is returned. Otherwise, the values returned are ``(type, value, - traceback)``. Their meaning is: *type* gets the exception type of the exception - being handled (a class object); *value* gets the exception parameter (its - :dfn:`associated value` or the second argument to :keyword:`raise`, which is - always a class instance if the exception type is a class object); *traceback* - gets a traceback object (see the Reference Manual) which encapsulates the call + If no exception is being handled anywhere on the stack, a tuple containing + three ``None`` values is returned. Otherwise, the values returned are + ``(type, value, traceback)``. Their meaning is: *type* gets the type of the + exception being handled (a subclass of :exc:`BaseException`); *value* gets + the exception instance (an instance of the exception type); *traceback* gets + a traceback object (see the Reference Manual) which encapsulates the call stack at the point where the exception originally occurred. .. warning:: @@ -495,9 +494,7 @@ always available. more information.) The meaning of the variables is the same as that of the return values from - :func:`exc_info` above. (Since there is only one interactive thread, - thread-safety is not a concern for these variables, unlike for ``exc_type`` - etc.) + :func:`exc_info` above. .. data:: maxsize diff --git a/Doc/reference/executionmodel.rst b/Doc/reference/executionmodel.rst index 90791d22472..b4c29b1b7fb 100644 --- a/Doc/reference/executionmodel.rst +++ b/Doc/reference/executionmodel.rst @@ -120,7 +120,7 @@ namespace is searched. The global statement must precede all uses of the name. .. index:: pair: restricted; execution -The built-in namespace associated with the execution of a code block is actually +The builtins namespace associated with the execution of a code block is actually found by looking up the name ``__builtins__`` in its global namespace; this should be a dictionary or a module (in the latter case the module's dictionary is used). By default, when in the :mod:`__main__` module, ``__builtins__`` is @@ -132,7 +132,7 @@ weak form of restricted execution. .. impl-detail:: Users should not touch ``__builtins__``; it is strictly an implementation - detail. Users wanting to override values in the built-in namespace should + detail. Users wanting to override values in the builtins namespace should :keyword:`import` the :mod:`builtins` module and modify its attributes appropriately. diff --git a/Doc/reference/expressions.rst b/Doc/reference/expressions.rst index c7dd3fc6af1..c71e89e694f 100644 --- a/Doc/reference/expressions.rst +++ b/Doc/reference/expressions.rst @@ -1120,12 +1120,7 @@ Boolean operations pair: Conditional; expression pair: Boolean; operation -Boolean operations have the lowest priority of all Python operations: - .. productionlist:: - expression: `conditional_expression` | `lambda_form` - expression_nocond: `or_test` | `lambda_form_nocond` - conditional_expression: `or_test` ["if" `or_test` "else" `expression`] or_test: `and_test` | `or_test` "or" `and_test` and_test: `not_test` | `and_test` "and" `not_test` not_test: `comparison` | "not" `not_test` @@ -1142,10 +1137,6 @@ truth value by providing a :meth:`__bool__` method. The operator :keyword:`not` yields ``True`` if its argument is false, ``False`` otherwise. -The expression ``x if C else y`` first evaluates *C* (*not* *x*); if *C* is -true, *x* is evaluated and its value is returned; otherwise, *y* is evaluated -and its value is returned. - .. index:: operator: and The expression ``x and y`` first evaluates *x*; if *x* is false, its value is @@ -1165,6 +1156,30 @@ not bother to return a value of the same type as its argument, so e.g., ``not 'foo'`` yields ``False``, not ``''``.) +Conditional Expressions +======================= + +.. versionadded:: 2.5 + +.. index:: + pair: conditional; expression + pair: ternary; operator + +.. productionlist:: + conditional_expression: `or_test` ["if" `or_test` "else" `expression`] + expression: `conditional_expression` | `lambda_form` + expression_nocond: `or_test` | `lambda_form_nocond` + +Conditional expressions (sometimes called a "ternary operator") have the lowest +priority of all Python operations. + +The expression ``x if C else y`` first evaluates the condition, *C* (*not* *x*); +if *C* is true, *x* is evaluated and its value is returned; otherwise, *y* is +evaluated and its value is returned. + +See :pep:`308` for more details about conditional expressions. + + .. _lambdas: .. _lambda: @@ -1259,6 +1274,8 @@ groups from right to left). +===============================================+=====================================+ | :keyword:`lambda` | Lambda expression | +-----------------------------------------------+-------------------------------------+ +| :keyword:`if` -- :keyword:`else` | Conditional expression | ++-----------------------------------------------+-------------------------------------+ | :keyword:`or` | Boolean OR | +-----------------------------------------------+-------------------------------------+ | :keyword:`and` | Boolean AND | diff --git a/Doc/reference/simple_stmts.rst b/Doc/reference/simple_stmts.rst index 531d69a90be..30861d4c682 100644 --- a/Doc/reference/simple_stmts.rst +++ b/Doc/reference/simple_stmts.rst @@ -148,9 +148,9 @@ Assignment of an object to a single target is recursively defined as follows. .. index:: single: destructor - The name is rebound if it was already bound. This may cause the reference count - for the object previously bound to the name to reach zero, causing the object to - be deallocated and its destructor (if it has one) to be called. + The name is rebound if it was already bound. This may cause the reference + count for the object previously bound to the name to reach zero, causing the + object to be deallocated and its destructor (if it has one) to be called. * If the target is a target list enclosed in parentheses or in square brackets: The object must be an iterable with the same number of items as there are diff --git a/Doc/using/cmdline.rst b/Doc/using/cmdline.rst index 540e4d7b0f9..0978770e1a4 100644 --- a/Doc/using/cmdline.rst +++ b/Doc/using/cmdline.rst @@ -232,8 +232,9 @@ Miscellaneous options .. cmdoption:: -u - Force stdin, stdout and stderr to be totally unbuffered. On systems where it - matters, also put stdin, stdout and stderr in binary mode. + Force the binary layer of the stdin, stdout and stderr streams (which is + available as their ``buffer`` attribute) to be unbuffered. The text I/O + layer will still be line-buffered. See also :envvar:`PYTHONUNBUFFERED`. diff --git a/Doc/whatsnew/2.6.rst b/Doc/whatsnew/2.6.rst index 00398fc4287..1af78c22767 100644 --- a/Doc/whatsnew/2.6.rst +++ b/Doc/whatsnew/2.6.rst @@ -111,9 +111,9 @@ are: :func:`reduce` function. Python 3.0 adds several new built-in functions and changes the -semantics of some existing built-ins. Functions that are new in 3.0 +semantics of some existing builtins. Functions that are new in 3.0 such as :func:`bin` have simply been added to Python 2.6, but existing -built-ins haven't been changed; instead, the :mod:`future_builtins` +builtins haven't been changed; instead, the :mod:`future_builtins` module has versions with the new 3.0 semantics. Code written to be compatible with 3.0 can do ``from future_builtins import hex, map`` as necessary. @@ -837,7 +837,7 @@ formatted. It receives a single argument, the format specifier:: else: return str(self) -There's also a :func:`format` built-in that will format a single +There's also a :func:`format` builtin that will format a single value. It calls the type's :meth:`__format__` method with the provided specifier:: @@ -1168,7 +1168,7 @@ access protocol. Abstract Base Classes (or ABCs) are an equivalent feature for Python. The ABC support consists of an :mod:`abc` module containing a metaclass called :class:`ABCMeta`, special handling of this metaclass by the :func:`isinstance` and :func:`issubclass` -built-ins, and a collection of basic ABCs that the Python developers +builtins, and a collection of basic ABCs that the Python developers think will be widely useful. Future versions of Python will probably add more ABCs. @@ -1322,9 +1322,9 @@ an octal number, but it does add support for "0o" and "0b":: >>> 0b101111 47 -The :func:`oct` built-in still returns numbers +The :func:`oct` builtin still returns numbers prefixed with a leading zero, and a new :func:`bin` -built-in returns the binary representation for a number:: +builtin returns the binary representation for a number:: >>> oct(42) '052' @@ -1333,7 +1333,7 @@ built-in returns the binary representation for a number:: >>> bin(173) '0b10101101' -The :func:`int` and :func:`long` built-ins will now accept the "0o" +The :func:`int` and :func:`long` builtins will now accept the "0o" and "0b" prefixes when base-8 or base-2 are requested, or when the *base* argument is zero (signalling that the base used should be determined from the string):: @@ -1419,7 +1419,7 @@ can be shifted left and right with ``<<`` and ``>>``, combined using bitwise operations such as ``&`` and ``|``, and can be used as array indexes and slice boundaries. -In Python 3.0, the PEP slightly redefines the existing built-ins +In Python 3.0, the PEP slightly redefines the existing builtins :func:`round`, :func:`math.floor`, :func:`math.ceil`, and adds a new one, :func:`math.trunc`, that's been backported to Python 2.6. :func:`math.trunc` rounds toward zero, returning the closest @@ -1520,7 +1520,7 @@ Some smaller changes made to the core Python language are: Previously this would have been a syntax error. (Contributed by Amaury Forgeot d'Arc; :issue:`3473`.) -* A new built-in, ``next(iterator, [default])`` returns the next item +* A new builtin, ``next(iterator, [default])`` returns the next item from the specified iterator. If the *default* argument is supplied, it will be returned if *iterator* has been exhausted; otherwise, the :exc:`StopIteration` exception will be raised. (Backported @@ -1949,9 +1949,9 @@ changes, or look through the Subversion logs for all the details. (Contributed by Phil Schwartz; :issue:`1221598`.) * The :func:`reduce` built-in function is also available in the - :mod:`functools` module. In Python 3.0, the built-in has been + :mod:`functools` module. In Python 3.0, the builtin has been dropped and :func:`reduce` is only available from :mod:`functools`; - currently there are no plans to drop the built-in in the 2.x series. + currently there are no plans to drop the builtin in the 2.x series. (Patched by Christian Heimes; :issue:`1739906`.) * When possible, the :mod:`getpass` module will now use @@ -2753,7 +2753,7 @@ The functions in this module currently include: * ``filter(predicate, iterable)``, ``map(func, iterable1, ...)``: the 3.0 versions - return iterators, unlike the 2.x built-ins which return lists. + return iterators, unlike the 2.x builtins which return lists. * ``hex(value)``, ``oct(value)``: instead of calling the :meth:`__hex__` or :meth:`__oct__` methods, these versions will diff --git a/Misc/HISTORY b/Misc/HISTORY index 4fb749aa1c0..57ae98d2d8d 100644 --- a/Misc/HISTORY +++ b/Misc/HISTORY @@ -2544,7 +2544,7 @@ Core and builtins - Bug #1244610, #1392915, fix build problem on OpenBSD 3.7 and 3.8. configure would break checking curses.h. -- Bug #959576: The pwd module is now builtin. This allows Python to be +- Bug #959576: The pwd module is now built in. This allows Python to be built on UNIX platforms without $HOME set. - Bug #1072182, fix some potential problems if characters are signed. @@ -2577,7 +2577,7 @@ Core and builtins it will now use a default error message in this case. - Replaced most Unicode charmap codecs with new ones using the - new Unicode translate string feature in the builtin charmap + new Unicode translate string feature in the built-in charmap codec; the codecs were created from the mapping tables available at ftp.unicode.org and contain a few updates (e.g. the Mac OS encodings now include a mapping for the Apple logo) @@ -3032,7 +3032,7 @@ Library current file number. - Patch #1349274: gettext.install() now optionally installs additional - translation functions other than _() in the builtin namespace. + translation functions other than _() in the builtins namespace. - Patch #1337756: fileinput now accepts Unicode filenames. @@ -3403,7 +3403,7 @@ Build - Patch #881820: look for openpty and forkpty also in libbsd. - The sources of zlib are now part of the Python distribution (zlib 1.2.3). - The zlib module is now builtin on Windows. + The zlib module is now built in on Windows. - Use -xcode=pic32 for CCSHARED on Solaris with SunPro. @@ -4238,7 +4238,7 @@ Library - Patch #846659. Fix an error in tarfile.py when using GNU longname/longlink creation. -- The obsolete FCNTL.py has been deleted. The builtin fcntl module +- The obsolete FCNTL.py has been deleted. The built-in fcntl module has been available (on platforms that support fcntl) since Python 1.5a3, and all FCNTL.py did is export fcntl's names, after generating a deprecation warning telling you to use fcntl directly. @@ -4492,7 +4492,7 @@ Core and builtins segfault in a debug build, but provided less predictable behavior in a release build. -- input() builtin function now respects compiler flags such as +- input() built-in function now respects compiler flags such as __future__ statements. SF patch 876178. - Removed PendingDeprecationWarning from apply(). apply() remains @@ -4553,12 +4553,12 @@ Core and builtins - Compiler flags set in PYTHONSTARTUP are now active in __main__. -- Added two builtin types, set() and frozenset(). +- Added two built-in types, set() and frozenset(). -- Added a reversed() builtin function that returns a reverse iterator +- Added a reversed() built-in function that returns a reverse iterator over a sequence. -- Added a sorted() builtin function that returns a new sorted list +- Added a sorted() built-in function that returns a new sorted list from any iterable. - CObjects are now mutable (on the C level) through PyCObject_SetVoidPtr. @@ -4597,7 +4597,7 @@ Core and builtins When comparing containers with cyclic references to themselves it will now just hit the recursion limit. See SF patch 825639. -- str and unicode builtin types now have an rsplit() method that is +- str and unicode built-in types now have an rsplit() method that is same as split() except that it scans the string from the end working towards the beginning. See SF feature request 801847. @@ -5148,7 +5148,7 @@ Core and builtins - A warning about assignments to module attributes that shadow builtins, present in earlier releases of 2.3, has been removed. -- It is not possible to create subclasses of builtin types like str +- It is not possible to create subclasses of built-in types like str and tuple that define an itemsize. Earlier releases of Python 2.3 allowed this by mistake, leading to crashes and other problems. @@ -5623,13 +5623,13 @@ Core and builtins - New format codes B, H, I, k and K have been implemented for PyArg_ParseTuple and PyBuild_Value. -- New builtin function sum(seq, start=0) returns the sum of all the +- New built-in function sum(seq, start=0) returns the sum of all the items in iterable object seq, plus start (items are normally numbers, and cannot be strings). - bool() called without arguments now returns False rather than raising an exception. This is consistent with calling the - constructors for the other builtin types -- called without argument + constructors for the other built-in types -- called without argument they all return the false value of that type. (SF patch #724135) - In support of PEP 269 (making the pgen parser generator accessible @@ -6154,7 +6154,7 @@ Library internals, and supplies some helpers for working with pickles, such as a symbolic pickle disassembler. -- Xmlrpclib.py now supports the builtin boolean type. +- xmlrpclib.py now supports the built-in boolean type. - py_compile has a new 'doraise' flag and a new PyCompileError exception. @@ -6405,8 +6405,8 @@ Core and builtins trace function to change which line will execute next. A command to exploit this from pdb has been added. [SF patch #643835] -- The _codecs support module for codecs.py was turned into a builtin - module to assure that at least the builtin codecs are available +- The _codecs support module for codecs.py was turned into a built-in + module to assure that at least the built-in codecs are available to the Python parser for source code decoding according to PEP 263. - issubclass now supports a tuple as the second argument, just like @@ -6564,13 +6564,13 @@ Core and builtins - Unicode objects in sys.path are no longer ignored but treated as directory names. -- Fixed string.startswith and string.endswith builtin methods +- Fixed string.startswith and string.endswith built-in methods so they accept negative indices. [SF bug 493951] - Fixed a bug with a continue inside a try block and a yield in the finally clause. [SF bug 567538] -- Most builtin sequences now support "extended slices", i.e. slices +- Most built-in sequences now support "extended slices", i.e. slices with a third "stride" parameter. For example, "hello world"[::-1] gives "dlrow olleh". @@ -6585,7 +6585,7 @@ Core and builtins method no longer exist. xrange repetition and slicing have been removed. -- New builtin function enumerate(x), from PEP 279. Example: +- New built-in function enumerate(x), from PEP 279. Example: enumerate("abc") is an iterator returning (0,"a"), (1,"b"), (2,"c"). The argument can be an arbitrary iterable object. @@ -7134,7 +7134,7 @@ Build Presumably 2.3a1 breaks such systems. If anyone uses such a system, help! - The configure option --without-doc-strings can be used to remove the - doc strings from the builtin functions and modules; this reduces the + doc strings from the built-in functions and modules; this reduces the size of the executable. - The universal newlines option (PEP 278) is on by default. On Unix @@ -7370,7 +7370,7 @@ Mac available for convenience. - New Carbon modules File (implementing the APIs in Files.h and Aliases.h) - and Folder (APIs from Folders.h). The old macfs builtin module is + and Folder (APIs from Folders.h). The old macfs built-in module is gone, and replaced by a Python wrapper around the new modules. - Pathname handling should now be fully consistent: MacPython-OSX always uses @@ -7592,7 +7592,7 @@ Build C API ----- -- New function PyDict_MergeFromSeq2() exposes the builtin dict +- New function PyDict_MergeFromSeq2() exposes the built-in dict constructor's logic for updating a dictionary from an iterable object producing key-value pairs. @@ -7643,7 +7643,7 @@ Type/class unification and new-style classes using new-style MRO rules if any base class is a new-style class. This needs to be documented. -- The new builtin dictionary() constructor, and dictionary type, have +- The new built-in dictionary() constructor, and dictionary type, have been renamed to dict. This reflects a decade of common usage. - dict() now accepts an iterable object producing 2-sequences. For @@ -8093,9 +8093,9 @@ Type/class unification and new-style classes The new class must have the same C-level object layout as the old class. -- The builtin file type can be subclassed now. In the usual pattern, - "file" is the name of the builtin type, and file() is a new builtin - constructor, with the same signature as the builtin open() function. +- The built-in file type can be subclassed now. In the usual pattern, + "file" is the name of the built-in type, and file() is a new built-in + constructor, with the same signature as the built-in open() function. file() is now the preferred way to open a file. - Previously, __new__ would only see sequential arguments passed to @@ -8109,7 +8109,7 @@ Type/class unification and new-style classes - Previously, an operation on an instance of a subclass of an immutable type (int, long, float, complex, tuple, str, unicode), where the subtype didn't override the operation (and so the - operation was handled by the builtin type), could return that + operation was handled by the built-in type), could return that instance instead a value of the base type. For example, if s was of a str subclass type, s[:] returned s as-is. Now it returns a str with the same value as s. @@ -8157,7 +8157,7 @@ Library called for each iteration until it returns an empty string). - The codecs module has grown four new helper APIs to access - builtin codecs: getencoder(), getdecoder(), getreader(), + built-in codecs: getencoder(), getdecoder(), getreader(), getwriter(). - SimpleXMLRPCServer: a new module (based upon SimpleHTMLServer) @@ -9287,7 +9287,7 @@ Core language, builtins, and interpreter In all previous version of Python, names were resolved in exactly three namespaces -- the local namespace, the global namespace, and - the builtin namespace. According to this old definition, if a + the builtins namespace. According to this old definition, if a function A is defined within a function B, the names bound in B are not visible in A. The new rules make names bound in B visible in A, unless A contains a name binding that hides the binding in B. @@ -9308,7 +9308,7 @@ Core language, builtins, and interpreter return str.strip() Under the old rules, the name str in helper() is bound to the - builtin function str(). Under the new rules, it will be bound to + built-in function str(). Under the new rules, it will be bound to the argument named str and an error will occur when helper() is called. @@ -9806,7 +9806,7 @@ Core language, builtins, and interpreter assignment, e.g. +=, was fixed. - Raise ZeroDivisionError when raising zero to a negative number, - e.g. 0.0 ** -2.0. Note that math.pow is unrelated to the builtin + e.g. 0.0 ** -2.0. Note that math.pow is unrelated to the built-in power operator and the result of math.pow(0.0, -2.0) will vary by platform. On Linux, it raises a ValueError. @@ -14056,7 +14056,7 @@ done to prevent accidental subdirectories with common names from overriding modules with the same name. - Fixed some strange exceptions in __del__ methods in library modules -(e.g. urllib). This happens because the builtin names are already +(e.g. urllib). This happens because the built-in names are already deleted by the time __del__ is called. The solution (a hack, but it works) is to set some instance variables to 0 instead of None. @@ -14759,8 +14759,8 @@ is set to somevalue.__class__, and SomeClass is ignored after that. f(a=1,a=2) is now a syntax error. -Changes to builtin features ---------------------------- +Changes to built-in features +---------------------------- - There's a new exception FloatingPointError (used only by Lee Busby's patches to catch floating point exceptions, at the moment). @@ -16060,7 +16060,7 @@ intervention may still be required.) (This has been fixed in 1.4beta3.) - New modules: errno, operator (XXX). -- Changes for use with Numerical Python: builtin function slice() and +- Changes for use with Numerical Python: built-in function slice() and Ellipses object, and corresponding syntax: x[lo:hi:stride] == x[slice(lo, hi, stride)] @@ -16548,7 +16548,7 @@ Complex in the library. - The functions posix.popen() and posix.fdopen() now have an optional third argument to specify the buffer size, and default their second -(mode) argument to 'r' -- in analogy to the builtin open() function. +(mode) argument to 'r' -- in analogy to the built-in open() function. The same applies to posixfile.open() and the socket method makefile(). - The thread.exit_thread() function now raises SystemExit so that diff --git a/Misc/SpecialBuilds.txt b/Misc/SpecialBuilds.txt index fa87d92ad32..25bb6d1e380 100644 --- a/Misc/SpecialBuilds.txt +++ b/Misc/SpecialBuilds.txt @@ -37,7 +37,7 @@ Py_TRACE_REFS introduced in 1.4 Turn on heavy reference debugging. This is major surgery. Every PyObject grows two more pointers, to maintain a doubly-linked list of all live -heap-allocated objects. Most builtin type objects are not in this list, +heap-allocated objects. Most built-in type objects are not in this list, as they're statically allocated. Starting in Python 2.3, if COUNT_ALLOCS (see below) is also defined, a static type object T does appear in this list if at least one object of type T has been created. diff --git a/Misc/python.man b/Misc/python.man index 9a406a8e95a..b96c8608b14 100644 --- a/Misc/python.man +++ b/Misc/python.man @@ -165,12 +165,12 @@ and the site-dependent manipulations of that it entails. .TP .B \-u -Force stdin, stdout and stderr to be totally unbuffered. On systems -where it matters, also put stdin, stdout and stderr in binary mode. -Note that there is internal buffering in readlines() and -file-object iterators ("for line in sys.stdin") which is not -influenced by this option. To work around this, you will want to use -"sys.stdin.readline()" inside a "while 1:" loop. +Force the binary I/O layers of stdin, stdout and stderr to be unbuffered. +The text I/O layer will still be line-buffered. +.\" Note that there is internal buffering in readlines() and +.\" file-object iterators ("for line in sys.stdin") which is not +.\" influenced by this option. To work around this, you will want to use +.\" "sys.stdin.readline()" inside a "while 1:" loop. .TP .B \-v Print a message each time a module is initialized, showing the place