Académique Documents
Professionnel Documents
Culture Documents
Python News
+++++++++++
(editors: check NEWS.help for information about editing NEWS using ReST.)
- Partially revert the fix for #1074011; don't try to fflush stdin anymore.
Library
-------
- 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"
``AttributeEror`` 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.
Extension modules
-----------------
Library
-------
- copy.py fixed to first lookup __copy__ from the instance being copied,
rather than only looking at the type - this was broken in 2.3.
- Bug #1045381: strptime() now uses %U and %W for date calculations if the year
and day of the week are also specified.
- Bug #1013882: Flush bz2 data even if nothing had been written so far.
- Bug #930024: posixpath.realpath() now detects loops from symlinks and returns
the longest path before the loop begins.
- Bug #980327/Patch #988607: ntpath now compresses extra slashes between the
drive letter and the rest of the path properly. Also removed ambiguity from
UNC paths. Thanks Paul Moore.
- Bug #679953: zipfile can now handle file sizes over 2 GB. Previously the
compressed and uncompressed file sizes were being stored as signed longs
instead of unsigned as the ZIP spec specifies.
- Bug #982215: The Back and Next buttons in bdist_wininst installers are now
disabled during file copy operations.
- Patch #975885: Print file name in err msg in quiet mode of compileall.py.
Macintosh
---------
Build
-----
Library
-------
- Brought platform.py in line with the 2.4 version, fixing support for
newer Windows versions and a cache issue.
- Bug #700055: .pth files can now have any type of line endings.
Windows
-------
Build
-----
Library
-------
Library
-------
Build
-----
- Bug #934635: Fixed a bug where the configure script couldn't detect
getaddrinfo() properly if the KAME stack had SCTP support.
Tools/Demos
-----------
Extension modules
-----------------
- The documentation for bsddb now warns strongly about using the legacy
API in multi-threaded applications.
Build
-----
- A bug in the autoconf machinery meant that os.fsync was never available.
Mac
---
Extension modules
-----------------
Library
-------
- The bsddb module and dbhash module now support the iterator and
mapping protocols.
- The csv module's DictReader and DictWriter classes now accept keyword
arguments. This was an omission in the initial implementation.
- Bug #797650: textwrap.py now avoids an infinite loop when one of the
indent arguments is set longer than the total width.
- The email package handles some RFC 2231 parameters with missing
CHARSET fields better. It also includes a patch to parameter
parsing when semicolons appear inside quotes.
- sets.py now runs under Py2.2. In addition, the argument restrictions
for most set methods (but not the operators) have been relaxed to
allow any iterable.
IDLE
----
- Bug #774680: IDLE now does not fail to save the file anymore
if the Tk buffer is not a Unicode string, yet eol_convention is.
- Bug #782510: The idna codec would fail to support names with a
trailing full-stop.
Tools/Demos
-----------
- Pynche was fixed to not crash when there is no ~/.pynche file and no
-d option was given.
- texcheck.py now checks for double word errors and erroneous spacing markup.
Build
-----
Windows
-------
- The _winreg module could segfault when reading very large registry
values, due to unchecked alloca() calls (SF bug 851056). The fix is
uses either PyMem_Malloc(n) or PyString_FromStringAndSize(NULL, n),
as appropriate, followed by a size check.
IDLE
----
- Bug 778400: IDLE hangs when selecting "Edit with IDLE" from explorer.
This was unique to Windows, and was fixed by adding an -n switch to
the command the Windows installer creates to execute "Edit with IDLE"
context-menu actions.
Extension modules
-----------------
IDLE
----
- Calltips patches.
Build
-----
Windows
-------
Mac
---
- Scripts runs with pythonw no longer had full window manager access.
- Several bugs in the symbol table phase of the compiler have been
fixed. Errors could be lost and compilation could fail without
reporting an error. SF patch 763201.
Extension modules
-----------------
- SSL no longer crashes the interpreter when the remote side disconnects.
- On Unix the mmap module can again be used to map device files.
- The print slot of weakref proxy objects was removed, because it was
not consistent with the object's repr slot.
- The mmap module only checks file size for regular files, not
character or block devices. SF patch 708374.
Library
-------
- There were several fixes to the way dumbdbms are closed. It's vital
that a dumbdbm database be closed properly, else the on-disk data
and directory files can be left in mutually inconsistent states.
dumbdbm.py's _Database.__del__() method attempted to close the
database properly, but a shutdown race in _Database._commit() could
prevent this from working, so that a program trusting __del__() to
get the on-disk files in synch could be badly surprised. The race
has been repaired. A sync() method was also added so that shelve
can guarantee data is written to disk.
The close() method can now be called more than once without complaint.
- SF patch 766650: The whichdb module was fixed to recognize dbm files
generated by gdbm on OS/2 EMX.
- SF bugs 763047 and 763052: fixes bug of timezone value being left as
-1 when ``time.tzname[0] == time.tzname[1] and not time.daylight``
is true when it should only when time.daylight is true.
Tools/Demos
-----------
- The trace.py script has been removed. It is now in the standard library.
Build
-----
C API
-----
Windows
-------
is raised now.
Mac
---
- pythonw did not allow user interaction in 2.3rc1, this has been fixed.
- Python is now compiled with -mno-fused-madd, making all tests pass
on Panther.
- SF bug 734869: Fixed a compiler bug that caused a fatal error when
compiling a list comprehension that contained another list comprehension
embedded in a lambda expression.
- The encoding attribute has been added for file objects, and set to
the terminal encoding on Unix and Windows.
Extension modules
-----------------
- The datetime module classes datetime, time, and timedelta are now
properly subclassable.
Library
-------
- Some happy doctest extensions from Jim Fulton have been added to
doctest.py. These are already being used in Zope3. The two
primary ones:
- The cgitb module has been extended to support plain text display (SF patch
569574).
- More fixes to urllib (SF 549151): (a) When redirecting, always use
GET. This is common practice and more-or-less sanctioned by the
HTTP standard. (b) Add a handler for 307 redirection, which becomes
an error for POST, but a regular redirect for GET and HEAD
- Fixed socket speed loss caused by use of the _socketobject wrapper class
in socket.py.
Tools/Demos
-----------
Build
-----
C API
-----
New platforms
-------------
Tests
-----
- The Windows installer ships with Tcl/Tk 8.4.3 (upgraded from 8.4.1).
Mac
---
- New builtin 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).
- range() now works even if the arguments are longs with magnitude
larger than sys.maxint, as long as the total length of the sequence
fits. E.g., range(2**100, 2**101, 2**100) is the following list:
[1267650600228229401496703205376L]. (SF patch #707427.)
- Fixed SF bug #663074. The codec system was using global static
variables to store internal data. As a result, any attempts to use the
unicode system with multiple active interpreters, or successive
interpreter executions, would fail.
Extension modules
-----------------
- The socket module now provides the functions inet_pton and inet_ntop
for converting between string and packed representation of IP
addresses. There is also a new module variable, has_ipv6, which is
True iff the current Python has IPv6 support. See SF patch #658327.
- The socket module now always uses the _socketobject wrapper class, even on
platforms which have dup(2). The makefile() method is built directly
on top of the socket without duplicating the file descriptor, allowing
timeouts to work properly.
Library
-------
- pdb has a new command, "debug", which lets you step through
arbitrary code from the debugger's (pdb) prompt.
- The urllib module now offers support for the iterator protocol.
SF patch 698520 contributed by Brett Cannon.
Tools/Demos
-----------
Build
-----
C API
-----
#ifndef PY_LONG_LONG
#define PY_LONG_LONG LONG_LONG
#endif
New platforms
-------------
Windows
-------
Mac
---
- OSA Scripting support has improved a lot, and gensuitemodule.py can now
be used by mere mortals. The documentation is now also more or less
complete.
- Negative positions returned from PEP 293 error callbacks are now
treated as being relative to the end of the input string. Positions
that are out of bounds raise an IndexError.
- Finally fixed the bug in compile() and exec where a string ending
with an indented code block but no newline would raise SyntaxError.
This would have been a four-line change in parsetok.c... Except
codeop.py depends on this behavior, so a compilation flag had to be
invented that causes the tokenizer to revert to the old behavior;
this required extra changes to 2 .h files, 2 .c files, and 2 .py
files. (Fixes SF bug #501622.)
- Through a bytecode optimizer bug (and I bet you didn't even know
Python *had* a bytecode optimizer :-), "unsigned" hex/oct constants
with a leading minus sign would come out with the wrong sign.
("Unsigned" hex/oct constants are those with a face value in the
range sys.maxint+1 through sys.maxint*2+1, inclusive; these have
always been interpreted as negative numbers through sign folding.)
E.g. 0xffffffff is -1, and -(0xffffffff) is 1, but -0xffffffff would
come out as -4294967295. This was the case in Python 2.2 through
2.2.2 and 2.3a1, and in Python 2.4 it will once again have that
value, but according to PEP 237 it really needs to be 1 now. This
will be backported to Python 2.2.3 a well. (SF #660455)
- compile(), eval() and the exec statement now fully support source code
passed as unicode strings.
- int subclasses can be initialized with longs if the value fits in an int.
See SF bug #683467.
- List objects' sort() method now accepts None as the comparison function.
Passing None is semantically identical to calling sort() with no
arguments.
- Fixed crash when printing a subclass of str and __str__ returned self.
See SF bug #667147.
Extension modules
-----------------
- The imp module now has ways to acquire and release the "import
lock": imp.acquire_lock() and imp.release_lock(). Note: this is a
reentrant lock, so releasing the lock only truly releases it when
this is the last release_lock() call. You can check with
imp.lock_held(). (SF bug #580952 and patch #683257.)
- The SSL module now handles sockets with a timeout set correctly (SF
patch #675750, fixing SF bug #675552).
- datetime changes:
The datetime and datetimetz classes have been collapsed into a single
datetime class, and likewise the time and timetz classes into a single
time class. Previously, a datetimetz object with tzinfo=None acted
exactly like a datetime object, and similarly for timetz. This wasn't
enough of a difference to justify distinct classes, and life is simpler
now.
The tzinfo methods utcoffset() and dst() must return a timedelta object
(or None) now. In 2.3a1 they could also return an int or long, but that
was an unhelpfully redundant leftover from an earlier version wherein
they couldn't return a timedelta. TOOWTDI.
The example tzinfo class for local time had a bug. It was replaced
by a later example coded by Guido.
tz.fromutc(datetime.utcnow().replace(tzinfo=utc))
if some_datetime in some_sequence:
and ::
some_dict[some_timedelta] = whatever
The pickle format of date, time and datetime objects has changed
completely. The undocumented pickler and unpickler functions no
longer exist. The undocumented __setstate__() and __getstate__()
methods no longer exist either.
Library
-------
- The logging module was updated slightly; the WARN level was renamed
to WARNING, and the matching function/method warn() to warning().
- The pickle and cPickle modules were updated with a new pickling
protocol (documented by pickletools.py, see below) and several
extensions to the pickle customization API (__reduce__, __setstate__
etc.). The copy module now uses more of the pickle customization
API to copy objects that don't implement __copy__ or __deepcopy__.
See PEP 307 for details.
- Bastion.py and rexec.py are disabled. These modules are not safe in
Python 2.2. or 2.3.
- urlparse can now parse imap:// URLs. See SF feature request #618024.
- The dospath module was deleted. Use the ntpath module when manipulating
DOS paths from other platforms.
Tools/Demos
-----------
- On systems which build using the configure script, compiler flags which
used to be lumped together using the OPT flag have been split into two
groups, OPT and BASECFLAGS. OPT is meant to carry just optimization- and
debug-related flags like "-g" and "-O3". BASECFLAGS is meant to carry
compiler flags that are required to get a clean compile. On some
platforms (many Linux flavors in particular) BASECFLAGS will be empty by
default. On others, such as Mac OS X and SCO, it will contain required
flags. This change allows people building Python to override OPT without
fear of clobbering compiler flags which are required to get a clean build.
C API
-----
Tests
-----
Windows
-------
- The timeout code for socket connect() didn't work right; this has
now been fixed. test_timeout.py should pass (at least most of the
time).
- The bsddb module now ships with Sleepycat's 4.1.25.NC, the latest
release without strong cryptography.
Mac
---
- There is a new module pimp, the package install manager for Python, and
accompanying applet PackageManager. These allow you to easily download
and install pretested extension packages either in source or binary
form. Only in MacPython-OSX.
- Applets are now built with bundlebuilder in MacPython-OSX, which should make
them more robust and also provides a path towards BuildApplication. The
downside of this change is that applets can no longer be run from the
Terminal window, this will hopefully be fixed in the 2.3b1.
- The __slots__ variable can now mention "private" names, and the
right thing will happen (e.g. __slots__ = ["__foo"]).
- The built-ins slice() and buffer() are now callable types. The
types classobj (formerly class), code, function, instance, and
instancemethod (formerly instance-method), which have no built-in
names but are accessible through the types module, are now also
callable. The type dict-proxy is renamed to dictproxy.
- The constructor for the module type now requires a name argument and
takes an optional docstring argument. Previously, this constructor
ignored its arguments. As a consequence, deriving a class from a
module (not from the module type) is now illegal; previously this
created an unnamed module, just like invoking the module type did.
[SF bug 563060]
- Fixed super() to work correctly with class methods. [SF bug #535444]
- The _codecs support module for codecs.py was turned into a builtin
module to assure that at least the builtin codecs are available
to the Python parser for source code decoding according to PEP 263.
- Thanks to Armin Rigo, the last known way to provoke a system crash
by cleverly arranging for a comparison function to mutate a list
during a list.sort() operation has been fixed. The effect of
attempting to mutate a list, or even to inspect its contents or
length, while a sort is in progress, is not defined by the language.
The C implementation of Python 2.3 attempts to detect mutations,
and raise ValueError if one occurs, but there's no guarantee that
all mutations will be caught, or that any will be caught across
releases or implementations.
- Octal and hex literals without 'L' prefix in the inclusive range
[0x80000000..0xffffffff]; these are currently negative ints, but
in Python 2.4 they will be positive longs with the same bit
pattern.
- The tempfile module has been overhauled for enhanced security. The
mktemp() function is now deprecated; new, safe replacements are
mkstemp() (for files) and mkdtemp() (for directories), and the
higher-level functions NamedTemporaryFile() and TemporaryFile().
Use of some global variables in this module is also deprecated; the
new functions have keyword arguments to provide the same
functionality. All Lib, Tools and Demo modules that used the unsafe
interfaces have been updated to use the safe replacements. Thanks
to Zack Weinberg!
- When x is an object whose class implements __mul__ and __rmul__,
1.0*x would correctly invoke __rmul__, but 1*x would erroneously
invoke __mul__. This was due to the sequence-repeat code in the int
type. This has been fixed now.
- File objects are now their own iterators. For a file f, iter(f) now
returns f (unless f is closed), and f.next() is similar to
f.readline() when EOF is not reached; however, f.next() uses a
readahead buffer that messes up the file position, so mixing
f.next() and f.readline() (or other methods) doesn't work right.
Calling f.seek() drops the readahead buffer, but other operations
don't. It so happens that this gives a nice additional speed boost
to "for line in file:"; the xreadlines method and corresponding
module are now obsolete. Thanks to Oren Tirosh!
- All standard iterators now ensure that, once StopIteration has been
raised, all future calls to next() on the same iterator will also
raise StopIteration. There used to be various counterexamples to
this behavior, which could caused confusion or subtle program
breakage, without any benefits. (Note that this is still an
iterator's responsibility; the iterator framework does not enforce
this.)
- Fixed a bug with a continue inside a try block and a yield in the
finally clause. [SF bug 567538]
- A method zfill() was added to str and unicode, that fills a numeric
string to the left with zeros. For example,
"+123".zfill(6) -> "+00123".
- String and unicode methods lstrip(), rstrip() and strip() now take
an optional argument that specifies the characters to strip. For
example, "Foo!!!?!?!?".rstrip("?!") -> "Foo".
- Added a new dict method pop(key). This removes and returns the
value corresponding to key. [SF patch #539949]
- PyErr_Display will provide file and line information for all exceptions
that have an attribute print_file_and_line, not just SyntaxErrors.
- The UTF-8 codec will now encode and decode Unicode surrogates
correctly and without raising exceptions for unpaired ones.
- Fix problem with dynamic loading on 64-bit AIX (see bug #639945).
Extension modules
-----------------
http://www.zope.org/Members/fdrake/DateTimeWiki/FrontPage
- The _tkinter module (and hence Tkinter) has dropped support for
Tcl/Tk 8.0 and 8.1. Only Tcl/Tk versions 8.2, 8.3 and 8.4 are
supported.
- pwd, grp, and resource return enhanced tuples now, with symbolic
field names.
- Fixed bug #470582: sre module would return a tuple (None, 'a', 'ab')
when applying the regular expression '^((a)c)?(ab)$' on 'ab'. It now
returns (None, None, 'ab'), as expected. Also fixed handling of
lastindex/lastgroup match attributes in similar cases. For example,
when running the expression r'(a)(b)?b' over 'ab', lastindex must be
1, not 2.
- Fixed bug #581080: sre scanner was not checking the buffer limit
before increasing the current pointer. This was creating an infinite
loop in the search function, once the pointer exceeded the buffer
limit.
- The os.fdopen function now enforces a file mode starting with the
letter 'r', 'w' or 'a', otherwise a ValueError is raised. This fixes
bug #623464.
Library
-------
- gzip.py now handles files exceeding 2GB. Files over 4GB also work
now (provided the OS supports it, and Python is configured with large
file support), but in that case the underlying gzip file format can
record only the least-significant 32 bits of the file size, so that
some tools working with gzipped files may report an incorrect file
size.
- Importing the readline module now no longer has the side effect of
calling setlocale(LC_CTYPE, ""). The initial "C" locale, or
whatever locale is explicitly set by the user, is preserved. If you
want repr() of 8-bit strings in your preferred encoding to preserve
all printable characters of that encoding, you have to add the
following code to your $PYTHONSTARTUP file or to your application's
main():
import locale
locale.setlocale(locale.LC_CTYPE, "")
- New module: sets, defines the class Set that implements a mutable
set type using the keys of a dict to represent the set. There's
also a class ImmutableSet which is useful when you need sets of sets
or when you need to use sets as dict keys, and a class BaseSet which
is the base class of the two.
- Some fixes in the copy module: when an object is copied through its
__reduce__ method, there was no check for a __setstate__ method on
the result [SF patch 565085]; deepcopy should treat instances of
custom metaclasses the same way it treats instances of type 'type'
[SF patch 560794].
- socket module: the SSL support was broken out of the main
_socket module C helper and placed into a new _ssl helper
which now gets imported by socket.py if available and working.
- distutils' build_ext command now links C++ extensions with the C++
compiler available in the Makefile or CXX environment variable, if
running under \*nix.
- New module bz2: provides a comprehensive interface for the bz2 compression
library. It implements a complete file interface, one-shot (de)compression
functions, and types for sequential (de)compression.
- New pdb command 'pp' which is like 'p' except that it pretty-prints
the value of its expression argument.
Tools/Demos
-----------
- The SGI demos (Demo/sgi) have been removed. Nobody thought they
were interesting any more. (The SGI library modules and extensions
are still there; it is believed that at least some of these are
still used and useful.)
- IDLE supports the new encoding declarations (PEP 263); it can also
deal with legacy 8-bit files if they use the locale's encoding. It
allows non-ASCII strings in the interactive shell and executes them
in the locale's encoding.
Build
-----
The Standard C macro HUGE_VAL and its float and long double analogs,
HUGE_VALF and HUGE_VALL, expand to expressions whose values are
positive infinities.
Python only uses the double HUGE_VAL, and only to #define its own symbol
Py_HUGE_VAL. Some platforms have incorrect definitions for HUGE_VAL.
pyport.h used to try to worm around that, but the workarounds triggered
other bugs on other platforms, so we gave up. If your platform defines
HUGE_VAL incorrectly, you'll need to #define Py_HUGE_VAL to something
that works on your platform. The only instance of this I'm sure about
is on an unknown subset of Cray systems, described here:
http://www.cray.com/swpubs/manuals/SN-2194_2.0/html-SN-2194_2.0/x3138.htm
Presumably 2.3a1 breaks such systems. If anyone uses such a system, help!
- The tools used to build the documentation now work under Cygwin as
well as Unix.
- The bsddb and dbm module builds have been changed to try and avoid version
skew problems and disable linkage with Berkeley DB 1.85 unless the
installer knows what s/he's doing. See the section on building these
modules in the README file for details.
C API
-----
- The type of tp_free has been changed from "``void (*)(PyObject *)``" to
"``void (*)(void *)``".
- A type can now inherit its metatype from its base type. Previously,
when PyType_Ready() was called, if ob_type was found to be NULL, it
was always set to &PyType_Type; now it is set to base->ob_type,
where base is tp_base, defaulting to &PyObject_Type.
- The "u#" parser marker will now pass through Unicode objects as-is
without going through the buffer API.
- The enumerators of cmp_op have been renamed to use the prefix ``PyCmp_``.
- An old #define of ANY as void has been removed from pyport.h. This
hasn't been used since Python's pre-ANSI days, and the #define has
been marked as obsolete since then. SF bug 495548 says it created
conflicts with other packages, so keeping it around wasn't harmless.
New platforms
-------------
Tests
-----
Windows
-------
- The Windows distribution now ships with Tcl/Tk version 8.4.1 (it
previously shipped with Tcl/Tk 8.3.2).
- The installer now installs Start menu shortcuts under (the local
equivalent of) "All Users" when doing an Admin install.
- The os module now exports all the symbolic constants usable with the
low-level os.open() on Windows: the new constants in 2.3 are
O_NOINHERIT, O_SHORT_LIVED, O_TEMPORARY, O_RANDOM and O_SEQUENTIAL.
The others were also available in 2.2: O_APPEND, O_BINARY, O_CREAT,
O_EXCL, O_RDONLY, O_RDWR, O_TEXT, O_TRUNC and O_WRONLY. Contrary
to Microsoft docs, O_SHORT_LIVED does not seem to imply O_TEMPORARY
(so specify both if you want both; note that neither is useful unless
specified with O_CREAT too).
Mac
----
- Mac/Relnotes is gone, the release notes are now here.
- The current naming convention for Python on the Macintosh is that MacPython
refers to the unix-based OSX-only version, and MacPython-OS9 refers to the
CFM-based version that runs on both OS9 and OSX.
- All the Carbon classes are now PEP253 compliant, meaning that you can
subclass them from Python. Most of the attributes have gone, you should
now use the accessor function call API, which is also what Apple's
documentation uses. Some attributes such as grafport.visRgn are still
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
gone, and replaced by a Python wrapper around the new modules.
- New Carbon modules Help and AH give access to the Carbon Help Manager.
There are hooks in the IDE to allow accessing the Python documentation
(and Apple's Carbon and Cocoa documentation) through the Help Viewer.
See Mac/OSX/README for converting the Python documentation to a
Help Viewer compatible form and installing it.
- OSA support has been redesigned and the generated Python classes now
mirror the inheritance defined by the underlying OSA classes.
- MacPython no longer maps both \r and \n to \n on input for any text file.
This feature has been replaced by universal newline support (PEP278).
----