Ignore:
Timestamp:
Mar 19, 2014, 11:31:01 PM (11 years ago)
Author:
dmik
Message:

python: Merge vendor 2.7.6 to trunk.

Location:
python/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • python/trunk

  • python/trunk/Doc/whatsnew/2.5.rst

    r2 r391  
    871871========================================
    872872
    873 A wide-ranging change to Python's C API, using a new  :ctype:`Py_ssize_t` type
    874 definition instead of :ctype:`int`,  will permit the interpreter to handle more
     873A wide-ranging change to Python's C API, using a new  :c:type:`Py_ssize_t` type
     874definition instead of :c:type:`int`,  will permit the interpreter to handle more
    875875data on 64-bit platforms. This change doesn't affect Python's capacity on 32-bit
    876876platforms.
    877877
    878 Various pieces of the Python interpreter used C's :ctype:`int` type to store
     878Various pieces of the Python interpreter used C's :c:type:`int` type to store
    879879sizes or counts; for example, the number of items in a list or tuple were stored
    880 in an :ctype:`int`.  The C compilers for most 64-bit platforms still define
    881 :ctype:`int` as a 32-bit type, so that meant that lists could only hold up to
     880in an :c:type:`int`.  The C compilers for most 64-bit platforms still define
     881:c:type:`int` as a 32-bit type, so that meant that lists could only hold up to
    882882``2**31 - 1`` = 2147483647 items. (There are actually a few different
    883883programming models that 64-bit C compilers can use -- see
    884884http://www.unix.org/version2/whatsnew/lp64_wp.html for a discussion -- but the
    885 most commonly available model leaves :ctype:`int` as 32 bits.)
     885most commonly available model leaves :c:type:`int` as 32 bits.)
    886886
    887887A limit of 2147483647 items doesn't really matter on a 32-bit platform because
    888888you'll run out of memory before hitting the length limit. Each list item
    889889requires space for a pointer, which is 4 bytes, plus space for a
    890 :ctype:`PyObject` representing the item.  2147483647\*4 is already more bytes
     890:c:type:`PyObject` representing the item.  2147483647\*4 is already more bytes
    891891than a 32-bit address space can contain.
    892892
     
    895895unreasonable that Python programmers might construct lists that large.
    896896Therefore, the Python interpreter had to be changed to use some type other than
    897 :ctype:`int`, and this will be a 64-bit type on 64-bit platforms.  The change
     897:c:type:`int`, and this will be a 64-bit type on 64-bit platforms.  The change
    898898will cause incompatibilities on 64-bit machines, so it was deemed worth making
    899899the transition now, while the number of 64-bit users is still relatively small.
     
    903903This change most strongly affects authors of C extension modules.   Python
    904904strings and container types such as lists and tuples  now use
    905 :ctype:`Py_ssize_t` to store their size.   Functions such as
    906 :cfunc:`PyList_Size`  now return :ctype:`Py_ssize_t`.  Code in extension modules
    907 may therefore need to have some variables changed to :ctype:`Py_ssize_t`.
    908 
    909 The :cfunc:`PyArg_ParseTuple` and :cfunc:`Py_BuildValue` functions have a new
    910 conversion code, ``n``, for :ctype:`Py_ssize_t`.   :cfunc:`PyArg_ParseTuple`'s
    911 ``s#`` and ``t#`` still output :ctype:`int` by default, but you can define the
    912 macro  :cmacro:`PY_SSIZE_T_CLEAN` before including :file:`Python.h`  to make
    913 them return :ctype:`Py_ssize_t`.
     905:c:type:`Py_ssize_t` to store their size.   Functions such as
     906:c:func:`PyList_Size`  now return :c:type:`Py_ssize_t`.  Code in extension modules
     907may therefore need to have some variables changed to :c:type:`Py_ssize_t`.
     908
     909The :c:func:`PyArg_ParseTuple` and :c:func:`Py_BuildValue` functions have a new
     910conversion code, ``n``, for :c:type:`Py_ssize_t`.   :c:func:`PyArg_ParseTuple`'s
     911``s#`` and ``t#`` still output :c:type:`int` by default, but you can define the
     912macro  :c:macro:`PY_SSIZE_T_CLEAN` before including :file:`Python.h`  to make
     913them return :c:type:`Py_ssize_t`.
    914914
    915915:pep:`353` has a section on conversion guidelines that  extension authors should
     
    955955
    956956A corresponding :attr:`nb_index` slot was added to the C-level
    957 :ctype:`PyNumberMethods` structure to let C extensions implement this protocol.
    958 :cfunc:`PyNumber_Index(obj)` can be used in extension code to call the
     957:c:type:`PyNumberMethods` structure to let C extensions implement this protocol.
     958:c:func:`PyNumber_Index(obj)` can be used in extension code to call the
    959959:meth:`__index__` function and retrieve its result.
    960960
     
    11801180
    11811181* The :mod:`re` module got a 1 or 2% speedup by switching to  Python's allocator
    1182   functions instead of the system's  :cfunc:`malloc` and :cfunc:`free`.
     1182  functions instead of the system's  :c:func:`malloc` and :c:func:`free`.
    11831183  (Contributed by Jack Diederich at the NeedForSpeed sprint.)
    11841184
     
    12041204
    12051205* Importing now caches the paths tried, recording whether  they exist or not so
    1206   that the interpreter makes fewer  :cfunc:`open` and :cfunc:`stat` calls on
     1206  that the interpreter makes fewer  :c:func:`open` and :c:func:`stat` calls on
    12071207  startup. (Contributed by Martin von Löwis and Georg Brandl.)
    12081208
     
    13391339  .. XXX need to provide some more detail here
    13401340
     1341  .. index::
     1342     single: universal newlines; What's new
     1343
    13411344* The :mod:`fileinput` module was made more flexible. Unicode filenames are now
    13421345  supported, and a *mode* parameter that defaults to ``"r"`` was added to the
    1343   :func:`input` function to allow opening files in binary or universal-newline
    1344   mode.  Another new parameter, *openhook*, lets you use a function other than
    1345   :func:`open`  to open the input files.  Once you're iterating over  the set of
    1346   files, the :class:`FileInput` object's new :meth:`fileno` returns the file
    1347   descriptor for the currently opened file. (Contributed by Georg Brandl.)
     1346  :func:`input` function to allow opening files in binary or :term:`universal
     1347  newlines` mode.  Another new parameter, *openhook*, lets you use a function
     1348  other than :func:`open`  to open the input files.  Once you're iterating over
     1349  the set of files, the :class:`FileInput` object's new :meth:`fileno` returns
     1350  the file descriptor for the currently opened file. (Contributed by Georg
     1351  Brandl.)
    13481352
    13491353* In the :mod:`gc` module, the new :func:`get_count` function returns a 3-tuple
     
    14601464  On FreeBSD, the :func:`os.stat` function now returns  times with nanosecond
    14611465  resolution, and the returned object now has :attr:`st_gen` and
    1462   :attr:`st_birthtime`. The :attr:`st_flags` member is also available, if the
     1466  :attr:`st_birthtime`. The :attr:`st_flags` attribute is also available, if the
    14631467  platform supports it. (Contributed by Antti Louko and  Diego Pettenò.)
    14641468
     
    15691573
    15701574  This information is also available to C extensions via the
    1571   :cfunc:`Py_GetBuildInfo` function that returns a  string of build information
     1575  :c:func:`Py_GetBuildInfo` function that returns a  string of build information
    15721576  like this: ``"trunk:45355:45356M, Apr 13 2006, 07:42:19"``.   (Contributed by
    15731577  Barry Warsaw.)
     
    16911695
    16921696Type constructors for the various C types are provided: :func:`c_int`,
    1693 :func:`c_float`, :func:`c_double`, :func:`c_char_p` (equivalent to :ctype:`char
     1697:func:`c_float`, :func:`c_double`, :func:`c_char_p` (equivalent to :c:type:`char
    16941698\*`), and so forth.  Unlike Python's types, the C versions are all mutable; you
    16951699can assign to their :attr:`value` attribute to change the wrapped value.  Python
     
    17211725interpreter lock before calling a function, because the lock must be held when
    17221726calling into the interpreter's code.   There's a :class:`py_object()` type
    1723 constructor that will create a  :ctype:`PyObject \*` pointer.  A simple usage::
     1727constructor that will create a  :c:type:`PyObject \*` pointer.  A simple usage::
    17241728
    17251729   import ctypes
     
    17661770
    17671771ElementTree represents an XML document as a tree of element nodes. The text
    1768 content of the document is stored as the :attr:`.text` and :attr:`.tail`
     1772content of the document is stored as the :attr:`text` and :attr:`tail`
    17691773attributes of  (This is one of the major differences between ElementTree and
    17701774the Document Object Model; in the DOM there are many different types of node,
     
    20882092
    20892093* The largest change to the C API came from :pep:`353`, which modifies the
    2090   interpreter to use a :ctype:`Py_ssize_t` type definition instead of
    2091   :ctype:`int`.  See the earlier section :ref:`pep-353` for a discussion of this
     2094  interpreter to use a :c:type:`Py_ssize_t` type definition instead of
     2095  :c:type:`int`.  See the earlier section :ref:`pep-353` for a discussion of this
    20922096  change.
    20932097
     
    21142118  the various AST nodes in :file:`Parser/Python.asdl`.  A Python script reads this
    21152119  file and generates a set of C structure definitions in
    2116   :file:`Include/Python-ast.h`.  The :cfunc:`PyParser_ASTFromString` and
    2117   :cfunc:`PyParser_ASTFromFile`, defined in :file:`Include/pythonrun.h`, take
     2120  :file:`Include/Python-ast.h`.  The :c:func:`PyParser_ASTFromString` and
     2121  :c:func:`PyParser_ASTFromFile`, defined in :file:`Include/pythonrun.h`, take
    21182122  Python source as input and return the root of an AST representing the contents.
    2119   This AST can then be turned into a code object by :cfunc:`PyAST_Compile`.  For
     2123  This AST can then be turned into a code object by :c:func:`PyAST_Compile`.  For
    21202124  more information, read the source code, and then ask questions on python-dev.
    21212125
     
    21392143  Note that this change means extension modules must be more careful when
    21402144  allocating memory.  Python's API has many different functions for allocating
    2141   memory that are grouped into families.  For example, :cfunc:`PyMem_Malloc`,
    2142   :cfunc:`PyMem_Realloc`, and :cfunc:`PyMem_Free` are one family that allocates
    2143   raw memory, while :cfunc:`PyObject_Malloc`, :cfunc:`PyObject_Realloc`, and
    2144   :cfunc:`PyObject_Free` are another family that's supposed to be used for
     2145  memory that are grouped into families.  For example, :c:func:`PyMem_Malloc`,
     2146  :c:func:`PyMem_Realloc`, and :c:func:`PyMem_Free` are one family that allocates
     2147  raw memory, while :c:func:`PyObject_Malloc`, :c:func:`PyObject_Realloc`, and
     2148  :c:func:`PyObject_Free` are another family that's supposed to be used for
    21452149  creating Python objects.
    21462150
    21472151  Previously these different families all reduced to the platform's
    2148   :cfunc:`malloc` and :cfunc:`free` functions.  This meant  it didn't matter if
    2149   you got things wrong and allocated memory with the :cfunc:`PyMem` function but
    2150   freed it with the :cfunc:`PyObject` function.  With 2.5's changes to obmalloc,
     2152  :c:func:`malloc` and :c:func:`free` functions.  This meant  it didn't matter if
     2153  you got things wrong and allocated memory with the :c:func:`PyMem` function but
     2154  freed it with the :c:func:`PyObject` function.  With 2.5's changes to obmalloc,
    21512155  these families now do different things and mismatches will probably result in a
    21522156  segfault.  You should carefully test your C extension modules with Python 2.5.
    21532157
    2154 * The built-in set types now have an official C API.  Call :cfunc:`PySet_New`
    2155   and :cfunc:`PyFrozenSet_New` to create a new set, :cfunc:`PySet_Add` and
    2156   :cfunc:`PySet_Discard` to add and remove elements, and :cfunc:`PySet_Contains`
    2157   and :cfunc:`PySet_Size` to examine the set's state. (Contributed by Raymond
     2158* The built-in set types now have an official C API.  Call :c:func:`PySet_New`
     2159  and :c:func:`PyFrozenSet_New` to create a new set, :c:func:`PySet_Add` and
     2160  :c:func:`PySet_Discard` to add and remove elements, and :c:func:`PySet_Contains`
     2161  and :c:func:`PySet_Size` to examine the set's state. (Contributed by Raymond
    21582162  Hettinger.)
    21592163
    21602164* C code can now obtain information about the exact revision of the Python
    2161   interpreter by calling the  :cfunc:`Py_GetBuildInfo` function that returns a
     2165  interpreter by calling the  :c:func:`Py_GetBuildInfo` function that returns a
    21622166  string of build information like this: ``"trunk:45355:45356M, Apr 13 2006,
    21632167  07:42:19"``.   (Contributed by Barry Warsaw.)
     
    21652169* Two new macros can be used to indicate C functions that are local to the
    21662170  current file so that a faster calling convention can be used.
    2167   :cfunc:`Py_LOCAL(type)` declares the function as returning a value of the
     2171  :c:func:`Py_LOCAL(type)` declares the function as returning a value of the
    21682172  specified *type* and uses a fast-calling qualifier.
    2169   :cfunc:`Py_LOCAL_INLINE(type)` does the same thing and also requests the
    2170   function be inlined.  If :cfunc:`PY_LOCAL_AGGRESSIVE` is defined before
     2173  :c:func:`Py_LOCAL_INLINE(type)` does the same thing and also requests the
     2174  function be inlined.  If :c:func:`PY_LOCAL_AGGRESSIVE` is defined before
    21712175  :file:`python.h` is included, a set of more aggressive optimizations are enabled
    21722176  for the module; you should benchmark the results to find out if these
     
    21742178  the NeedForSpeed sprint.)
    21752179
    2176 * :cfunc:`PyErr_NewException(name, base, dict)` can now accept a tuple of base
     2180* :c:func:`PyErr_NewException(name, base, dict)` can now accept a tuple of base
    21772181  classes as its *base* argument.  (Contributed by Georg Brandl.)
    21782182
    2179 * The :cfunc:`PyErr_Warn` function for issuing warnings is now deprecated in
    2180   favour of :cfunc:`PyErr_WarnEx(category, message, stacklevel)` which lets you
     2183* The :c:func:`PyErr_Warn` function for issuing warnings is now deprecated in
     2184  favour of :c:func:`PyErr_WarnEx(category, message, stacklevel)` which lets you
    21812185  specify the number of stack frames separating this function and the caller.  A
    2182   *stacklevel* of 1 is the function calling :cfunc:`PyErr_WarnEx`, 2 is the
     2186  *stacklevel* of 1 is the function calling :c:func:`PyErr_WarnEx`, 2 is the
    21832187  function above that, and so forth.  (Added by Neal Norwitz.)
    21842188
     
    21872191  Martin von Löwis, Skip Montanaro.)
    21882192
    2189 * The :cfunc:`PyRange_New` function was removed.  It was never documented, never
     2193* The :c:func:`PyRange_New` function was removed.  It was never documented, never
    21902194  used in the core code, and had dangerously lax error checking.  In the unlikely
    21912195  case that your extensions were using it, you can replace it by something like
     
    22042208
    22052209* MacOS X (10.3 and higher): dynamic loading of modules now uses the
    2206   :cfunc:`dlopen` function instead of MacOS-specific functions.
     2210  :c:func:`dlopen` function instead of MacOS-specific functions.
    22072211
    22082212* MacOS X: an :option:`--enable-universalsdk` switch was added to the
     
    22602264  checking.
    22612265
    2262 * C API: Many functions now use :ctype:`Py_ssize_t`  instead of :ctype:`int` to
     2266* C API: Many functions now use :c:type:`Py_ssize_t`  instead of :c:type:`int` to
    22632267  allow processing more data on 64-bit machines.  Extension code may need to make
    22642268  the same change to avoid warnings and to support 64-bit machines.  See the
     
    22662270
    22672271* C API:  The obmalloc changes mean that  you must be careful to not mix usage
    2268   of the :cfunc:`PyMem_\*` and :cfunc:`PyObject_\*` families of functions. Memory
    2269   allocated with  one family's :cfunc:`\*_Malloc` must be  freed with the
    2270   corresponding family's :cfunc:`\*_Free` function.
     2272  of the :c:func:`PyMem_\*` and :c:func:`PyObject_\*` families of functions. Memory
     2273  allocated with  one family's :c:func:`\*_Malloc` must be  freed with the
     2274  corresponding family's :c:func:`\*_Free` function.
    22712275
    22722276.. ======================================================================
Note: See TracChangeset for help on using the changeset viewer.