Python History-------------- This file contains the release messages for previous Python releases.As you read on you go back to the dark ages of Python's history. ====================================================================== What's New in Python 2.4 final?=============================== *Release date: 30-NOV-2004* Core and builtins----------------- - Bug 875692: Improve signal handling, especially when using threads, by forcing an early re-execution of PyEval_EvalFrame() "periodic" code when things_to_do is not cleared by Py_MakePendingCalls(). What's New in Python 2.4 (release candidate 1)============================================== *Release date: 18-NOV-2004* Core and builtins----------------- - Bug 1061968: Fixes in 2.4a3 to address thread bug 1010677 reintroduced the years-old thread shutdown race bug 225673. Numeric history lesson aside, all bugs in all three reports are fixed now. Library------- - Bug 1052242: If exceptions are raised by an atexit handler function an attempt is made to execute the remaining handlers. The last exception raised is re-raised. - ``doctest``'s new support for adding ``pdb.set_trace()`` calls to doctests was broken in a dramatic but shallow way. Fixed. - Bug 1065388: ``calendar``'s ``day_name``, ``day_abbr``, ``month_name``, and ``month_abbr`` attributes emulate sequences of locale-correct spellings of month and day names. Because the locale can change at any time, the correct spelling is recomputed whenever one of these is indexed. In the worst case, the index may be a slice object, so these recomputed every day or month name each time they were indexed. This is much slower than necessary in the usual case, when the index is just an integer. In that case, only the single spelling needed is recomputed now; and, when the index is a slice object, only the spellings needed by the slice are recomputed now. - Patch 1061679: Added ``__all__`` to pickletools.py. Build----- - Bug 1034277 / Patch 1035255: Remove compilation of core against CoreServices and CoreFoundation on OS X. Involved removing PyMac_GetAppletScriptFile() which has no known users. Thanks Bob Ippolito. C API----- - The PyRange_New() function is deprecated. What's New in Python 2.4 beta 2?================================ *Release date: 03-NOV-2004* License------- The Python Software Foundation changed the license under which Pythonis released, to remove Python version numbers. There were no otherchanges to the license. So, for example, wherever the license forPython 2.3 said "Python 2.3", the new license says "Python". Theintent is to make it possible to refer to the PSF license in a moredurable way. For example, some people say they're confused by thatthe Open Source Initiative's entry for the Python Software FoundationLicense:: http://www.opensource.org/licenses/PythonSoftFoundation.php says "Python 2.1.1" all over it, wondering whether it applies onlyto Python 2.1.1. The official name of the new license is the Python Software FoundationLicense Version 2. Core and builtins----------------- - Bug #1055820 Cyclic garbage collection was not protecting against that calling a live weakref to a piece of cyclic trash could resurrect an insane mutation of the trash if any Python code ran during gc (via running a dead object's __del__ method, running another callback on a weakref to a dead object, or via any Python code run in any other thread that managed to obtain the GIL while a __del__ or callback was running in the thread doing gc). The most likely symptom was "impossible" ``AttributeError`` exceptions, appearing seemingly at random, on weakly referenced objects. The cure was to clear all weakrefs to unreachable objects before allowing any callbacks to run. - Bug #1054139 _PyString_Resize() now invalidates its cached hash value. Extension Modules----------------- - Bug #1048870: the compiler now generates distinct code objects for functions with identical bodies. This was producing confusing traceback messages which pointed to the function where the code object was first defined rather than the function being executed. Library------- - Patch #1056967 changes the semantics of Template.safe_substitute() so that no ValueError is raised on an 'invalid' match group. Now the delimiter is returned. - Bug #1052503 pdb.runcall() was not passing along keyword arguments. - Bug #902037: XML.sax.saxutils.prepare_input_source() now combines relative paths with a base path before checking os.path.isfile(). - The whichdb module can now be run from the command line. - Bug #1045381: time.strptime() can now infer the date using %U or %W (week of the year) when the day of the week and year are also specified. - Bug #1048816: fix bug in Ctrl-K at start of line in curses.textpad.Textbox - Bug #1017553: fix bug in tarfile.filemode() - Patch #737473: fix bug that old source code is shown in tracebacks even if the source code is updated and reloaded. Build----- - Patch #1044395: --enable-shared is allowed in FreeBSD also. What's New in Python 2.4 beta 1?================================ *Release date: 15-OCT-2004* Core and builtins----------------- - Patch #975056: Restartable signals were not correctly disabled on BSD systems. Consistently use PyOS_setsig() instead of signal(). - The internal portable implementation of thread-local storage (TLS), used by the ``PyGILState_Ensure()``/``PyGILState_Release()`` API, was not thread-correct. This could lead to a variety of problems, up to and including segfaults. See bug 1041645 for an example. - Added a command line option, -m module, which searches sys.path for the module and then runs it. (Contributed by Nick Coghlan.) - The bytecode optimizer now folds tuples of constants into a single constant. - SF bug #513866: Float/long comparison anomaly. Prior to 2.4b1, when an integer was compared to a float, the integer was coerced to a float. That could yield spurious overflow errors (if the integer was very large), and to anomalies such as ``long(1e200)+1 == 1e200 == long(1e200)-1``. Coercion to float is no longer performed, and cases like ``long(1e200)-1 < 1e200``, ``long(1e200)+1 > 1e200`` and ``(1 << 20000) > 1e200`` are computed correctly now. Extension modules----------------- - ``collections.deque`` objects didn't play quite right with garbage collection, which could lead to a segfault in a release build, or an assert failure in a debug build. Also, added overflow checks, better detection of mutation during iteration, and shielded deque comparisons from unusual subclass overrides of the __iter__() method. Library------- - Patch 1046644: distutils build_ext grew two new options - --swig for specifying the swig executable to use, and --swig-opts to specify options to pass to swig. --swig-opts="-c++" is the new way to spell --swig-cpp. - Patch 983206: distutils now obeys environment variable LDSHARED, if it is set. - Added Peter Astrand's subprocess.py module. See PEP 324 for details. - time.strptime() now properly escapes timezones and all other locale-specific strings for regex-specific symbols. Was breaking under Japanese Windows when the timezone was specified as "Tokyo (standard time)". Closes bug #1039270. - Updates for the email package: + email.Utils.formatdate() grew a 'usegmt' argument for HTTP support. + All deprecated APIs that in email 2.x issued warnings have been removed: _encoder argument to the MIMEText constructor, Message.add_payload(), Utils.dump_address_pair(), Utils.decode(), Utils.encode() + New deprecations: Generator.__call__(), Message.get_type(), Message.get_main_type(), Message.get_subtype(), the 'strict' argument to the Parser constructor. These will be removed in email 3.1. + Support for Python earlier than 2.3 has been removed (see PEP 291). + All defect classes have been renamed to end in 'Defect'. + Some FeedParser fixes; also a MultipartInvariantViolationDefect will be added to messages that claim to be multipart but really aren't. + Updates to documentation. - re's findall() and finditer() functions now take an optional flags argument just like the compile(), search(), and match() functions. Also, documented the previously existing start and stop parameters for the findall() and finditer() methods of regular expression objects. - rfc822 Messages now support iterating over the headers. - The (undocumented) tarfile.Tarfile.membernames has been removed; applications should use the getmember function. - httplib now offers symbolic constants for the HTTP status codes. - SF bug #1028306: Trying to compare a ``datetime.date`` to a ``datetime.datetime`` mistakenly compared only the year, month and day. Now it acts like a mixed-type comparison: ``False`` for ``==``, ``True`` for ``!=``, and raises ``TypeError`` for other comparison operators. Because datetime is a subclass of date, comparing only the base class (date) members can still be done, if that's desired, by forcing using of the approprate date method; e.g., ``a_date.__eq__(a_datetime)`` is true if and only if the year, month and day members of ``a_date`` and ``a_datetime`` are equal. - bdist_rpm now supports command line options --force-arch, {pre,post}-install, {pre,post}-uninstall, and {prep,build,install,clean,verify}-script. - SF patch #998993: The UTF-8 and the UTF-16 stateful decoders now support decoding incomplete input (when the input stream is temporarily exhausted). ``codecs.StreamReader`` now implements buffering, which enables proper readline support for the UTF-16 decoders. ``codecs.StreamReader.read()`` has a new argument ``chars`` which specifies the number of characters to return. ``codecs.StreamReader.readline()`` and ``codecs.StreamReader.readlines()`` have a new argument ``keepends``. Trailing "\n"s will be stripped from the lines if ``keepends`` is false. - The documentation for doctest is greatly expanded, and now covers all the new public features (of which there are many). - ``doctest.master`` was put back in, and ``doctest.testmod()`` once again updates it. This isn't good, because every ``testmod()`` call contributes to bloating the "hidden" state of ``doctest.master``, but some old code apparently relies on it. For now, all we can do is encourage people to stitch doctests together via doctest's unittest integration features instead. - httplib now handles ipv6 address/port pairs. - SF bug #1017864: ConfigParser now correctly handles default keys, processing them with ``ConfigParser.optionxform`` when supplied, consistent with the handling of config file entries and runtime-set options. - SF bug #997050: Document, test, & check for non-string values in ConfigParser. Moved the new string-only restriction added in rev. 1.65 to the SafeConfigParser class, leaving existing ConfigParser & RawConfigParser behavior alone, and documented the conditions under which non-string values work. Build----- - Building on darwin now includes /opt/local/include and /opt/local/lib for building extension modules. This is so as to include software installed as a DarwinPorts port <http://darwinports.opendarwin.org/> - pyport.h now defines a Py_IS_NAN macro. It works as-is when the platform C computes true for ``x != x`` if and only if X is a NaN. Other platforms can override the default definition with a platform- specific spelling in that platform's pyconfig.h. You can also override pyport.h's default Py_IS_INFINITY definition now. C API----- - SF patch 1044089: New function ``PyEval_ThreadsInitialized()`` returns non-zero if PyEval_InitThreads() has been called. - The undocumented and unused extern int ``_PyThread_Started`` was removed. - The C API calls ``PyInterpreterState_New()`` and ``PyThreadState_New()`` are two of the very few advertised as being safe to call without holding the GIL. However, this wasn't true in a debug build, as bug 1041645 demonstrated. In a debug build, Python redirects the ``PyMem`` family of calls to Python's small-object allocator, to get the benefit of its extra debugging capabilities. But Python's small-object allocator isn't threadsafe, relying on the GIL to avoid the expense of doing its own locking. ``PyInterpreterState_New()`` and ``PyThreadState_New()`` call the platform ``malloc()`` directly now, regardless of build type. - PyLong_AsUnsignedLong[Mask] now support int objects as well. - SF patch #998993: ``PyUnicode_DecodeUTF8Stateful`` and ``PyUnicode_DecodeUTF16Stateful`` have been added, which implement stateful decoding. Tests----- - test__locale ported to unittest Mac--- - ``plistlib`` now supports non-dict root objects. There is also a new interface for reading and writing plist files: ``readPlist(pathOrFile)`` and ``writePlist(rootObject, pathOrFile)`` Tools/Demos----------- - The text file comparison scripts ``ndiff.py`` and ``diff.py`` now read the input files in universal-newline mode. This spares them from consuming a great deal of time to deduce the useless result that, e.g., a file with Windows line ends and a file with Linux line ends have no lines in common. What's New in Python 2.4 alpha 3?================================= *Release date: 02-SEP-2004* Core and builtins----------------- - SF patch #1007189: ``from ... import ...`` statements now allow the name list to be surrounded by parentheses. - Some speedups for long arithmetic, thanks to Trevor Perrin. Gradeschool multiplication was sped a little by optimizing the C code. Gradeschool squaring was sped by about a factor of 2, by exploiting that about half the digit products are duplicates in a square. Because exponentiation uses squaring often, this also speeds long power. For example, the time to compute 17**1000000 dropped from about 14 seconds to 9 on my box due to this much. The cutoff for Karatsuba multiplication was raised, since gradeschool multiplication got quicker, and the cutoff was aggressively small regardless. The exponentiation algorithm was switched from right-to-left to left-to-right, which is more efficient for small bases. In addition, if the exponent is large, the algorithm now does 5 bits (instead of 1 bit) at a time. That cut the time to compute 17**1000000 on my box in half again, down to about 4.5 seconds. - OverflowWarning is no longer generated. PEP 237 scheduled this to occur in Python 2.3, but since OverflowWarning was disabled by default, nobody realized it was still being generated. On the chance that user code is still using them, the Python builtin OverflowWarning, and corresponding C API PyExc_OverflowWarning, will exist until Python 2.5. - Py_InitializeEx has been added. - Fix the order of application of decorators. The proper order is bottom-up; the first decorator listed is the last one called. - SF patch #1005778. Fix a seg fault if the list size changed while calling list.index(). This could happen if a rich comparison function modified the list. - The ``func_name`` (a.k.a. ``__name__``) attribute of user-defined functions is now writable. - code_new (a.k.a new.code()) now checks its arguments sufficiently carefully that passing them on to PyCode_New() won't trigger calls to Py_FatalError() or PyErr_BadInternalCall(). It is still the case that the returned code object might be entirely insane. - Subclasses of string can no longer be interned. The semantics of interning were not clear here -- a subclass could be mutable, for example -- and had bugs. Explicitly interning a subclass of string via intern() will raise a TypeError. Internal operations that attempt to intern a string subclass will have no effect. - Bug 1003935: xrange() could report bogus OverflowErrors. Documented what xrange() intends, and repaired tests accordingly. Extension modules----------------- - difflib now supports HTML side-by-side diff. - os.urandom has been added for systems that support sources of random data. - Patch 1012740: truncate() on a writeable cStringIO now resets the position to the end of the stream. This is consistent with the original StringIO module and avoids inadvertently resurrecting data that was supposed to have been truncated away. - Added socket.socketpair(). - Added CurrentByteIndex, CurrentColumnNumber, CurrentLineNumber members to xml.parsers.expat.XMLParser object. - The mpz, rotor, and xreadlines modules, all deprecated in earlier versions of Python, have now been removed. Library------- - Patch #934356: if a module defines __all__, believe that rather than using heuristics for filtering out imported names. - Patch #941486: added os.path.lexists(), which returns True for broken symlinks, unlike os.path.exists(). - the random module now uses os.urandom() for seeding if it is available. Added a new generator based on os.urandom(). - difflib and diff.py can now generate HTML. - bdist_rpm now includes version and release in the BuildRoot, and replaces - by ``_`` in version and release. - distutils build/build_scripts now has an -e option to specify the path to the Python interpreter for installed scripts. - PEP 292 classes Template and SafeTemplate are added to the string module. - tarfile now generates GNU tar files by default. - HTTPResponse has now a getheaders method. - Patch #1006219: let inspect.getsource handle '@' decorators. Thanks Simon Percivall. - logging.handlers.SMTPHandler.date_time has been removed; the class now uses email.Utils.formatdate to generate the time stamp. - A new function tkFont.nametofont was added to return an existing font. The Font class constructor now has an additional exists argument which, if True, requests to return/configure an existing font, rather than creating a new one. - Updated the decimal package's min() and max() methods to match the latest revision of the General Decimal Arithmetic Specification. Quiet NaNs are ignored and equal values are sorted based on sign and exponent. - The decimal package's Context.copy() method now returns deep copies. - Deprecated sys.exitfunc in favor of the atexit module. The sys.exitfunc attribute will be kept around for backwards compatibility and atexit will just become the one preferred way to do it. - patch #675551: Add get_history_item and replace_history_item functions to the readline module. - bug #989672: pdb.doc and the help messages for the help_d and help_u methods of the pdb.Pdb class gives have been corrected. d(own) goes to a newer frame, u(p) to an older frame, not the other way around. - bug #990669: os.path.realpath() will resolve symlinks before normalizing the path, as normalizing the path may alter the meaning of the path if it contains symlinks. - bug #851123: shutil.copyfile will raise an exception when trying to copy a file onto a link to itself. Thanks Gregory Ball. - bug #570300: Fix inspect to resolve file locations using os.path.realpath() so as to properly list all functions in a module when the module itself is reached through a symlink. Thanks Johannes Gijsbers. - doctest refactoring continued. See the docs for details. As part of this effort, some old and little- (never?) used features are now deprecated: the Tester class, the module is_private() function, and the isprivate argument to testmod(). The Tester class supplied a feeble "by hand" way to combine multiple doctests, if you knew exactly what you were doing. The newer doctest features for unittest integration already did a better job of that, are stronger now than ever, and the new DocTestRunner class is a saner foundation if you want to do it by hand. The "private name" filtering gimmick was a mistake from the start, and testmod() changed long ago to ignore it by default. If you want to filter out tests, the new DocTestFinder class can be used to return a list of all doctests, and you can filter that list by any computable criteria before passing it to a DocTestRunner instance. - Bug #891637, patch #1005466: fix inspect.getargs() crash on def foo((bar)). Lines 1–500 of 15303. Load more
Python History -------------- This file contains the release messages for previous Python releases. As you read on you go back to the dark ages of Python's history. ====================================================================== What's New in Python 2.4 final? =============================== *Release date: 30-NOV-2004* Core and builtins ----------------- - Bug 875692: Improve signal handling, especially when using threads, by forcing an early re-execution of PyEval_EvalFrame() "periodic" code when things_to_do is not cleared by Py_MakePendingCalls(). What's New in Python 2.4 (release candidate 1) ============================================== *Release date: 18-NOV-2004* Core and builtins ----------------- - Bug 1061968: Fixes in 2.4a3 to address thread bug 1010677 reintroduced the years-old thread shutdown race bug 225673. Numeric history lesson aside, all bugs in all three reports are fixed now. Library ------- - Bug 1052242: If exceptions are raised by an atexit handler function an attempt is made to execute the remaining handlers. The last exception raised is re-raised. - ``doctest``'s new support for adding ``pdb.set_trace()`` calls to doctests was broken in a dramatic but shallow way. Fixed. - Bug 1065388: ``calendar``'s ``day_name``, ``day_abbr``, ``month_name``, and ``month_abbr`` attributes emulate sequences of locale-correct spellings of month and day names. Because the locale can change at any time, the correct spelling is recomputed whenever one of these is indexed. In the worst case, the index may be a slice object, so these recomputed every day or month name each time they were indexed. This is much slower than necessary in the usual case, when the index is just an integer. In that case, only the single spelling needed is recomputed now; and, when the index is a slice object, only the spellings needed by the slice are recomputed now. - Patch 1061679: Added ``__all__`` to pickletools.py. Build ----- - Bug 1034277 / Patch 1035255: Remove compilation of core against CoreServices and CoreFoundation on OS X. Involved removing PyMac_GetAppletScriptFile() which has no known users. Thanks Bob Ippolito. C API ----- - The PyRange_New() function is deprecated. What's New in Python 2.4 beta 2? ================================ *Release date: 03-NOV-2004* License ------- The Python Software Foundation changed the license under which Python is released, to remove Python version numbers. There were no other changes to the license. So, for example, wherever the license for Python 2.3 said "Python 2.3", the new license says "Python". The intent is to make it possible to refer to the PSF license in a more durable way. For example, some people say they're confused by that the Open Source Initiative's entry for the Python Software Foundation License:: http://www.opensource.org/licenses/PythonSoftFoundation.php says "Python 2.1.1" all over it, wondering whether it applies only to Python 2.1.1. The official name of the new license is the Python Software Foundation License Version 2. Core and builtins ----------------- - Bug #1055820 Cyclic garbage collection was not protecting against that calling a live weakref to a piece of cyclic trash could resurrect an insane mutation of the trash if any Python code ran during gc (via running a dead object's __del__ method, running another callback on a weakref to a dead object, or via any Python code run in any other thread that managed to obtain the GIL while a __del__ or callback was running in the thread doing gc). The most likely symptom was "impossible" ``AttributeError`` exceptions, appearing seemingly at random, on weakly referenced objects. The cure was to clear all weakrefs to unreachable objects before allowing any callbacks to run. - Bug #1054139 _PyString_Resize() now invalidates its cached hash value. Extension Modules ----------------- - Bug #1048870: the compiler now generates distinct code objects for functions with identical bodies. This was producing confusing traceback messages which pointed to the function where the code object was first defined rather than the function being executed. Library ------- - Patch #1056967 changes the semantics of Template.safe_substitute() so that no ValueError is raised on an 'invalid' match group. Now the delimiter is returned. - Bug #1052503 pdb.runcall() was not passing along keyword arguments. - Bug #902037: XML.sax.saxutils.prepare_input_source() now combines relative paths with a base path before checking os.path.isfile(). - The whichdb module can now be run from the command line. - Bug #1045381: time.strptime() can now infer the date using %U or %W (week of the year) when the day of the week and year are also specified. - Bug #1048816: fix bug in Ctrl-K at start of line in curses.textpad.Textbox - Bug #1017553: fix bug in tarfile.filemode() - Patch #737473: fix bug that old source code is shown in tracebacks even if the source code is updated and reloaded. Build ----- - Patch #1044395: --enable-shared is allowed in FreeBSD also. What's New in Python 2.4 beta 1? ================================ *Release date: 15-OCT-2004* Core and builtins ----------------- - Patch #975056: Restartable signals were not correctly disabled on BSD systems. Consistently use PyOS_setsig() instead of signal(). - The internal portable implementation of thread-local storage (TLS), used by the ``PyGILState_Ensure()``/``PyGILState_Release()`` API, was not thread-correct. This could lead to a variety of problems, up to and including segfaults. See bug 1041645 for an example. - Added a command line option, -m module, which searches sys.path for the module and then runs it. (Contributed by Nick Coghlan.) - The bytecode optimizer now folds tuples of constants into a single constant. - SF bug #513866: Float/long comparison anomaly. Prior to 2.4b1, when an integer was compared to a float, the integer was coerced to a float. That could yield spurious overflow errors (if the integer was very large), and to anomalies such as ``long(1e200)+1 == 1e200 == long(1e200)-1``. Coercion to float is no longer performed, and cases like ``long(1e200)-1 < 1e200``, ``long(1e200)+1 > 1e200`` and ``(1 << 20000) > 1e200`` are computed correctly now. Extension modules ----------------- - ``collections.deque`` objects didn't play quite right with garbage collection, which could lead to a segfault in a release build, or an assert failure in a debug build. Also, added overflow checks, better detection of mutation during iteration, and shielded deque comparisons from unusual subclass overrides of the __iter__() method. Library ------- - Patch 1046644: distutils build_ext grew two new options - --swig for specifying the swig executable to use, and --swig-opts to specify options to pass to swig. --swig-opts="-c++" is the new way to spell --swig-cpp. - Patch 983206: distutils now obeys environment variable LDSHARED, if it is set. - Added Peter Astrand's subprocess.py module. See PEP 324 for details. - time.strptime() now properly escapes timezones and all other locale-specific strings for regex-specific symbols. Was breaking under Japanese Windows when the timezone was specified as "Tokyo (standard time)". Closes bug #1039270. - Updates for the email package: + email.Utils.formatdate() grew a 'usegmt' argument for HTTP support. + All deprecated APIs that in email 2.x issued warnings have been removed: _encoder argument to the MIMEText constructor, Message.add_payload(), Utils.dump_address_pair(), Utils.decode(), Utils.encode() + New deprecations: Generator.__call__(), Message.get_type(), Message.get_main_type(), Message.get_subtype(), the 'strict' argument to the Parser constructor. These will be removed in email 3.1. + Support for Python earlier than 2.3 has been removed (see PEP 291). + All defect classes have been renamed to end in 'Defect'. + Some FeedParser fixes; also a MultipartInvariantViolationDefect will be added to messages that claim to be multipart but really aren't. + Updates to documentation. - re's findall() and finditer() functions now take an optional flags argument just like the compile(), search(), and match() functions. Also, documented the previously existing start and stop parameters for the findall() and finditer() methods of regular expression objects. - rfc822 Messages now support iterating over the headers. - The (undocumented) tarfile.Tarfile.membernames has been removed; applications should use the getmember function. - httplib now offers symbolic constants for the HTTP status codes. - SF bug #1028306: Trying to compare a ``datetime.date`` to a ``datetime.datetime`` mistakenly compared only the year, month and day. Now it acts like a mixed-type comparison: ``False`` for ``==``, ``True`` for ``!=``, and raises ``TypeError`` for other comparison operators. Because datetime is a subclass of date, comparing only the base class (date) members can still be done, if that's desired, by forcing using of the approprate date method; e.g., ``a_date.__eq__(a_datetime)`` is true if and only if the year, month and day members of ``a_date`` and ``a_datetime`` are equal. - bdist_rpm now supports command line options --force-arch, {pre,post}-install, {pre,post}-uninstall, and {prep,build,install,clean,verify}-script. - SF patch #998993: The UTF-8 and the UTF-16 stateful decoders now support decoding incomplete input (when the input stream is temporarily exhausted). ``codecs.StreamReader`` now implements buffering, which enables proper readline support for the UTF-16 decoders. ``codecs.StreamReader.read()`` has a new argument ``chars`` which specifies the number of characters to return. ``codecs.StreamReader.readline()`` and ``codecs.StreamReader.readlines()`` have a new argument ``keepends``. Trailing "\n"s will be stripped from the lines if ``keepends`` is false. - The documentation for doctest is greatly expanded, and now covers all the new public features (of which there are many). - ``doctest.master`` was put back in, and ``doctest.testmod()`` once again updates it. This isn't good, because every ``testmod()`` call contributes to bloating the "hidden" state of ``doctest.master``, but some old code apparently relies on it. For now, all we can do is encourage people to stitch doctests together via doctest's unittest integration features instead. - httplib now handles ipv6 address/port pairs. - SF bug #1017864: ConfigParser now correctly handles default keys, processing them with ``ConfigParser.optionxform`` when supplied, consistent with the handling of config file entries and runtime-set options. - SF bug #997050: Document, test, & check for non-string values in ConfigParser. Moved the new string-only restriction added in rev. 1.65 to the SafeConfigParser class, leaving existing ConfigParser & RawConfigParser behavior alone, and documented the conditions under which non-string values work. Build ----- - Building on darwin now includes /opt/local/include and /opt/local/lib for building extension modules. This is so as to include software installed as a DarwinPorts port <http://darwinports.opendarwin.org/> - pyport.h now defines a Py_IS_NAN macro. It works as-is when the platform C computes true for ``x != x`` if and only if X is a NaN. Other platforms can override the default definition with a platform- specific spelling in that platform's pyconfig.h. You can also override pyport.h's default Py_IS_INFINITY definition now. C API ----- - SF patch 1044089: New function ``PyEval_ThreadsInitialized()`` returns non-zero if PyEval_InitThreads() has been called. - The undocumented and unused extern int ``_PyThread_Started`` was removed. - The C API calls ``PyInterpreterState_New()`` and ``PyThreadState_New()`` are two of the very few advertised as being safe to call without holding the GIL. However, this wasn't true in a debug build, as bug 1041645 demonstrated. In a debug build, Python redirects the ``PyMem`` family of calls to Python's small-object allocator, to get the benefit of its extra debugging capabilities. But Python's small-object allocator isn't threadsafe, relying on the GIL to avoid the expense of doing its own locking. ``PyInterpreterState_New()`` and ``PyThreadState_New()`` call the platform ``malloc()`` directly now, regardless of build type. - PyLong_AsUnsignedLong[Mask] now support int objects as well. - SF patch #998993: ``PyUnicode_DecodeUTF8Stateful`` and ``PyUnicode_DecodeUTF16Stateful`` have been added, which implement stateful decoding. Tests ----- - test__locale ported to unittest Mac --- - ``plistlib`` now supports non-dict root objects. There is also a new interface for reading and writing plist files: ``readPlist(pathOrFile)`` and ``writePlist(rootObject, pathOrFile)`` Tools/Demos ----------- - The text file comparison scripts ``ndiff.py`` and ``diff.py`` now read the input files in universal-newline mode. This spares them from consuming a great deal of time to deduce the useless result that, e.g., a file with Windows line ends and a file with Linux line ends have no lines in common. What's New in Python 2.4 alpha 3? ================================= *Release date: 02-SEP-2004* Core and builtins ----------------- - SF patch #1007189: ``from ... import ...`` statements now allow the name list to be surrounded by parentheses. - Some speedups for long arithmetic, thanks to Trevor Perrin. Gradeschool multiplication was sped a little by optimizing the C code. Gradeschool squaring was sped by about a factor of 2, by exploiting that about half the digit products are duplicates in a square. Because exponentiation uses squaring often, this also speeds long power. For example, the time to compute 17**1000000 dropped from about 14 seconds to 9 on my box due to this much. The cutoff for Karatsuba multiplication was raised, since gradeschool multiplication got quicker, and the cutoff was aggressively small regardless. The exponentiation algorithm was switched from right-to-left to left-to-right, which is more efficient for small bases. In addition, if the exponent is large, the algorithm now does 5 bits (instead of 1 bit) at a time. That cut the time to compute 17**1000000 on my box in half again, down to about 4.5 seconds. - OverflowWarning is no longer generated. PEP 237 scheduled this to occur in Python 2.3, but since OverflowWarning was disabled by default, nobody realized it was still being generated. On the chance that user code is still using them, the Python builtin OverflowWarning, and corresponding C API PyExc_OverflowWarning, will exist until Python 2.5. - Py_InitializeEx has been added. - Fix the order of application of decorators. The proper order is bottom-up; the first decorator listed is the last one called. - SF patch #1005778. Fix a seg fault if the list size changed while calling list.index(). This could happen if a rich comparison function modified the list. - The ``func_name`` (a.k.a. ``__name__``) attribute of user-defined functions is now writable. - code_new (a.k.a new.code()) now checks its arguments sufficiently carefully that passing them on to PyCode_New() won't trigger calls to Py_FatalError() or PyErr_BadInternalCall(). It is still the case that the returned code object might be entirely insane. - Subclasses of string can no longer be interned. The semantics of interning were not clear here -- a subclass could be mutable, for example -- and had bugs. Explicitly interning a subclass of string via intern() will raise a TypeError. Internal operations that attempt to intern a string subclass will have no effect. - Bug 1003935: xrange() could report bogus OverflowErrors. Documented what xrange() intends, and repaired tests accordingly. Extension modules ----------------- - difflib now supports HTML side-by-side diff. - os.urandom has been added for systems that support sources of random data. - Patch 1012740: truncate() on a writeable cStringIO now resets the position to the end of the stream. This is consistent with the original StringIO module and avoids inadvertently resurrecting data that was supposed to have been truncated away. - Added socket.socketpair(). - Added CurrentByteIndex, CurrentColumnNumber, CurrentLineNumber members to xml.parsers.expat.XMLParser object. - The mpz, rotor, and xreadlines modules, all deprecated in earlier versions of Python, have now been removed. Library ------- - Patch #934356: if a module defines __all__, believe that rather than using heuristics for filtering out imported names. - Patch #941486: added os.path.lexists(), which returns True for broken symlinks, unlike os.path.exists(). - the random module now uses os.urandom() for seeding if it is available. Added a new generator based on os.urandom(). - difflib and diff.py can now generate HTML. - bdist_rpm now includes version and release in the BuildRoot, and replaces - by ``_`` in version and release. - distutils build/build_scripts now has an -e option to specify the path to the Python interpreter for installed scripts. - PEP 292 classes Template and SafeTemplate are added to the string module. - tarfile now generates GNU tar files by default. - HTTPResponse has now a getheaders method. - Patch #1006219: let inspect.getsource handle '@' decorators. Thanks Simon Percivall. - logging.handlers.SMTPHandler.date_time has been removed; the class now uses email.Utils.formatdate to generate the time stamp. - A new function tkFont.nametofont was added to return an existing font. The Font class constructor now has an additional exists argument which, if True, requests to return/configure an existing font, rather than creating a new one. - Updated the decimal package's min() and max() methods to match the latest revision of the General Decimal Arithmetic Specification. Quiet NaNs are ignored and equal values are sorted based on sign and exponent. - The decimal package's Context.copy() method now returns deep copies. - Deprecated sys.exitfunc in favor of the atexit module. The sys.exitfunc attribute will be kept around for backwards compatibility and atexit will just become the one preferred way to do it. - patch #675551: Add get_history_item and replace_history_item functions to the readline module. - bug #989672: pdb.doc and the help messages for the help_d and help_u methods of the pdb.Pdb class gives have been corrected. d(own) goes to a newer frame, u(p) to an older frame, not the other way around. - bug #990669: os.path.realpath() will resolve symlinks before normalizing the path, as normalizing the path may alter the meaning of the path if it contains symlinks. - bug #851123: shutil.copyfile will raise an exception when trying to copy a file onto a link to itself. Thanks Gregory Ball. - bug #570300: Fix inspect to resolve file locations using os.path.realpath() so as to properly list all functions in a module when the module itself is reached through a symlink. Thanks Johannes Gijsbers. - doctest refactoring continued. See the docs for details. As part of this effort, some old and little- (never?) used features are now deprecated: the Tester class, the module is_private() function, and the isprivate argument to testmod(). The Tester class supplied a feeble "by hand" way to combine multiple doctests, if you knew exactly what you were doing. The newer doctest features for unittest integration already did a better job of that, are stronger now than ever, and the new DocTestRunner class is a saner foundation if you want to do it by hand. The "private name" filtering gimmick was a mistake from the start, and testmod() changed long ago to ignore it by default. If you want to filter out tests, the new DocTestFinder class can be used to return a list of all doctests, and you can filter that list by any computable criteria before passing it to a DocTestRunner instance. - Bug #891637, patch #1005466: fix inspect.getargs() crash on def foo((bar)).