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.1 (final)? ================================= We only changed a few things since the last release candidate, all in Python library code: - A bug in the locale module was fixed that affected locales which define no grouping for numeric formatting. - A few bugs in the weakref module's implementations of weak dictionaries (WeakValueDictionary and WeakKeyDictionary) were fixed, and the test suite was updated to check for these bugs. - An old bug in the os.path.walk() function (introduced in Python 2.0!) was fixed: a non-existent file would cause an exception instead of being ignored. - Fixed a few bugs in the new symtable module found by Neil Norwitz's PyChecker. What's New in Python 2.1c2? =========================== A flurry of small changes, and one showstopper fixed in the nick of time made it necessary to release another release candidate. The list here is the *complete* list of patches (except version updates): Core - Tim discovered a nasty bug in the dictionary code, caused by PyDict_Next() calling dict_resize(), and the GC code's use of PyDict_Next() violating an assumption in dict_items(). This was fixed with considerable amounts of band-aid, but the net effect is a saner and more robust implementation. - Made a bunch of symbols static that were accidentally global. Build and Ports - The setup.py script didn't check for a new enough version of zlib (1.1.3 is needed). Now it does. - Changed "make clean" target to also remove shared libraries. - Added a more general warning about the SGI Irix optimizer to README. Library - Fix a bug in urllib.basejoin("http://host", "../file.html") which omitted the slash between host and file.html. - The mailbox module's _Mailbox class contained a completely broken and undocumented seek() method. Ripped it out. - Fixed a bunch of typos in various library modules (urllib2, smtpd, sgmllib, netrc, chunk) found by Neil Norwitz's PyChecker. - Fixed a few last-minute bugs in unittest. Extensions - Reverted the patch to the OpenSSL code in socketmodule.c to support RAND_status() and the EGD, and the subsequent patch that tried to fix it for pre-0.9.5 versions; the problem with the patch is that on some systems it issues a warning whenever socket is imported, and that's unacceptable. Tests - Fixed the pickle tests to work with "import test.test_pickle". - Tweaked test_locale.py to actually run the test Windows. - In distutils/archive_util.py, call zipfile.ZipFile() with mode "w", not "wb" (which is not a valid mode at all). - Fix pstats browser crashes. Import readline if it exists to make the user interface nicer. - Add "import thread" to the top of test modules that import the threading module (test_asynchat and test_threadedtempfile). This prevents test failures caused by a broken threading module resulting from a previously caught failed import. - Changed test_asynchat.py to set the SO_REUSEADDR option; this was needed on some platforms (e.g. Solaris 8) when the tests are run twice in succession. - Skip rather than fail test_sunaudiodev if no audio device is found. What's New in Python 2.1c1? =========================== This list was significantly updated when 2.1c2 was released; the 2.1c1 release didn't mention most changes that were actually part of 2.1c1: Legal - Copyright was assigned to the Python Software Foundation (PSF) and a PSF license (very similar to the CNRI license) was added. - The CNRI copyright notice was updated to include 2001. Core - After a public outcry, assignment to __debug__ is no longer illegal; instead, a warning is issued. It will become illegal in 2.2. - Fixed a core dump with "%#x" % 0, and changed the semantics so that "%#x" now always prepends "0x", even if the value is zero. - Fixed some nits in the bytecode compiler. - Fixed core dumps when calling certain kinds of non-functions. - Fixed various core dumps caused by reference count bugs. Build and Ports - Use INSTALL_SCRIPT to install script files. - New port: SCO Unixware 7, by Billy G. Allie. - Updated RISCOS port. - Updated BeOS port and notes. - Various other porting problems resolved. Library - The TERMIOS and SOCKET modules are now truly obsolete and unnecessary. Their symbols are incorporated in the termios and socket modules. - Fixed some 64-bit bugs in pickle, cPickle, and struct, and added better tests for pickling. - threading: make Condition.wait() robust against KeyboardInterrupt. - zipfile: add support to zipfile to support opening an archive represented by an open file rather than a file name. Fix bug where the archive was not properly closed. Fixed a bug in this bugfix where flush() was called for a read-only file. - imputil: added an uninstall() method to the ImportManager. - Canvas: fixed bugs in lower() and tkraise() methods. - SocketServer: API change (added overridable close_request() method) so that the TCP server can explicitly close the request. - pstats: Eric Raymond added a simple interactive statistics browser, invoked when the module is run as a script. - locale: fixed a problem in format(). - webbrowser: made it work when the BROWSER environment variable has a value like "/usr/bin/netscape". Made it auto-detect Konqueror for KDE 2. Fixed some other nits. - unittest: changes to allow using a different exception than AssertionError, and added a few more function aliases. Some other small changes. - urllib, urllib2: fixed redirect problems and a coupleof other nits. - asynchat: fixed a critical bug in asynchat that slipped through the 2.1b2 release. Fixed another rare bug. - Fix some unqualified except: clauses (always a bad code example). XML - pyexpat: new API get_version_string(). - Fixed some minidom bugs. Extensions - Fixed a core dump in _weakref. Removed the weakref.mapping() function (it adds nothing to the API). - Rationalized the use of header files in the readline module, to make it compile (albeit with some warnings) with the very recent readline 4.2, without breaking for earlier versions. - Hopefully fixed a buffering problem in linuxaudiodev. - Attempted a fix to make the OpenSSL support in the socket module work again with pre-0.9.5 versions of OpenSSL. Tests - Added a test case for asynchat and asyncore. - Removed coupling between tests where one test failing could break another. Tools - Ping added an interactive help browser to pydoc, fixed some nits in the rest of the pydoc code, and added some features to his inspect module. - An updated python-mode.el version 4.1 which integrates Ken Manheimer's pdbtrack.el. This makes debugging Python code via pdb much nicer in XEmacs and Emacs. When stepping through your program with pdb, in either the shell window or the *Python* window, the source file and line will be tracked by an arrow. Very cool! - IDLE: syntax warnings in interactive mode are changed into errors. - Some improvements to Tools/webchecker (ignore some more URL types, follow some more links). - Brought the Tools/compiler package up to date. What's New in Python 2.1 beta 2? ================================ (Unlisted are many fixed bugs, more documentation, etc.) Core language, builtins, and interpreter - The nested scopes work (enabled by "from __future__ import nested_scopes") is completed; in particular, the future now extends into code executed through exec, eval() and execfile(), and into the interactive interpreter. - When calling a base class method (e.g. BaseClass.__init__(self)), this is now allowed even if self is not strictly spoken a class instance (e.g. when using metaclasses or the Don Beaudry hook). - Slice objects are now comparable but not hashable; this prevents dict[:] from being accepted but meaningless. - Complex division is now calculated using less braindead algorithms. This doesn't change semantics except it's more likely to give useful results in extreme cases. Complex repr() now uses full precision like float repr(). - sgmllib.py now calls handle_decl() for simple declarations. - It is illegal to assign to the name __debug__, which is set when the interpreter starts. It is effectively a compile-time constant. - A warning will be issued if a global statement for a variable follows a use or assignment of that variable. Standard library - unittest.py, a unit testing framework by Steve Purcell (PyUNIT, inspired by JUnit), is now part of the standard library. You now have a choice of two testing frameworks: unittest requires you to write testcases as separate code, doctest gathers them from docstrings. Both approaches have their advantages and disadvantages. - A new module Tix was added, which wraps the Tix extension library for Tk. With that module, it is not necessary to statically link Tix with _tkinter, since Tix will be loaded with Tcl's "package require" command. See Demo/tix/. - tzparse.py is now obsolete. - In gzip.py, the seek() and tell() methods are removed -- they were non-functional anyway, and it's better if callers can test for their existence with hasattr(). Python/C API - PyDict_Next(): it is now safe to call PyDict_SetItem() with a key that's already in the dictionary during a PyDict_Next() iteration. This used to fail occasionally when a dictionary resize operation could be triggered that would rehash all the keys. All other modifications to the dictionary are still off-limits during a PyDict_Next() iteration! - New extended APIs related to passing compiler variables around. - New abstract APIs PyObject_IsInstance(), PyObject_IsSubclass() implement isinstance() and issubclass(). - Py_BuildValue() now has a "D" conversion to create a Python complex number from a Py_complex C value. - Extensions types which support weak references must now set the field allocated for the weak reference machinery to NULL themselves; this is done to avoid the cost of checking each object for having a weakly referencable type in PyObject_INIT(), since most types are not weakly referencable. - PyFrame_FastToLocals() and PyFrame_LocalsToFast() copy bindings for free variables and cell variables to and from the frame's f_locals. - Variants of several functions defined in pythonrun.h have been added to support the nested_scopes future statement. The variants all end in Flags and take an extra argument, a PyCompilerFlags *; examples: PyRun_AnyFileExFlags(), PyRun_InteractiveLoopFlags(). These variants may be removed in Python 2.2, when nested scopes are mandatory. Distutils - the sdist command now writes a PKG-INFO file, as described in PEP 241, into the release tree. - several enhancements to the bdist_wininst command from Thomas Heller (an uninstaller, more customization of the installer's display) - from Jack Jansen: added Mac-specific code to generate a dialog for users to specify the command-line (because providing a command-line with MacPython is awkward). Jack also made various fixes for the Mac and the Metrowerks compiler. - added 'platforms' and 'keywords' to the set of metadata that can be specified for a distribution. - applied patches from Jason Tishler to make the compiler class work with Cygwin. What's New in Python 2.1 beta 1? ================================ Core language, builtins, and interpreter - Following an outcry from the community about the amount of code broken by the nested scopes feature introduced in 2.1a2, we decided to make this feature optional, and to wait until Python 2.2 (or at least 6 months) to make it standard. The option can be enabled on a per-module basis by adding "from __future__ import nested_scopes" at the beginning of a module (before any other statements, but after comments and an optional docstring). See PEP 236 (Back to the __future__) for a description of the __future__ statement. PEP 227 (Statically Nested Scopes) has been updated to reflect this change, and to clarify the semantics in a number of endcases. - The nested scopes code, when enabled, has been hardened, and most bugs and memory leaks in it have been fixed. - Compile-time warnings are now generated for a number of conditions that will break or change in meaning when nested scopes are enabled: - Using "from...import *" or "exec" without in-clause in a function scope that also defines a lambda or nested function with one or more free (non-local) variables. The presence of the import* or bare exec makes it impossible for the compiler to determine the exact set of local variables in the outer scope, which makes it impossible to determine the bindings for free variables in the inner scope. To avoid the warning about import *, change it into an import of explicitly name object, or move the import* statement to the global scope; to avoid the warning about bare exec, use exec...in... (a good idea anyway -- there's a possibility that bare exec will be deprecated in the future). - Use of a global variable in a nested scope with the same name as a local variable in a surrounding scope. This will change in meaning with nested scopes: the name in the inner scope will reference the variable in the outer scope rather than the global of the same name. To avoid the warning, either rename the outer variable, or use a global statement in the inner function. - An optional object allocator has been included. This allocator is optimized for Python objects and should be faster and use less memory than the standard system allocator. It is not enabled by default because of possible thread safety problems. The allocator is only protected by the Python interpreter lock and it is possible that some extension modules require a thread safe allocator. The object allocator can be enabled by providing the "--with-pymalloc" option to configure. Standard library - pyexpat now detects the expat version if expat.h defines it. A number of additional handlers are provided, which are only available since expat 1.95. In addition, the methods SetParamEntityParsing and GetInputContext of Parser objects are available with 1.95.x only. Parser objects now provide the ordered_attributes and specified_attributes attributes. A new module expat.model was added, which offers a number of additional constants if 1.95.x is used. - xml.dom offers the new functions registerDOMImplementation and getDOMImplementation. - xml.dom.minidom offers a toprettyxml method. A number of DOM conformance issues have been resolved. In particular, Element now has an hasAttributes method, and the handling of namespaces was improved. - Ka-Ping Yee contributed two new modules: inspect.py, a module for getting information about live Python code, and pydoc.py, a module for interactively converting docstrings to HTML or text. Tools/scripts/pydoc, which is now automatically installed into /bin, uses pydoc.py to display documentation; try running "pydoc -h" for instructions. "pydoc -g" pops up a small GUI that lets you browse the module docstrings using a web browser. - New library module difflib.py, primarily packaging the SequenceMatcher class at the heart of the popular ndiff.py file-comparison tool. - doctest.py (a framework for verifying Python code examples in docstrings) is now part of the std library. Windows changes - A new entry in the Start menu, "Module Docs", runs "pydoc -g" -- a small GUI that lets you browse the module docstrings using your default web browser. - Import is now case-sensitive. PEP 235 (Import on Case-Insensitive Platforms) is implemented. See http://python.sourceforge.net/peps/pep-0235.html for full details, especially the "Current Lower-Left Semantics" section. The new Windows import rules are simpler than before: A. If the PYTHONCASEOK environment variable exists, same as before: silently accept the first case-insensitive match of any kind; raise ImportError if none found. B. Else search sys.path for the first case-sensitive match; raise ImportError if none found. The same rules have been implemented on other platforms with case- insensitive but case-preserving filesystems too (including Cygwin, and several flavors of Macintosh operating systems). - winsound module: Under Win9x, winsound.Beep() now attempts to simulate what it's supposed to do (and does do under NT and 2000) via direct port manipulation. It's unknown whether this will work on all systems, but it does work on my Win98SE systems now and was known to be useless on all Win9x systems before. - Build: Subproject _test (effectively) renamed to _testcapi. New platforms - 2.1 should compile and run out of the box under MacOS X, even using HFS+. Thanks to Steven Majewski! - 2.1 should compile and run out of the box on Cygwin. Thanks to Jason Tishler! - 2.1 contains new files and patches for RISCOS, thanks to Dietmar Schwertberger! See RISCOS/README for more information -- it seems that because of the bizarre filename conventions on RISCOS, no port to that platform is easy. What's New in Python 2.1 alpha 2? ================================= Core language, builtins, and interpreter - Scopes nest. If a name is used in a function or class, but is not local, the definition in the nearest enclosing function scope will be used. One consequence of this change is that lambda statements could reference variables in the namespaces where the lambda is defined. In some unusual cases, this change will break code. 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 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. Section 4.1 of the reference manual describes the new scoping rules in detail. The test script in Lib/test/test_scope.py demonstrates some of the effects of the change. The new rules will cause existing code to break if it defines nested functions where an outer function has local variables with the same name as globals or builtins used by the inner function. Example: def munge(str): def helper(x): return str(x) if type(str) != type(''): str = helper(str) 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 the argument named str and an error will occur when helper() is called. - The compiler will report a SyntaxError if "from ... import *" occurs in a function or class scope. The language reference has documented that this case is illegal, but the compiler never checked for it. The recent introduction of nested scope makes the meaning of this form of name binding ambiguous. In a future release, the compiler may allow this form when there is no possibility of ambiguity. - repr(string) is easier to read, now using hex escapes instead of octal, and using \t, \n and \r instead of \011, \012 and \015 (respectively): >>> "\texample \r\n" + chr(0) + chr(255) '\texample \r\n\x00\xff' # in 2.1 '\011example \015\012\000\377' # in 2.0 - Functions are now compared and hashed by identity, not by value, since the func_code attribute is writable. - Weak references (PEP 205) have been added. This involves a few changes in the core, an extension module (_weakref), and a Python module (weakref). The weakref module is the public interface. It includes support for "explicit" weak references, proxy objects, and mappings with weakly held values. - A 'continue' statement can now appear in a try block within the body of a loop. It is still not possible to use continue in a finally clause. Standard library - mailbox.py now has a new class, PortableUnixMailbox which is identical to UnixMailbox but uses a more portable scheme for determining From_ separators. Also, the constructors for all the classes in this module have a new optional `factory' argument, which is a callable used when new message classes must be instantiated by the next() method. - random.py is now self-contained, and offers all the functionality of the now-deprecated whrandom.py. See the docs for details. random.py also supports new functions getstate() and setstate(), for saving and restoring the internal state of the generator; and jumpahead(n), for quickly forcing the internal state to be the same as if n calls to random() had been made. The latter is particularly useful for multi- threaded programs, creating one instance of the random.Random() class for each thread, then using .jumpahead() to force each instance to use a non-overlapping segment of the full period. - random.py's seed() function is new. For bit-for-bit compatibility with prior releases, use the whseed function instead. The new seed function addresses two problems: (1) The old function couldn't produce more than about 2**24 distinct internal states; the new one about 2**45 (the best that can be done in the Wichmann-Hill generator). (2) The old function sometimes produced identical internal states when passed distinct integers, and there was no simple way to predict when that would happen; the new one guarantees to produce distinct internal states for all arguments in [0, 27814431486576L). - The socket module now supports raw packets on Linux. The socket family is AF_PACKET. - test_capi.py is a start at running tests of the Python C API. The tests are implemented by the new Modules/_testmodule.c. - A new extension module, _symtable, provides provisional access to the internal symbol table used by the Python compiler. A higher-level interface will be added on top of _symtable in a future release. - Removed the obsolete soundex module. - xml.dom.minidom now uses the standard DOM exceptions. Node supports the isSameNode method; NamedNodeMap the get method. - xml.sax.expatreader supports the lexical handler property; it generates comment, startCDATA, and endCDATA events. Windows changes - Build procedure: the zlib project is built in a different way that ensures the zlib header files used can no longer get out of synch with the zlib binary used. See PCbuild\readme.txt for details. Your old zlib-related directories can be deleted; you'll need to download fresh source for zlib and unpack it into a new directory. - Build: New subproject _test for the benefit of test_capi.py (see above). - Build: New subproject _symtable, for new DLL _symtable.pyd (a nascent interface to some Python compiler internals). - Build: Subproject ucnhash is gone, since the code was folded into the unicodedata subproject. What's New in Python 2.1 alpha 1? ================================= Core language, builtins, and interpreter - There is a new Unicode companion to the PyObject_Str() API called PyObject_Unicode(). It behaves in the same way as the former, but assures that the returned value is an Unicode object (applying the usual coercion if necessary). - The comparison operators support "rich comparison overloading" (PEP 207). C extension types can provide a rich comparison function in the new tp_richcompare slot in the type object. The cmp() function and the C function PyObject_Compare() first try the new rich comparison operators before trying the old 3-way comparison. There is also a new C API PyObject_RichCompare() (which also falls back on the old 3-way comparison, but does not constrain the outcome of the rich comparison to a Boolean result). The rich comparison function takes two objects (at least one of which is guaranteed to have the type that provided the function) and an integer indicating the opcode, which can be Py_LT, Py_LE, Py_EQ, Py_NE, Py_GT, Py_GE (for <, <=, ==, !=, >, >=), and returns a Python object, which may be NotImplemented (in which case the tp_compare slot function is used as a fallback, if defined). Classes can overload individual comparison operators by defining one or more of the methods__lt__, __le__, __eq__, __ne__, __gt__, __ge__. There are no explicit "reflected argument" versions of these; instead, __lt__ and __gt__ are each other's reflection, likewise for__le__ and __ge__; __eq__ and __ne__ are their own reflection (similar at the C level). No other implications are made; in particular, Python does not assume that == is the Boolean inverse of !=, or that < is the Boolean inverse of >=. This makes it possible to define types with partial orderings. Classes or types that want to implement (in)equality tests but not the ordering operators (i.e. unordered types) should implement == and !=, and raise an error for the ordering operators. It is possible to define types whose rich comparison results are not Boolean; e.g. a matrix type might want to return a matrix of bits for A < B, giving elementwise comparisons. Such types should ensure that any interpretation of their value in a Boolean context raises an exception, e.g. by defining __nonzero__ (or the tp_nonzero slot at the C level) to always raise an exception. - Complex numbers use rich comparisons to define == and != but raise an exception for <, <=, > and >=. Unfortunately, this also means that cmp() of two complex numbers raises an exception when the two numbers differ. Since it is not mathematically meaningful to compare complex numbers except for equality, I hope that this doesn't break too much code. - The outcome of comparing non-numeric objects of different types is not defined by the language, other than that it's arbitrary but consistent (see the Reference Manual). An implementation detail changed in 2.1a1 such that None now compares less than any other object. Code relying on this new behavior (like code that relied on the previous behavior) does so at its own risk. - Functions and methods now support getting and setting arbitrarily named attributes (PEP 232). Functions have a new __dict__ (a.k.a. func_dict) which hold the function attributes. Methods get and set attributes on their underlying im_func. It is a TypeError to set an attribute on a bound method. - The xrange() object implementation has been improved so that xrange(sys.maxint) can be used on 64-bit platforms. There's still a limitation that in this case len(xrange(sys.maxint)) can't be calculated, but the common idiom "for i in xrange(sys.maxint)" will work fine as long as the index i doesn't actually reach 2**31. (Python uses regular ints for sequence and string indices; fixing that is much more work.) - Two changes to from...import: 1) "from M import X" now works even if (after loading module M) sys.modules['M'] is not a real module; it's basically a getattr() operation with AttributeError exceptions changed into ImportError. 2) "from M import *" now looks for M.__all__ to decide which names to import; if M.__all__ doesn't exist, it uses M.__dict__.keys() but filters out names starting with '_' as before. Whether or not __all__ exists, there's no restriction on the type of M. - File objects have a new method, xreadlines(). This is the fastest way to iterate over all lines in a file: for line in file.xreadlines(): ...do something to line... See the xreadlines module (mentioned below) for how to do this for other file-like objects. - Even if you don't use file.xreadlines(), you may expect a speedup on line-by-line input. The file.readline() method has been optimized quite a bit in platform-specific ways: on systems (like Linux) that support flockfile(), getc_unlocked(), and funlockfile(), those are used by default. On systems (like Windows) without getc_unlocked(), a complicated (but still thread-safe) method using fgets() is used by default. You can force use of the fgets() method by #define'ing USE_FGETS_IN_GETLINE at build time (it may be faster than getc_unlocked()). You can force fgets() not to be used by #define'ing DONT_USE_FGETS_IN_GETLINE (this is the first thing to try if std test test_bufio.py fails -- and let us know if it does!). - In addition, the fileinput module, while still slower than the other methods on most platforms, has been sped up too, by using file.readlines(sizehint). - Support for run-time warnings has been added, including a new command line option (-W) to specify the disposition of warnings. See the description of the warnings module below. - Extensive changes have been made to the coercion code. This mostly affects extension modules (which can now implement mixed-type numerical operators without having to use coercion), but occasionally, in boundary cases the coercion semantics have changed subtly. Since this was a terrible gray area of the language, this is considered an improvement. Also note that __rcmp__ is no longer supported -- instead of calling __rcmp__, __cmp__ is called with reflected arguments. - In connection with the coercion changes, a new built-in singleton object, NotImplemented is defined. This can be returned for operations that wish to indicate they are not implemented for a particular combination of arguments. From C, this is Py_NotImplemented. - The interpreter accepts now bytecode files on the command line even if they do not have a .pyc or .pyo extension. On Linux, after executing import imp,sys,string magic = string.join(["\\x%.2x" % ord(c) for c in imp.get_magic()],"") reg = ':pyc:M::%s::%s:' % (magic, sys.executable) open("/proc/sys/fs/binfmt_misc/register","wb").write(reg) any byte code file can be used as an executable (i.e. as an argument to execve(2)). - %[xXo] formats of negative Python longs now produce a sign character. In 1.6 and earlier, they never produced a sign, and raised an error if the value of the long was too large to fit in a Python int. In 2.0, they produced a sign if and only if too large to fit in an int. This was inconsistent across platforms (because the size of an int varies across platforms), and inconsistent with hex() and oct(). Example: >>> "%x" % -0x42L '-42' # in 2.1 'ffffffbe' # in 2.0 and before, on 32-bit machines >>> hex(-0x42L) '-0x42L' # in all versions of Python The behavior of %d formats for negative Python longs remains the same as in 2.0 (although in 1.6 and before, they raised an error if the long didn't fit in a Python int). %u formats don't make sense for Python longs, but are allowed and treated the same as %d in 2.1. In 2.0, a negative long formatted via %u produced a sign if and only if too large to fit in an int. In 1.6 and earlier, a negative long formatted via %u raised an error if it was too big to fit in an int. - Dictionary objects have an odd new method, popitem(). This removes an arbitrary item from the dictionary and returns it (in the form of a (key, value) pair). This can be useful for algorithms that use a dictionary as a bag of "to do" items and repeatedly need to pick one item. Such algorithms normally end up running in quadratic time; using popitem() they can usually be made to run in linear time. Standard library - In the time module, the time argument to the functions strftime, localtime, gmtime, asctime and ctime is now optional, defaulting to the current time (in the local timezone). - The ftplib module now defaults to passive mode, which is deemed a more useful default given that clients are often inside firewalls these days. Note that this could break if ftplib is used to connect to a *server* that is inside a firewall, from outside; this is expected to be a very rare situation. To fix that, you can call ftp.set_pasv(0). - The module site now treats .pth files not only for path configuration, but also supports extensions to the initialization code: Lines starting with import are executed. - There's a new module, warnings, which implements a mechanism for issuing and filtering warnings. There are some new built-in exceptions that serve as warning categories, and a new command line option, -W, to control warnings (e.g. -Wi ignores all warnings, -We turns warnings into errors). warnings.warn(message[, category]) issues a warning message; this can also be called from C as PyErr_Warn(category, message). - A new module xreadlines was added. This exports a single factory function, xreadlines(). The intention is that this code is the absolutely fastest way to iterate over all lines in an open file(-like) object: import xreadlines for line in xreadlines.xreadlines(file): ...do something to line... This is equivalent to the previous the speed record holder using file.readlines(sizehint). Note that if file is a real file object (as opposed to a file-like object), this is equivalent: for line in file.xreadlines(): ...do something to line... - The bisect module has new functions bisect_left, insort_left, bisect_right and insort_right. The old names bisect and insort are now aliases for bisect_right and insort_right. XXX_right and XXX_left methods differ in what happens when the new element compares equal to one or more elements already in the list: the XXX_left methods insert to the left, the XXX_right methods to the right. Code that doesn't care where equal elements end up should continue to use the old, short names ("bisect" and "insort"). - The new curses.panel module wraps the panel library that forms part of SYSV curses and ncurses. Contributed by Thomas Gellekum. - The SocketServer module now sets the allow_reuse_address flag by default in the TCPServer class. - A new function, sys._getframe(), returns the stack frame pointer of the caller. This is intended only as a building block for higher-level mechanisms such as string interpolation. - The pyexpat module supports a number of new handlers, which are available only in expat 1.2. If invocation of a callback fails, it will report an additional frame in the traceback. Parser objects participate now in garbage collection. If expat reports an unknown encoding, pyexpat will try to use a Python codec; that works only for single-byte charsets. The parser type objects is exposed as XMLParserObject. - xml.dom now offers standard definitions for symbolic node type and exception code constants, and a hierarchy of DOM exceptions. minidom was adjusted to use them. - The conformance of xml.dom.minidom to the DOM specification was improved. It detects a number of additional error cases; the previous/next relationship works even when the tree is modified; Node supports the normalize() method; NamedNodeMap, DocumentType and DOMImplementation classes were added; Element supports the hasAttribute and hasAttributeNS methods; and Text supports the splitText method. Build issues - For Unix (and Unix-compatible) builds, configuration and building of extension modules is now greatly automated. Rather than having to edit the Modules/Setup file to indicate which modules should be built and where their include files and libraries are, a distutils-based setup.py script now takes care of building most extension modules. All extension modules built this way are built as shared libraries. Only a few modules that must be linked statically are still listed in the Setup file; you won't need to edit their configuration. - Python should now build out of the box on Cygwin. If it doesn't, mail to Jason Tishler (jlt63 at users.sourceforge.net). - Python now always uses its own (renamed) implementation of getopt() -- there's too much variation among C library getopt() implementations. - C++ compilers are better supported; the CXX macro is always set to a C++ compiler if one is found. Windows changes - select module: By default under Windows, a select() call can specify no more than 64 sockets. Python now boosts this Microsoft default to 512. If you need even more than that, see the MS docs (you'll need to #define FD_SETSIZE and recompile Python from source). - Support for Windows 3.1, DOS and OS/2 is gone. The Lib/dos-8x3 subdirectory is no more! What's New in Python 2.0? ========================= Below is a list of all relevant changes since release 1.6. Older changes are in the file HISTORY. If you are making the jump directly from Python 1.5.2 to 2.0, make sure to read the section for 1.6 in the HISTORY file! Many important changes listed there. Alternatively, a good overview of the changes between 1.5.2 and 2.0 is the document "What's New in Python 2.0" by Kuchling and Moshe Zadka: http://www.amk.ca/python/2.0/. --Guido van Rossum (home page: http://www.pythonlabs.com/~guido/) ====================================================================== What's new in 2.0 (since release candidate 1)? ============================================== Standard library - The copy_reg module was modified to clarify its intended use: to register pickle support for extension types, not for classes. pickle() will raise a TypeError if it is passed a class. - Fixed a bug in gettext's "normalize and expand" code that prevented it from finding an existing .mo file. - Restored support for HTTP/0.9 servers in httplib. - The math module was changed to stop raising OverflowError in case of underflow, and return 0 instead in underflow cases. Whether Python used to raise OverflowError in case of underflow was platform- dependent (it did when the platform math library set errno to ERANGE on underflow). - Fixed a bug in StringIO that occurred when the file position was not at the end of the file and write() was called with enough data to extend past the end of the file. - Fixed a bug that caused Tkinter error messages to get lost on Windows. The bug was fixed by replacing direct use of interp->result with Tcl_GetStringResult(interp). - Fixed bug in urllib2 that caused it to fail when it received an HTTP redirect response. - Several changes were made to distutils: Some debugging code was removed from util. Fixed the installer used when an external zip program (like WinZip) is not found; the source code for this installer is in Misc/distutils. check_lib() was modified to behave more like AC_CHECK_LIB by add other_libraries() as a parameter. The test for whether installed modules are on sys.path was changed to use both normcase() and normpath(). - Several minor bugs were fixed in the xml package (the minidom, pulldom, expatreader, and saxutils modules). - The regression test driver (regrtest.py) behavior when invoked with -l changed: It now reports a count of objects that are recognized as garbage but not freed by the garbage collector. - The regression test for the math module was changed to test exceptional behavior when the test is run in verbose mode. Python cannot yet guarantee consistent exception behavior across platforms, so the exception part of test_math is run only in verbose mode, and may fail on your platform. Internals - PyOS_CheckStack() has been disabled on Win64, where it caused test_sre to fail. Build issues - Changed compiler flags, so that gcc is always invoked with -Wall and -Wstrict-prototypes. Users compiling Python with GCC should see exactly one warning, except if they have passed configure the --with-pydebug flag. The expected warning is for getopt() in Modules/main.c. This warning will be fixed for Python 2.1. - Fixed configure to add -threads argument during linking on OSF1. Tools and other miscellany - The compiler in Tools/compiler was updated to support the new language features introduced in 2.0: extended print statement, list comprehensions, and augmented assignments. The new compiler should also be backwards compatible with Python 1.5.2; the compiler will always generate code for the version of the interpreter it runs under. What's new in 2.0 release candidate 1 (since beta 2)? ===================================================== What is release candidate 1? We believe that release candidate 1 will fix all known bugs that we intend to fix for the 2.0 final release. This release should be a bit more stable than the previous betas. We would like to see even more widespread testing before the final release, so we are producing this release candidate. The final release will be exactly the same unless any show-stopping (or brown bag) bugs are found by testers of the release candidate. All the changes since the last beta release are bug fixes or changes to support building Python for specific platforms. Core language, builtins, and interpreter - A bug that caused crashes when __coerce__ was used with augmented 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 power operator and the result of math.pow(0.0, -2.0) will vary by platform. On Linux, it raises a ValueError. - A bug in Unicode string interpolation was fixed that occasionally caused errors with formats including "%%". For example, the following expression "%% %s" % u"abc" no longer raises a TypeError. - Compilation of deeply nested expressions raises MemoryError instead of SyntaxError, e.g. eval("[" * 50 + "]" * 50). - In 2.0b2 on Windows, the interpreter wrote .pyc files in text mode, rendering them useless. They are now written in binary mode again. Standard library - Keyword arguments are now accepted for most pattern and match object methods in SRE, the standard regular expression engine. - In SRE, fixed error with negative lookahead and lookbehind that manifested itself as a runtime error in patterns like "(? is now included by Python.h (if it exists). INT_MAX and LONG_MAX will always be defined, even if is not available. - PyFloat_FromString takes a second argument, pend, that was effectively useless. It is now officially useless but preserved for backwards compatibility. If the pend argument is not NULL, *pend is set to NULL. - PyObject_GetAttr() and PyObject_SetAttr() now accept Unicode objects for the attribute name. See note on getattr() above. - A few bug fixes to argument processing for Unicode. PyArg_ParseTupleAndKeywords() now accepts "es#" and "es". PyArg_Parse() special cases "s#" for Unicode objects; it returns a pointer to the default encoded string data instead of to the raw UTF-16. - Py_BuildValue accepts B format (for bgen-generated code). Internals - On Unix, fix code for finding Python installation directory so that it works when argv[0] is a relative path. - Added a true unicode_internal_encode() function and fixed the unicode_internal_decode function() to support Unicode objects directly rather than by generating a copy of the object. - Several of the internal Unicode tables are much smaller now, and the source code should be much friendlier to weaker compilers. - In the garbage collector: Fixed bug in collection of tuples. Fixed bug that caused some instances to be removed from the container set while they were still live. Fixed parsing in gc.set_debug() for platforms where sizeof(long) > sizeof(int). - Fixed refcount problem in instance deallocation that only occurred when Py_REF_DEBUG was defined and Py_TRACE_REFS was not. - On Windows, getpythonregpath is now protected against null data in registry key. - On Unix, create .pyc/.pyo files with O_EXCL flag to avoid a race condition. Build and platform-specific issues - Better support of GNU Pth via --with-pth configure option. - Python/C API now properly exposed to dynamically-loaded extension modules on Reliant UNIX. - Changes for the benefit of SunOS 4.1.4 (really!). mmapmodule.c: Don't define MS_SYNC to be zero when it is undefined. Added missing prototypes in posixmodule.c. - Improved support for HP-UX build. Threads should now be correctly configured (on HP-UX 10.20 and 11.00). - Fix largefile support on older NetBSD systems and OpenBSD by adding define for TELL64. Tools and other miscellany - ftpmirror: Call to main() is wrapped in if __name__ == "__main__". - freeze: The modulefinder now works with 2.0 opcodes. - IDLE: Move hackery of sys.argv until after the Tk instance has been created, which allows the application-specific Tkinter initialization to be executed if present; also pass an explicit className parameter to the Tk() constructor. What's new in 2.0 beta 1? ========================= Source Incompatibilities ------------------------ None. Note that 1.6 introduced several incompatibilities with 1.5.2, such as single-argument append(), connect() and bind(), and changes to str(long) and repr(float). Binary Incompatibilities ------------------------ - Third party extensions built for Python 1.5.x or 1.6 cannot be used with Python 2.0; these extensions will have to be rebuilt for Python 2.0. - On Windows, attempting to import a third party extension built for Python 1.5.x or 1.6 results in an immediate crash; there's not much we can do about this. Check your PYTHONPATH environment variable! - Python bytecode files (*.pyc and *.pyo) are not compatible between releases. Overview of Changes Since 1.6 ----------------------------- There are many new modules (including brand new XML support through the xml package, and i18n support through the gettext module); a list of all new modules is included below. Lots of bugs have been fixed. The process for making major new changes to the language has changed since Python 1.6. Enhancements must now be documented by a Python Enhancement Proposal (PEP) before they can be accepted. There are several important syntax enhancements, described in more detail below: - Augmented assignment, e.g. x += 1 - List comprehensions, e.g. [x**2 for x in range(10)] - Extended import statement, e.g. import Module as Name - Extended print statement, e.g. print >> file, "Hello" Other important changes: - Optional collection of cyclical garbage Python Enhancement Proposal (PEP) --------------------------------- PEP stands for Python Enhancement Proposal. A PEP is a design document providing information to the Python community, or describing a new feature for Python. The PEP should provide a concise technical specification of the feature and a rationale for the feature. We intend PEPs to be the primary mechanisms for proposing new features, for collecting community input on an issue, and for documenting the design decisions that have gone into Python. The PEP author is responsible for building consensus within the community and documenting dissenting opinions. The PEPs are available at http://python.sourceforge.net/peps/. Augmented Assignment -------------------- This must have been the most-requested feature of the past years! Eleven new assignment operators were added: += -= *= /= %= **= <<= >>= &= ^= |= For example, A += B is similar to A = A + B except that A is evaluated only once (relevant when A is something like dict[index].attr). However, if A is a mutable object, A may be modified in place. Thus, if A is a number or a string, A += B has the same effect as A = A+B (except A is only evaluated once); but if a is a list, A += B has the same effect as A.extend(B)! Classes and built-in object types can override the new operators in order to implement the in-place behavior; the not-in-place behavior is used automatically as a fallback when an object doesn't implement the in-place behavior. For classes, the method name is derived from the method name for the corresponding not-in-place operator by inserting an 'i' in front of the name, e.g. __iadd__ implements in-place __add__. Augmented assignment was implemented by Thomas Wouters. List Comprehensions ------------------- This is a flexible new notation for lists whose elements are computed from another list (or lists). The simplest form is: [ for in ] For example, [i**2 for i in range(4)] yields the list [0, 1, 4, 9]. This is more efficient than a for loop with a list.append() call. You can also add a condition: [ for in if ] For example, [w for w in words if w == w.lower()] would yield the list of words that contain no uppercase characters. This is more efficient than a for loop with an if statement and a list.append() call. You can also have nested for loops and more than one 'if' clause. For example, here's a function that flattens a sequence of sequences:: def flatten(seq): return [x for subseq in seq for x in subseq] flatten([[0], [1,2,3], [4,5], [6,7,8,9], []]) This prints [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] List comprehensions originated as a patch set from Greg Ewing; Skip Montanaro and Thomas Wouters also contributed. Described by PEP 202. Extended Import Statement ------------------------- Many people have asked for a way to import a module under a different name. This can be accomplished like this: import foo bar = foo del foo but this common idiom gets old quickly. A simple extension of the import statement now allows this to be written as follows: import foo as bar There's also a variant for 'from ... import': from foo import bar as spam This also works with packages; e.g. you can write this: import test.regrtest as regrtest Note that 'as' is not a new keyword -- it is recognized only in this context (this is only possible because the syntax for the import statement doesn't involve expressions). Implemented by Thomas Wouters. Described by PEP 221. Extended Print Statement ------------------------ Easily the most controversial new feature, this extension to the print statement adds an option to make the output go to a different file than the default sys.stdout. For example, to write an error message to sys.stderr, you can now write: print >> sys.stderr, "Error: bad dog!" As a special feature, if the expression used to indicate the file evaluates to None, the current value of sys.stdout is used. Thus: print >> None, "Hello world" is equivalent to print "Hello world" Design and implementation by Barry Warsaw. Described by PEP 214. Optional Collection of Cyclical Garbage --------------------------------------- Python is now equipped with a garbage collector that can hunt down cyclical references between Python objects. It's no replacement for reference counting; in fact, it depends on the reference counts being correct, and decides that a set of objects belong to a cycle if all their reference counts can be accounted for from their references to each other. This devious scheme was first proposed by Eric Tiedemann, and brought to implementation by Neil Schemenauer. There's a module "gc" that lets you control some parameters of the garbage collection. There's also an option to the configure script that lets you enable or disable the garbage collection. In 2.0b1, it's on by default, so that we (hopefully) can collect decent user experience with this new feature. There are some questions about its performance. If it proves to be too much of a problem, we'll turn it off by default in the final 2.0 release. Smaller Changes --------------- A new function zip() was added. zip(seq1, seq2, ...) is equivalent to map(None, seq1, seq2, ...) when the sequences have the same length; i.e. zip([1,2,3], [10,20,30]) returns [(1,10), (2,20), (3,30)]. When the lists are not all the same length, the shortest list wins: zip([1,2,3], [10,20]) returns [(1,10), (2,20)]. See PEP 201. sys.version_info is a tuple (major, minor, micro, level, serial). Dictionaries have an odd new method, setdefault(key, default). dict.setdefault(key, default) returns dict[key] if it exists; if not, it sets dict[key] to default and returns that value. Thus: dict.setdefault(key, []).append(item) does the same work as this common idiom: if not dict.has_key(key): dict[key] = [] dict[key].append(item) There are two new variants of SyntaxError that are raised for indentation-related errors: IndentationError and TabError. Changed \x to consume exactly two hex digits; see PEP 223. Added \U escape that consumes exactly eight hex digits. The limits on the size of expressions and file in Python source code have been raised from 2**16 to 2**32. Previous versions of Python were limited because the maximum argument size the Python VM accepted was 2**16. This limited the size of object constructor expressions, e.g. [1,2,3] or {'a':1, 'b':2}, and the size of source files. This limit was raised thanks to a patch by Charles Waldman that effectively fixes the problem. It is now much more likely that you will be limited by available memory than by an arbitrary limit in Python. The interpreter's maximum recursion depth can be modified by Python programs using sys.getrecursionlimit and sys.setrecursionlimit. This limit is the maximum number of recursive calls that can be made by Python code. The limit exists to prevent infinite recursion from overflowing the C stack and causing a core dump. The default value is 1000. The maximum safe value for a particular platform can be found by running Misc/find_recursionlimit.py. New Modules and Packages ------------------------ atexit - for registering functions to be called when Python exits. imputil - Greg Stein's alternative API for writing custom import hooks. pyexpat - an interface to the Expat XML parser, contributed by Paul Prescod. xml - a new package with XML support code organized (so far) in three subpackages: xml.dom, xml.sax, and xml.parsers. Describing these would fill a volume. There's a special feature whereby a user-installed package named _xmlplus overrides the standard xmlpackage; this is intended to give the XML SIG a hook to distribute backwards-compatible updates to the standard xml package. webbrowser - a platform-independent API to launch a web browser. Changed Modules --------------- array -- new methods for array objects: count, extend, index, pop, and remove binascii -- new functions b2a_hex and a2b_hex that convert between binary data and its hex representation calendar -- Many new functions that support features including control over which day of the week is the first day, returning strings instead of printing them. Also new symbolic constants for days of week, e.g. MONDAY, ..., SUNDAY. cgi -- FieldStorage objects have a getvalue method that works like a dictionary's get method and returns the value attribute of the object. ConfigParser -- The parser object has new methods has_option, remove_section, remove_option, set, and write. They allow the module to be used for writing config files as well as reading them. ftplib -- ntransfercmd(), transfercmd(), and retrbinary() all now optionally support the RFC 959 REST command. gzip -- readline and readlines now accept optional size arguments httplib -- New interfaces and support for HTTP/1.1 by Greg Stein. See the module doc strings for details. locale -- implement getdefaultlocale for Win32 and Macintosh marshal -- no longer dumps core when marshaling deeply nested or recursive data structures os -- new functions isatty, seteuid, setegid, setreuid, setregid os/popen2 -- popen2/popen3/popen4 support under Windows. popen2/popen3 support under Unix. os/pty -- support for openpty and forkpty os.path -- fix semantics of os.path.commonprefix smtplib -- support for sending very long messages socket -- new function getfqdn() readline -- new functions to read, write and truncate history files. The readline section of the library reference manual contains an example. select -- add interface to poll system call shutil -- new copyfileobj function SimpleHTTPServer, CGIHTTPServer -- Fix problems with buffering in the HTTP server. Tkinter -- optimization of function flatten urllib -- scans environment variables for proxy configuration, e.g. http_proxy. whichdb -- recognizes dumbdbm format Obsolete Modules ---------------- None. However note that 1.6 made a whole slew of modules obsolete: stdwin, soundex, cml, cmpcache, dircache, dump, find, grep, packmail, poly, zmod, strop, util, whatsound. Changed, New, Obsolete Tools ---------------------------- None. C-level Changes --------------- Several cleanup jobs were carried out throughout the source code. All C code was converted to ANSI C; we got rid of all uses of the Py_PROTO() macro, which makes the header files a lot more readable. Most of the portability hacks were moved to a new header file, pyport.h; several other new header files were added and some old header files were removed, in an attempt to create a more rational set of header files. (Few of these ever need to be included explicitly; they are all included by Python.h.) Trent Mick ensured portability to 64-bit platforms, under both Linux and Win64, especially for the new Intel Itanium processor. Mick also added large file support for Linux64 and Win64. The C APIs to return an object's size have been update to consistently use the form PyXXX_Size, e.g. PySequence_Size and PyDict_Size. In previous versions, the abstract interfaces used PyXXX_Length and the concrete interfaces used PyXXX_Size. The old names, e.g. PyObject_Length, are still available for backwards compatibility at the API level, but are deprecated. The PyOS_CheckStack function has been implemented on Windows by Fredrik Lundh. It prevents Python from failing with a stack overflow on Windows. The GC changes resulted in creation of two new slots on object, tp_traverse and tp_clear. The augmented assignment changes result in the creation of a new slot for each in-place operator. The GC API creates new requirements for container types implemented in C extension modules. See Include/objimpl.h for details. PyErr_Format has been updated to automatically calculate the size of the buffer needed to hold the formatted result string. This change prevents crashes caused by programmer error. New C API calls: PyObject_AsFileDescriptor, PyErr_WriteUnraisable. PyRun_AnyFileEx, PyRun_SimpleFileEx, PyRun_FileEx -- New functions that are the same as their non-Ex counterparts except they take an extra flag argument that tells them to close the file when done. XXX There were other API changes that should be fleshed out here. Windows Changes --------------- New popen2/popen3/peopen4 in os module (see Changed Modules above). os.popen is much more usable on Windows 95 and 98. See Microsoft Knowledge Base article Q150956. The Win9x workaround described there is implemented by the new w9xpopen.exe helper in the root of your Python installation. Note that Python uses this internally; it is not a standalone program. Administrator privileges are no longer required to install Python on Windows NT or Windows 2000. If you have administrator privileges, Python's registry info will be written under HKEY_LOCAL_MACHINE. Otherwise the installer backs off to writing Python's registry info under HKEY_CURRENT_USER. The latter is sufficient for all "normal" uses of Python, but will prevent some advanced uses from working (for example, running a Python script as an NT service, or possibly from CGI). [This was new in 1.6] The installer no longer runs a separate Tcl/Tk installer; instead, it installs the needed Tcl/Tk files directly in the Python directory. If you already have a Tcl/Tk installation, this wastes some disk space (about 4 Megs) but avoids problems with conflicting Tcl/Tk installations, and makes it much easier for Python to ensure that Tcl/Tk can find all its files. [This was new in 1.6] The Windows installer now installs by default in \Python20\ on the default volume, instead of \Program Files\Python-2.0\. Updates to the changes between 1.5.2 and 1.6 -------------------------------------------- The 1.6 NEWS file can't be changed after the release is done, so here is some late-breaking news: New APIs in locale.py: normalize(), getdefaultlocale(), resetlocale(), and changes to getlocale() and setlocale(). The new module is now enabled per default. It is not true that the encodings codecs cannot be used for normal strings: the string.encode() (which is also present on 8-bit strings !) allows using them for 8-bit strings too, e.g. to convert files from cp1252 (Windows) to latin-1 or vice-versa. Japanese codecs are available from Tamito KAJIYAMA: http://pseudo.grad.sccs.chukyo-u.ac.jp/~kajiyama/python/ ====================================================================== ======================================= ==> Release 1.6 (September 5, 2000) <== ======================================= What's new in release 1.6? ========================== Below is a list of all relevant changes since release 1.5.2. Source Incompatibilities ------------------------ Several small incompatible library changes may trip you up: - The append() method for lists can no longer be invoked with more than one argument. This used to append a single tuple made out of all arguments, but was undocumented. To append a tuple, use e.g. l.append((a, b, c)). - The connect(), connect_ex() and bind() methods for sockets require exactly one argument. Previously, you could call s.connect(host, port), but this was undocumented. You must now write s.connect((host, port)). - The str() and repr() functions are now different more often. For long integers, str() no longer appends a 'L'. Thus, str(1L) == '1', which used to be '1L'; repr(1L) is unchanged and still returns '1L'. For floats, repr() now gives 17 digits of precision, to ensure no precision is lost (on all current hardware). - The -X option is gone. Built-in exceptions are now always classes. Many more library modules also have been converted to class-based exceptions. Binary Incompatibilities ------------------------ - Third party extensions built for Python 1.5.x cannot be used with Python 1.6; these extensions will have to be rebuilt for Python 1.6. - On Windows, attempting to import a third party extension built for Python 1.5.x results in an immediate crash; there's not much we can do about this. Check your PYTHONPATH environment variable! Overview of Changes since 1.5.2 ------------------------------- For this overview, I have borrowed from the document "What's New in Python 2.0" by Andrew Kuchling and Moshe Zadka: http://www.amk.ca/python/2.0/ . There are lots of new modules and lots of bugs have been fixed. A list of all new modules is included below. Probably the most pervasive change is the addition of Unicode support. We've added a new fundamental datatype, the Unicode string, a new build-in function unicode(), an numerous C APIs to deal with Unicode and encodings. See the file Misc/unicode.txt for details, or http://starship.python.net/crew/lemburg/unicode-proposal.txt. Two other big changes, related to the Unicode support, are the addition of string methods and (yet another) new regular expression engine. - String methods mean that you can now say s.lower() etc. instead of importing the string module and saying string.lower(s) etc. One peculiarity is that the equivalent of string.join(sequence, delimiter) is delimiter.join(sequence). Use " ".join(sequence) for the effect of string.join(sequence); to make this more readable, try space=" " first. Note that the maxsplit argument defaults in split() and replace() have changed from 0 to -1. - The new regular expression engine, SRE by Fredrik Lundh, is fully backwards compatible with the old engine, and is in fact invoked using the same interface (the "re" module). You can explicitly invoke the old engine by import pre, or the SRE engine by importing sre. SRE is faster than pre, and supports Unicode (which was the main reason to put effort in yet another new regular expression engine -- this is at least the fourth!). Other Changes ------------- Other changes that won't break code but are nice to know about: Deleting objects is now safe even for deeply nested data structures. Long/int unifications: long integers can be used in seek() calls, as slice indexes. String formatting (s % args) has a new formatting option, '%r', which acts like '%s' but inserts repr(arg) instead of str(arg). (Not yet in alpha 1.) Greg Ward's "distutils" package is included: this will make installing, building and distributing third party packages much simpler. There's now special syntax that you can use instead of the apply() function. f(*args, **kwds) is equivalent to apply(f, args, kwds). You can also use variations f(a1, a2, *args, **kwds) and you can leave one or the other out: f(*args), f(**kwds). The built-ins int() and long() take an optional second argument to indicate the conversion base -- of course only if the first argument is a string. This makes string.atoi() and string.atol() obsolete. (string.atof() was already obsolete). When a local variable is known to the compiler but undefined when used, a new exception UnboundLocalError is raised. This is a class derived from NameError so code catching NameError should still work. The purpose is to provide better diagnostics in the following example: x = 1 def f(): print x x = x+1 This used to raise a NameError on the print statement, which confused even experienced Python programmers (especially if there are several hundreds of lines of code between the reference and the assignment to x :-). You can now override the 'in' operator by defining a __contains__ method. Note that it has its arguments backwards: x in a causes a.__contains__(x) to be called. That's why the name isn't __in__. The exception AttributeError will have a more friendly error message, e.g.: 'Spam' instance has no attribute 'eggs'. This may break code that expects the message to be exactly the attribute name. New Modules in 1.6 ------------------ UserString - base class for deriving from the string type. distutils - tools for distributing Python modules. robotparser - parse a robots.txt file, for writing web spiders. (Moved from Tools/webchecker/.) linuxaudiodev - audio for Linux. mmap - treat a file as a memory buffer. (Windows and Unix.) sre - regular expressions (fast, supports unicode). Currently, this code is very rough. Eventually, the re module will be reimplemented using sre (without changes to the re API). filecmp - supersedes the old cmp.py and dircmp.py modules. tabnanny - check Python sources for tab-width dependance. (Moved from Tools/scripts/.) urllib2 - new and improved but incompatible version of urllib (still experimental). zipfile - read and write zip archives. codecs - support for Unicode encoders/decoders. unicodedata - provides access to the Unicode 3.0 database. _winreg - Windows registry access. encodings - package which provides a large set of standard codecs -- currently only for the new Unicode support. It has a drop-in extension mechanism which allows you to add new codecs by simply copying them into the encodings package directory. Asian codec support will probably be made available as separate distribution package built upon this technique and the new distutils package. Changed Modules --------------- readline, ConfigParser, cgi, calendar, posix, readline, xmllib, aifc, chunk, wave, random, shelve, nntplib - minor enhancements. socket, httplib, urllib - optional OpenSSL support (Unix only). _tkinter - support for 8.0 up to 8.3. Support for versions older than 8.0 has been dropped. string - most of this module is deprecated now that strings have methods. This no longer uses the built-in strop module, but takes advantage of the new string methods to provide transparent support for both Unicode and ordinary strings. Changes on Windows ------------------ The installer no longer runs a separate Tcl/Tk installer; instead, it installs the needed Tcl/Tk files directly in the Python directory. If you already have a Tcl/Tk installation, this wastes some disk space (about 4 Megs) but avoids problems with conflincting Tcl/Tk installations, and makes it much easier for Python to ensure that Tcl/Tk can find all its files. Note: the alpha installers don't include the documentation. The Windows installer now installs by default in \Python16\ on the default volume, instead of \Program Files\Python-1.6\. Changed Tools ------------- IDLE - complete overhaul. See the IDLE home page for more information. (Python 1.6 alpha 1 will come with IDLE 0.6.) Tools/i18n/pygettext.py - Python equivalent of xgettext(1). A message text extraction tool used for internationalizing applications written in Python. Obsolete Modules ---------------- stdwin and everything that uses it. (Get Python 1.5.2 if you need it. :-) soundex. (Skip Montanaro has a version in Python but it won't be included in the Python release.) cmp, cmpcache, dircmp. (Replaced by filecmp.) dump. (Use pickle.) find. (Easily coded using os.walk().) grep. (Not very useful as a library module.) packmail. (No longer has any use.) poly, zmod. (These were poor examples at best.) strop. (No longer needed by the string module.) util. (This functionality was long ago built in elsewhere). whatsound. (Use sndhdr.) Detailed Changes from 1.6b1 to 1.6 ---------------------------------- - Slight changes to the CNRI license. A copyright notice has been added; the requirement to indicate the nature of modifications now applies when making a derivative work available "to others" instead of just "to the public"; the version and date are updated. The new license has a new handle. - Added the Tools/compiler package. This is a project led by Jeremy Hylton to write the Python bytecode generator in Python. - The function math.rint() is removed. - In Python.h, "#define _GNU_SOURCE 1" was added. - Version 0.9.1 of Greg Ward's distutils is included (instead of version 0.9). - A new version of SRE is included. It is more stable, and more compatible with the old RE module. Non-matching ranges are indicated by -1, not None. (The documentation said None, but the PRE implementation used -1; changing to None would break existing code.) - The winreg module has been renamed to _winreg. (There are plans for a higher-level API called winreg, but this has not yet materialized in a form that is acceptable to the experts.) - The _locale module is enabled by default. - Fixed the configuration line for the _curses module. - A few crashes have been fixed, notably .writelines() with a list containing non-string objects would crash, and there were situations where a lost SyntaxError could dump core. - The .extend() method now accepts an arbitrary sequence argument. - If __str__() or __repr__() returns a Unicode object, this is converted to an 8-bit string. - Unicode string comparisons is no longer aware of UTF-16 encoding peculiarities; it's a straight 16-bit compare. - The Windows installer now installs the LICENSE file and no longer registers the Python DLL version in the registry (this is no longer needed). It now uses Tcl/Tk 8.3.2. - A few portability problems have been fixed, in particular a compilation error involving socklen_t. - The PC configuration is slightly friendlier to non-Microsoft compilers. ====================================================================== ====================================== ==> Release 1.5.2 (April 13, 1999) <== ====================================== From 1.5.2c1 to 1.5.2 (final) ============================= Tue Apr 13 15:44:49 1999 Guido van Rossum * PCbuild/python15.wse: Bump version to 1.5.2 (final) * PCbuild/python15.dsp: Added shamodule.c * PC/config.c: Added sha module! * README, Include/patchlevel.h: Prepare for final release. * Misc/ACKS: More (Cameron Laird is honorary; the others are 1.5.2c1 testers). * Python/thread_solaris.h: While I can't really test this thoroughly, Pat Knight and the Solaris man pages suggest that the proper thing to do is to add THR_NEW_LWP to the flags on thr_create(), and that there really isn't a downside, so I'll do that. * Misc/ACKS: Bunch of new names who helped iron out the last wrinkles of 1.5.2. * PC/python_nt.rc: Bump the myusterious M$ version number from 1,5,2,1 to 1,5,2,3. (I can't even display this on NT, maybe Win/98 can?) * Lib/pstats.py: Fix mysterious references to jprofile that were in the source since its creation. I'm assuming these were once valid references to "Jim Roskind's profile"... * Lib/Attic/threading_api.py: Removed; since long subsumed in Doc/lib/libthreading.tex * Modules/socketmodule.c: Put back __osf__ support for gethostbyname_r(); the real bug was that it was being used even without threads. This of course might be an all-platform problem so now we only use the _r variant when we are using threads. Mon Apr 12 22:51:20 1999 Guido van Rossum * Modules/cPickle.c: Fix accidentally reversed NULL test in load_mark(). Suggested by Tamito Kajiyama. (This caused a bug only on platforms where malloc(0) returns NULL.) * README: Add note about popen2 problem on Linux noticed by Pablo Bleyer. * README: Add note about -D_REENTRANT for HP-UX 10.20. * Modules/Makefile.pre.in: 'clean' target should remove hassignal. * PC/Attic/vc40.mak, PC/readme.txt: Remove all VC++ info (except VC 1.5) from readme.txt; remove the VC++ 4.0 project file; remove the unused _tkinter extern defs. * README: Clarify PC build instructions (point to PCbuild). * Modules/zlibmodule.c: Cast added by Jack Jansen (for Mac port). * Lib/plat-sunos5/CDIO.py, Lib/plat-linux2/CDROM.py: Forgot to add this file. CDROM device parameters. * Lib/gzip.py: Two different changes. 1. Jack Jansen reports that on the Mac, the time may be negative, and solves this by adding a write32u() function that writes an unsigned long. 2. On 64-bit platforms the CRC comparison fails; I've fixed this by casting both values to be compared to "unsigned long" i.e. modulo 0x100000000L. Sat Apr 10 18:42:02 1999 Guido van Rossum * PC/Attic/_tkinter.def: No longer needed. * Misc/ACKS: Correct missed character in Andrew Dalke's name. * README: Add DEC Ultrix notes (from Donn Cave's email). * configure: The usual * configure.in: Quote a bunch of shell variables used in test, related to long-long. * Objects/fileobject.c, Modules/shamodule.c, Modules/regexpr.c: casts for picky compilers. * Modules/socketmodule.c: 3-arg gethostbyname_r doesn't really work on OSF/1. * PC/vc15_w31/_.c, PC/vc15_lib/_.c, Tools/pynche/__init__.py: Avoid totally empty files. Fri Apr 9 14:56:35 1999 Guido van Rossum * Tools/scripts/fixps.py: Use re instead of regex. Don't rewrite the file in place. (Reported by Andy Dustman.) * Lib/netrc.py, Lib/shlex.py: Get rid of #! line Thu Apr 8 23:13:37 1999 Guido van Rossum * PCbuild/python15.wse: Use the Tcl 8.0.5 installer. Add a variable %_TCL_% that makes it easier to switch to a different version. ====================================================================== From 1.5.2b2 to 1.5.2c1 ======================= Thu Apr 8 23:13:37 1999 Guido van Rossum * PCbuild/python15.wse: Release 1.5.2c1. Add IDLE and Uninstall to program group. Don't distribute zlib.dll. Tweak some comments. * PCbuild/zlib.dsp: Now using static zlib 1.1.3 * Lib/dos-8x3/userdict.py, Lib/dos-8x3/userlist.py, Lib/dos-8x3/test_zli.py, Lib/dos-8x3/test_use.py, Lib/dos-8x3/test_pop.py, Lib/dos-8x3/test_pic.py, Lib/dos-8x3/test_ntp.py, Lib/dos-8x3/test_gzi.py, Lib/dos-8x3/test_fcn.py, Lib/dos-8x3/test_cpi.py, Lib/dos-8x3/test_bsd.py, Lib/dos-8x3/posixfil.py, Lib/dos-8x3/mimetype.py, Lib/dos-8x3/nturl2pa.py, Lib/dos-8x3/compilea.py, Lib/dos-8x3/exceptio.py, Lib/dos-8x3/basehttp.py: The usual * Include/patchlevel.h: Release 1.5.2c1 * README: Release 1.5.2c1. * Misc/NEWS: News for the 1.5.2c1 release. * Lib/test/test_strftime.py: On Windows, we suddenly find, strftime() may return "" for an unsupported format string. (I guess this is because the logic for deciding whether to reallocate the buffer or not has been improved.) This caused the test code to crash on result[0]. Fix this by assuming an empty result also means the format is not supported. * Demo/tkinter/matt/window-creation-w-location.py: This demo imported some private code from Matt. Make it cripple along. * Lib/lib-tk/Tkinter.py: Delete an accidentally checked-in feature that actually broke more than was worth it: when deleting a canvas item, it would try to automatically delete the bindings for that item. Since there's nothing that says you can't reuse the tag and still have the bindings, this is not correct. Also, it broke at least one demo (Demo/tkinter/matt/rubber-band-box-demo-1.py). * Python/thread_wince.h: Win/CE thread support by Mark Hammond. Wed Apr 7 20:23:17 1999 Guido van Rossum * Modules/zlibmodule.c: Patch by Andrew Kuchling to unflush() (flush() for deflating). Without this, if inflate() returned Z_BUF_ERROR asking for more output space, we would report the error; now, we increase the buffer size and try again, just as for Z_OK. * Lib/test/test_gzip.py: Use binary mode for all gzip files we open. * Tools/idle/ChangeLog: New change log. * Tools/idle/README.txt, Tools/idle/NEWS.txt: New version. * Python/pythonrun.c: Alas, get rid of the Win specific hack to ask the user to press Return before exiting when an error happened. This didn't work right when Python is invoked from a daemon. * Tools/idle/idlever.py: Version bump awaiting impending new release. (Not much has changed :-( ) * Lib/lib-tk/Tkinter.py: lower, tkraise/lift hide Misc.lower, Misc.tkraise/lift, so the preferred name for them is tag_lower, tag_raise (similar to tag_bind, and similar to the Text widget); unfortunately can't delete the old ones yet (maybe in 1.6) * Python/thread.c, Python/strtod.c, Python/mystrtoul.c, Python/import.c, Python/ceval.c: Changes by Mark Hammond for Windows CE. Mostly of the form #ifdef DONT_HAVE_header_H ... #endif around #include . * Python/bltinmodule.c: Remove unused variable from complex_from_string() code. * Include/patchlevel.h: Add the possibility of a gamma release (release candidate). Add '+' to string version number to indicate we're beyond b2 now. * Modules/posixmodule.c: Add extern decl for fsync() for SunOS 4.x. * Lib/smtplib.py: Changes by Per Cederquist and The Dragon. Per writes: """ The application where Signum Support uses smtplib needs to be able to report good error messages to the user when sending email fails. To help in diagnosing problems it is useful to be able to report the entire message sent by the server, not only the SMTP error code of the offending command. A lot of the functions in sendmail.py unfortunately discards the message, leaving only the code. The enclosed patch fixes that problem. The enclosed patch also introduces a base class for exceptions that include an SMTP error code and error message, and make the code and message available on separate attributes, so that surrounding code can deal with them in whatever way it sees fit. I've also added some documentation to the exception classes. The constructor will now raise an exception if it cannot connect to the SMTP server. The data() method will raise an SMTPDataError if it doesn't receive the expected 354 code in the middle of the exchange. According to section 5.2.10 of RFC 1123 a smtp client must accept "any text, including no text at all" after the error code. If the response of a HELO command contains no text self.helo_resp will be set to the empty string (""). The patch fixes the test in the sendmail() method so that helo_resp is tested against None; if it has the empty string as value the sendmail() method would invoke the helo() method again. The code no longer accepts a -1 reply from the ehlo() method in sendmail(). [Text about removing SMTPRecipientsRefused deleted --GvR] """ and also: """ smtplib.py appends an extra blank line to the outgoing mail if the `msg' argument to the sendmail method already contains a trailing newline. This patch should fix the problem. """ The Dragon writes: """ Mostly I just re-added the SMTPRecipientsRefused exception (the exeption object now has the appropriate info in it ) [Per had removed this in his patch --GvR] and tweaked the behavior of the sendmail method whence it throws the newly added SMTPHeloException (it was closing the connection, which it shouldn't. whatever catches the exception should do that. ) I pondered the change of the return values to tuples all around, and after some thinking I decided that regularizing the return values was too much of the Right Thing (tm) to not do. My one concern is that code expecting an integer & getting a tuple may fail silently. (i.e. if it's doing : x.somemethod() >= 400: expecting an integer, the expression will always be true if it gets a tuple instead. ) However, most smtplib code I've seen only really uses the sendmail() method, so this wouldn't bother it. Usually code I've seen that calls the other methods usually only calls helo() and ehlo() for doing ESMTP, a feature which was not in the smtplib included with 1.5.1, and thus I would think not much code uses it yet. """ Tue Apr 6 19:38:18 1999 Guido van Rossum * Lib/test/test_ntpath.py: Fix the tests now that splitdrive() no longer treats UNC paths special. (Some tests converted to splitunc() tests.) * Lib/ntpath.py: Withdraw the UNC support from splitdrive(). Instead, a new function splitunc() parses UNC paths. The contributor of the UNC parsing in splitdrive() doesn't like it, but I haven't heard a good reason to keep it, and it causes some problems. (I think there's a philosophical problem -- to me, the split*() functions are purely syntactical, and the fact that \\foo is not a valid path doesn't mean that it shouldn't be considered an absolute path.) Also (quite separately, but strangely related to the philosophical issue above) fix abspath() so that if win32api exists, it doesn't fail when the path doesn't actually exist -- if GetFullPathName() fails, fall back on the old strategy (join with getcwd() if neccessary, and then use normpath()). * configure.in, configure, config.h.in, acconfig.h: For BeOS PowerPC. Chris Herborth. Mon Apr 5 21:54:14 1999 Guido van Rossum * Modules/timemodule.c: Jonathan Giddy notes, and Chris Lawrence agrees, that some comments on #else/#endif are wrong, and that #if HAVE_TM_ZONE should be #ifdef. * Misc/ACKS: Bunch of new contributors, including 9 who contributed to the Docs, reported by Fred. Mon Apr 5 18:37:59 1999 Fred Drake * Lib/gzip.py: Oops, missed mode parameter to open(). * Lib/gzip.py: Made the default mode 'rb' instead of 'r', for better cross-platform support. (Based on comment on the documentation by Bernhard Reiter ). Fri Apr 2 22:18:25 1999 Guido van Rossum * Tools/scripts/dutree.py: For reasons I dare not explain, this script should always execute main() when imported (in other words, it is not usable as a module). Thu Apr 1 15:32:30 1999 Guido van Rossum * Lib/test/test_cpickle.py: Jonathan Giddy write: In test_cpickle.py, the module os got imported, but the line to remove the temp file has gone missing. Tue Mar 30 20:17:31 1999 Guido van Rossum * Lib/BaseHTTPServer.py: Per Cederqvist writes: If you send something like "PUT / HTTP/1.0" to something derived from BaseHTTPServer that doesn't define do_PUT, you will get a response that begins like this: HTTP/1.0 501 Unsupported method ('do_PUT') Server: SimpleHTTP/0.3 Python/1.5 Date: Tue, 30 Mar 1999 18:53:53 GMT The server should complain about 'PUT' instead of 'do_PUT'. This patch should fix the problem. Mon Mar 29 20:33:21 1999 Guido van Rossum * Lib/smtplib.py: Patch by Per Cederqvist, who writes: """ - It needlessly used the makefile() method for each response that is read from the SMTP server. - If the remote SMTP server closes the connection unexpectedly the code raised an IndexError. It now raises an SMTPServerDisconnected exception instead. - The code now checks that all lines in a multiline response actually contains an error code. """ The Dragon approves. Mon Mar 29 20:25:40 1999 Fred Drake * Lib/compileall.py: When run as a script, report failures in the exit code as well. Patch largely based on changes by Andrew Dalke, as discussed in the distutils-sig. Mon Mar 29 20:23:41 1999 Guido van Rossum * Lib/urllib.py: Hack so that if a 302 or 301 redirect contains a relative URL, the right thing "just happens" (basejoin() with old URL). * Modules/cPickle.c: Protection against picling to/from closed (real) file. The problem was reported by Moshe Zadka. * Lib/test/test_cpickle.py: Test protection against picling to/from closed (real) file. * Modules/timemodule.c: Chris Lawrence writes: """ The GNU folks, in their infinite wisdom, have decided not to implement altzone in libc6; this would not be horrible, except that timezone (which is implemented) includes the current DST setting (i.e. timezone for Central is 18000 in summer and 21600 in winter). So Python's timezone and altzone variables aren't set correctly during DST. Here's a patch relative to 1.5.2b2 that (a) makes timezone and altzone show the "right" thing on Linux (by using the tm_gmtoff stuff available in BSD, which is how the GLIBC manual claims things should be done) and (b) should cope with the southern hemisphere. In pursuit of (b), I also took the liberty of renaming the "summer" and "winter" variables to "july" and "jan". This patch should also make certain time calculations on Linux actually work right (like the tz-aware functions in the rfc822 module). (It's hard to find DST that's currently being used in the southern hemisphere; I tested using Africa/Windhoek.) """ * Lib/test/output/test_gzip: Jonathan Giddy discovered this file was missing. * Modules/shamodule.c: Avoid warnings from AIX compiler. Reported by Vladimir (AIX is my middlename) Marangozov, patch coded by Greg Stein. * Tools/idle/ScriptBinding.py, Tools/idle/PyShell.py: At Tim Peters' recommendation, add a dummy flush() method to PseudoFile. Sun Mar 28 17:55:32 1999 Guido van Rossum * Tools/scripts/ndiff.py: Tim Peters writes: I should have waited overnight . Nothing wrong with the one I sent, but I couldn't resist going on to add new -r1 / -r2 cmdline options for recreating the original files from ndiff's output. That's attached, if you're game! Us Windows guys don't usually have a sed sitting around . Sat Mar 27 13:34:01 1999 Guido van Rossum * Tools/scripts/ndiff.py: Tim Peters writes: Attached is a cleaned-up version of ndiff (added useful module docstring, now echo'ed in case of cmd line mistake); added -q option to suppress initial file identification lines; + other minor cleanups, & a slightly faster match engine. Fri Mar 26 22:36:00 1999 Fred Drake * Tools/scripts/dutree.py: During display, if EPIPE is raised, it's probably because a pager was killed. Discard the error in that case, but propogate it otherwise. Fri Mar 26 16:20:45 1999 Guido van Rossum * Lib/test/output/test_userlist, Lib/test/test_userlist.py: Test suite for UserList. * Lib/UserList.py: Use isinstance() where appropriate. Reformatted with 4-space indent. Fri Mar 26 16:11:40 1999 Barry Warsaw * Tools/pynche/PyncheWidget.py: Helpwin.__init__(): The text widget should get focus. * Tools/pynche/pyColorChooser.py: Removed unnecessary import `from PyncheWidget import PyncheWidget' Fri Mar 26 15:32:05 1999 Guido van Rossum * Lib/test/output/test_userdict, Lib/test/test_userdict.py: Test suite for UserDict * Lib/UserDict.py: Improved a bunch of things. The constructor now takes an optional dictionary. Use isinstance() where appropriate. Thu Mar 25 22:38:49 1999 Guido van Rossum * Lib/test/output/test_pickle, Lib/test/output/test_cpickle, Lib/test/test_pickle.py, Lib/test/test_cpickle.py: Basic regr tests for pickle/cPickle * Lib/pickle.py: Don't use "exec" in find_class(). It's slow, unnecessary, and (as AMK points out) it doesn't work in JPython Applets. Thu Mar 25 21:50:27 1999 Andrew Kuchling * Lib/test/test_gzip.py: Added a simple test suite for gzip. It simply opens a temp file, writes a chunk of compressed data, closes it, writes another chunk, and reads the contents back to verify that they are the same. * Lib/gzip.py: Based on a suggestion from bruce@hams.com, make a trivial change to allow using the 'a' flag as a mode for opening a GzipFile. gzip files, surprisingly enough, can be concatenated and then decompressed; the effect is to concatenate the two chunks of data. If we support it on writing, it should also be supported on reading. This *wasn't* trivial, and required rearranging the code in the reading path, particularly the _read() method. Raise IOError instead of RuntimeError in two cases, 'Not a gzipped file' and 'Unknown compression method' Thu Mar 25 21:25:01 1999 Guido van Rossum * Lib/test/test_b1.py: Add tests for float() and complex() with string args (Nick/Stephanie Lockwood). Thu Mar 25 21:21:08 1999 Andrew Kuchling * Modules/zlibmodule.c: Add an .unused_data attribute to decompressor objects. If .unused_data is not an empty string, this means that you have arrived at the end of the stream of compressed data, and the contents of .unused_data are whatever follows the compressed stream. Thu Mar 25 21:16:07 1999 Guido van Rossum * Python/bltinmodule.c: Patch by Nick and Stephanie Lockwood to implement complex() with a string argument. This closes TODO item 2.19. Wed Mar 24 19:09:00 1999 Guido van Rossum * Tools/webchecker/wcnew.py: Added Samuel Bayer's new webchecker. Unfortunately his code breaks wcgui.py in a way that's not easy to fix. I expect that this is a temporary situation -- eventually Sam's changes will be merged back in. (The changes add a -t option to specify exceptions to the -x option, and explicit checking for #foo style fragment ids.) * Objects/dictobject.c: Vladimir Marangozov contributed updated comments. * Objects/bufferobject.c: Folded long lines. * Lib/test/output/test_sha, Lib/test/test_sha.py: Added Jeremy's test code for the sha module. * Modules/shamodule.c, Modules/Setup.in: Added Greg Stein and Andrew Kuchling's sha module. Fix comments about zlib version and URL. * Lib/test/test_bsddb.py: Remove the temp file when we're done. * Include/pythread.h: Conform to standard boilerplate. * configure.in, configure, BeOS/linkmodule, BeOS/ar-fake: Chris Herborth: the new compiler in R4.1 needs some new options to work... * Modules/socketmodule.c: Implement two suggestions by Jonathan Giddy: (1) in AIX, clear the data struct before calling gethostby{name,addr}_r(); (2) ignore the 3/5/6 args determinations made by the configure script and switch on platform identifiers instead: AIX, OSF have 3 args Sun, SGI have 5 args Linux has 6 args On all other platforms, undef HAVE_GETHOSTBYNAME_R altogether. * Modules/socketmodule.c: Vladimir Marangozov implements the AIX 3-arg gethostbyname_r code. * Lib/mailbox.py: Add readlines() to _Subfile class. Not clear who would need it, but Chris Lawrence sent me a broken version; this one is a tad simpler and more conforming to the standard. Tue Mar 23 23:05:34 1999 Jeremy Hylton * Lib/gzip.py: use struct instead of bit-manipulate in Python Tue Mar 23 19:00:55 1999 Guido van Rossum * Modules/Makefile.pre.in: Add $(EXE) to various occurrences of python so it will work on Cygwin with egcs (after setting EXE=.exe). Patch by Norman Vine. * configure, configure.in: Ack! It never defined HAVE_GETHOSTBYNAME_R so that code was never tested! Mon Mar 22 22:25:39 1999 Guido van Rossum * Include/thread.h: Adding thread.h -- unused but for b/w compatibility. As requested by Bill Janssen. * configure.in, configure: Add code to test for all sorts of gethostbyname_r variants, donated by David Arnold. * config.h.in, acconfig.h: Add symbols for gethostbyname_r variants (sigh). * Modules/socketmodule.c: Clean up pass for the previous patches. - Use HAVE_GETHOSTBYNAME_R_6_ARG instead of testing for Linux and glibc2. - If gethostbyname takes 3 args, undefine HAVE_GETHOSTBYNAME_R -- don't know what code should be used. - New symbol USE_GETHOSTBYNAME_LOCK defined iff the lock should be used. - Modify the gethostbyaddr() code to also hold on to the lock until after it is safe to release, overlapping with the Python lock. (Note: I think that it could in theory be possible that Python code executed while gethostbyname_lock is held could attempt to reacquire the lock -- e.g. in a signal handler or destructor. I will simply say "don't do that then.") * Modules/socketmodule.c: Jonathan Giddy writes: Here's a patch to fix the race condition, which wasn't fixed by Rob's patch. It holds the gethostbyname lock until the results are copied out, which means that this lock and the Python global lock are held at the same time. This shouldn't be a problem as long as the gethostbyname lock is always acquired when the global lock is not held. Mon Mar 22 19:25:30 1999 Andrew Kuchling * Modules/zlibmodule.c: Fixed the flush() method of compression objects; the test for the end of loop was incorrect, and failed when the flushmode != Z_FINISH. Logic cleaned up and commented. * Lib/test/test_zlib.py: Added simple test for the flush() method of compression objects, trying the different flush values Z_NO_FLUSH, Z_SYNC_FLUSH, Z_FULL_FLUSH. Mon Mar 22 15:28:08 1999 Guido van Rossum * Lib/shlex.py: Bug reported by Tobias Thelen: missing "self." in assignment target. Fri Mar 19 21:50:11 1999 Guido van Rossum * Modules/arraymodule.c: Use an unsigned cast to avoid a warning in VC++. * Lib/dospath.py, Lib/ntpath.py: New code for split() by Tim Peters, behaves more like posixpath.split(). * Objects/floatobject.c: Fix a problem with Vladimir's PyFloat_Fini code: clear the free list; if a block cannot be freed, add its free items back to the free list. This is necessary to avoid leaking when Python is reinitialized later. * Objects/intobject.c: Fix a problem with Vladimir's PyInt_Fini code: clear the free list; if a block cannot be freed, add its free items back to the free list, and add its valid ints back to the small_ints array if they are in range. This is necessary to avoid leaking when Python is reinitialized later. * Lib/types.py: Added BufferType, the type returned by the new builtin buffer(). Greg Stein. * Python/bltinmodule.c: New builtin buffer() creates a derived read-only buffer from any object that supports the buffer interface (e.g. strings, arrays). * Objects/bufferobject.c: Added check for negative offset for PyBuffer_FromObject and check for negative size for PyBuffer_FromMemory. Greg Stein. Thu Mar 18 15:10:44 1999 Guido van Rossum * Lib/urlparse.py: Sjoerd Mullender writes: If a filename on Windows starts with \\, it is converted to a URL which starts with ////. If this URL is passed to urlparse.urlparse you get a path that starts with // (and an empty netloc). If you pass the result back to urlparse.urlunparse, you get a URL that starts with //, which is parsed differently by urlparse.urlparse. The fix is to add the (empty) netloc with accompanying slashes if the path in urlunparse starts with //. Do this for all schemes that use a netloc. * Lib/nturl2path.py: Sjoerd Mullender writes: Pathnames of files on other hosts in the same domain (\\host\path\to\file) are not translated correctly to URLs and back. The URL should be something like file:////host/path/to/file. Note that a combination of drive letter and remote host is not possible. Wed Mar 17 22:30:10 1999 Guido van Rossum * Lib/urlparse.py: Delete non-standard-conforming code in urljoin() that would use the netloc from the base url as the default netloc for the resulting url even if the schemes differ. Once upon a time, when the web was wild, this was a valuable hack because some people had a URL referencing an ftp server colocated with an http server without having the host in the ftp URL (so they could replicate it or change the hostname easily). More recently, after the file: scheme got added back to the list of schemes that accept a netloc, it turns out that this caused weirdness when joining an http: URL with a file: URL -- the resulting file: URL would always inherit the host from the http: URL because the file: scheme supports a netloc but in practice never has one. There are two reasons to get rid of the old, once-valuable hack, instead of removing the file: scheme from the uses_netloc list. One, the RFC says that file: uses the netloc syntax, and does not endorse the old hack. Two, neither netscape 4.5 nor IE 4.0 support the old hack. * Include/ceval.h, Include/abstract.h: Add DLL level b/w compat for PySequence_In and PyEval_CallObject Tue Mar 16 21:54:50 1999 Guido van Rossum * Lib/lib-tk/Tkinter.py: Bug reported by Jim Robinson: An attempt to execute grid_slaves with arguments (0,0) results in *all* of the slaves being returned, not just the slave associated with row 0, column 0. This is because the test for arguments in the method does not test to see if row (and column) does not equal None, but rather just whether is evaluates to non-false. A value of 0 fails this test. Tue Mar 16 14:17:48 1999 Fred Drake * Modules/cmathmodule.c: Docstring fix: acosh() returns the hyperbolic arccosine, not the hyperbolic cosine. Problem report via David Ascher by one of his students. Mon Mar 15 21:40:59 1999 Guido van Rossum * configure.in: Should test for gethost*by*name_r, not for gethostname_r (which doesn't exist and doesn't make sense). * Modules/socketmodule.c: Patch by Rob Riggs for Linux -- glibc2 has a different argument converntion for gethostbyname_r() etc. than Solaris! * Python/thread_pthread.h: Rob Riggs wrote: """ Spec says that on success pthread_create returns 0. It does not say that an error code will be < 0. Linux glibc2 pthread_create() returns ENOMEM (12) when one exceed process limits. (It looks like it should return EAGAIN, but that's another story.) For reference, see: http://www.opengroup.org/onlinepubs/7908799/xsh/pthread_create.html """ [I have a feeling that similar bugs were fixed before; perhaps someone could check that all error checks no check for != 0?] * Tools/bgen/bgen/bgenObjectDefinition.py: New mixin class that defines cmp and hash that use the ob_itself pointer. This allows (when using the mixin) different Python objects pointing to the same C object and behaving well as dictionary keys. Or so sez Jack Jansen... * Lib/urllib.py: Yet another patch by Sjoerd Mullender: Don't convert URLs to URLs using pathname2url. Fri Mar 12 22:15:43 1999 Guido van Rossum * Lib/cmd.py: Patch by Michael Scharf. He writes: The module cmd requires for each do_xxx command a help_xxx function. I think this is a little old fashioned. Here is a patch: use the docstring as help if no help_xxx function can be found. [I'm tempted to rip out all the help_* functions from pdb, but I'll resist it. Any takers? --Guido] * Tools/freeze/freeze.py: Bug submitted by Wayne Knowles, who writes: Under Windows, python freeze.py -o hello hello.py creates all the correct files in the hello subdirectory, but the Makefile has the directory prefix in it for frozen_extensions.c nmake fails because it tries to locate hello/frozen_extensions.c (His fix adds a call to os.path.basename() in the appropriate place.) * Objects/floatobject.c, Objects/intobject.c: Vladimir has restructured his code somewhat so that the blocks are now represented by an explicit structure. (There are still too many casts in the code, but that may be unavoidable.) Also added code so that with -vv it is very chatty about what it does. * Demo/zlib/zlibdemo.py, Demo/zlib/minigzip.py: Change #! line to modern usage; also chmod +x * Demo/pdist/rrcs, Demo/pdist/rcvs, Demo/pdist/rcsbump: Change #! line to modern usage * Lib/nturl2path.py, Lib/urllib.py: From: Sjoerd Mullender The filename to URL conversion didn't properly quote special characters. The URL to filename didn't properly unquote special chatacters. * Objects/floatobject.c: OK, try again. Vladimir gave me a fix for the alignment bus error, so here's his patch again. This time it works (at least on Solaris, Linux and Irix). Thu Mar 11 23:21:23 1999 Guido van Rossum * Tools/idle/PathBrowser.py: Don't crash when sys.path contains an empty string. * Tools/idle/PathBrowser.py: - Don't crash in the case where a superclass is a string instead of a pyclbr.Class object; this can happen when the superclass is unrecognizable (to pyclbr), e.g. when module renaming is used. - Show a watch cursor when calling pyclbr (since it may take a while recursively parsing imported modules!). Thu Mar 11 16:04:04 1999 Fred Drake * Lib/mimetypes.py: Added .rdf and .xsl as application/xml types. (.rdf is for the Resource Description Framework, a metadata encoding, and .xsl is for the Extensible Stylesheet Language.) Thu Mar 11 13:26:23 1999 Guido van Rossum * Lib/test/output/test_popen2, Lib/test/test_popen2.py: Test for popen2 module, by Chris Tismer. * Objects/floatobject.c: Alas, Vladimir's patch caused a bus error (probably double alignment?), and I didn't test it. Withdrawing it for now. Wed Mar 10 22:55:47 1999 Guido van Rossum * Objects/floatobject.c: Patch by Vladimir Marangoz to allow freeing of the allocated blocks of floats on finalization. * Objects/intobject.c: Patch by Vladimir Marangoz to allow freeing of the allocated blocks of integers on finalization. * Tools/idle/EditorWindow.py, Tools/idle/Bindings.py: Add PathBrowser to File module * Tools/idle/PathBrowser.py: "Path browser" - 4 scrolled lists displaying: directories on sys.path modules in selected directory classes in selected module methods of selected class Sinlge clicking in a directory, module or class item updates the next column with info about the selected item. Double clicking in a module, class or method item opens the file (and selects the clicked item if it is a class or method). I guess eventually I should be using a tree widget for this, but the ones I've seen don't work well enough, so for now I use the old Smalltalk or NeXT style multi-column hierarchical browser. * Tools/idle/MultiScrolledLists.py: New utility: multiple scrolled lists in parallel * Tools/idle/ScrolledList.py: - White background. - Display "(None)" (or text of your choosing) when empty. - Don't set the focus. Tue Mar 9 19:31:21 1999 Guido van Rossum * Lib/urllib.py: open_http also had the 'data is None' test backwards. don't call with the extra argument if data is None. * Demo/embed/demo.c: Call Py_SetProgramName() instead of redefining getprogramname(), reflecting changes in the runtime around 1.5 or earlier. * Python/ceval.c: Always test for an error return (usually NULL or -1) without setting an exception. * Modules/timemodule.c: Patch by Chris Herborth for BeOS code. He writes: I had an off-by-1000 error in floatsleep(), and the problem with time.clock() is that it's not implemented properly on QNX... ANSI says it's supposed to return _CPU_ time used by the process, but on QNX it returns the amount of real time used... so I was confused. * Tools/bgen/bgen/macsupport.py: Small change by Jack Jansen. Test for self.returntype behaving like OSErr rather than being it. Thu Feb 25 16:14:58 1999 Jeremy Hylton * Lib/urllib.py: http_error had the 'data is None' test backwards. don't call with the extra argument if data is None. * Lib/urllib.py: change indentation from 8 spaces to 4 spaces * Lib/urllib.py: pleasing the tabnanny Thu Feb 25 14:26:02 1999 Fred Drake * Lib/colorsys.py: Oops, one more "x, y, z" to convert... * Lib/colorsys.py: Adjusted comment at the top to be less confusing, following Fredrik Lundh's example. Converted comment to docstring. Wed Feb 24 18:49:15 1999 Fred Drake * Lib/toaiff.py: Use sndhdr instead of the obsolete whatsound module. Wed Feb 24 18:42:38 1999 Jeremy Hylton * Lib/urllib.py: When performing a POST request, i.e. when the second argument to urlopen is used to specify form data, make sure the second argument is threaded through all of the http_error_NNN calls. This allows error handlers like the redirect and authorization handlers to properly re-start the connection. Wed Feb 24 16:25:17 1999 Guido van Rossum * Lib/mhlib.py: Patch by Lars Wirzenius: o the initial comment is wrong: creating messages is already implemented o Message.getbodytext: if the mail or it's part contains an empty content-transfer-encoding header, the code used to break; the change below treats an empty encoding value the same as the other types that do not need decoding o SubMessage.getbodytext was missing the decode argument; the change below adds it; I also made it unconditionally return the raw text if decoding was not desired, because my own routines needed that (and it was easier than rewriting my own routines ;-) Wed Feb 24 00:35:43 1999 Barry Warsaw * Python/bltinmodule.c (initerrors): Make sure that the exception tuples ("base-classes" when string-based exceptions are used) reflect the real class hierarchy, i.e. that SystemExit derives from Exception not StandardError. * Lib/exceptions.py: Document the correct class hierarchy for SystemExit. It is not an error and so it derives from Exception and not SystemError. The docstring was incorrect but the implementation was fine. Tue Feb 23 23:07:51 1999 Guido van Rossum * Lib/shutil.py: Add import sys, needed by reference to sys.exc_info() in rmtree(). Discovered by Mitch Chapman. * config.h.in: Now that we don't have AC_CHECK_LIB(m, pow), the HAVE_LIBM symbol disappears. It wasn't used anywhere anyway... * Modules/arraymodule.c: Carefully check for overflow when allocating the memory for fromfile -- someone tried to pass in sys.maxint and got bitten by the bogus calculations. * configure.in: Get rid of AC_CHECK_LIB(m, pow) since this is taken care of later with LIBM (from --with-libm=...); this actually broke the customizability offered by the latter option. Thanks go to Clay Spence for reporting this. * Lib/test/test_dl.py: 1. Print the error message (carefully) when a dl.open() fails in verbose mode. 2. When no test case worked, raise ImportError instead of failing. * Python/bltinmodule.c: Patch by Tim Peters to improve the range checks for range() and xrange(), especially for platforms where int and long are different sizes (so sys.maxint isn't actually the theoretical limit for the length of a list, but the largest C int is -- sys.maxint is the largest Python int, which is actually a C long). * Makefile.in: 1. Augment the DG/UX rule so it doesn't break the BeOS build. 2. Add $(EXE) to various occurrences of python so it will work on Cygwin with egcs (after setting EXE=.exe). These patches by Norman Vine. * Lib/posixfile.py: According to Jeffrey Honig, bsd/os 2.0 - 4.0 should be added to the list (of bsd variants that have a different lock structure). * Lib/test/test_fcntl.py: According to Jeffrey Honig, bsd/os 4.0 should be added to the list. * Modules/timemodule.c: Patch by Tadayoshi Funaba (with some changes) to be smarter about guessing what happened when strftime() returns 0. Is it buffer overflow or was the result simply 0 bytes long? (This happens for an empty format string, or when the format string is a single %Z and the timezone is unknown.) if the buffer is at least 256 times as long as the format, assume the latter. Mon Feb 22 19:01:42 1999 Guido van Rossum * Lib/urllib.py: As Des Barry points out, we need to call pathname2url(file) in two calls to addinfourl() in open_file(). * Modules/Setup.in: Document *static* -- in two places! * Modules/timemodule.c: We don't support leap seconds, so the seconds field of a time 9-tuple should be in the range [0-59]. Noted by Tadayoshi Funaba. * Modules/stropmodule.c: In atoi(), don't use isxdigit() to test whether the last character converted was a "digit" -- use isalnum(). This test is there only to guard against "+" or "-" being interpreted as a valid int literal. Reported by Takahiro Nakayama. * Lib/os.py: As Finn Bock points out, _P_WAIT etc. don't have a leading underscore so they don't need to be treated specially here. Mon Feb 22 15:38:58 1999 Fred Drake * Misc/NEWS: Typo: "apparentlt" --> "apparently" Mon Feb 22 15:38:46 1999 Guido van Rossum * Lib/urlparse.py: Steve Clift pointed out that 'file' allows a netloc. * Modules/posixmodule.c: The docstring for ttyname(..) claims a second "mode" argument. The actual code does not allow such an argument. (Finn Bock.) * Lib/lib-old/poly.py: Dang. Even though this is obsolete code, somebody found a bug, and I fix it. Oh well. Thu Feb 18 20:51:50 1999 Fred Drake * Lib/pyclbr.py: Bow to font-lock at the end of the docstring, since it throws stuff off. Make sure the path paramter to readmodule() is a list before adding it with sys.path, or the addition could fail. ====================================================================== From 1.5.2b1 to 1.5.2b2 ======================= General ------- - Many memory leaks fixed. - Many small bugs fixed. - Command line option -OO (or -O -O) suppresses inclusion of doc strings in resulting bytecode. Windows-specific changes ------------------------ - New built-in module winsound provides an interface to the Win32 PlaySound() call. - Re-enable the audioop module in the config.c file. - On Windows, support spawnv() and associated P_* symbols. - Fixed the conversion of times() return values on Windows. - Removed freeze from the installer -- it doesn't work without the source tree. (See FAQ 8.11.) - On Windows 95/98, the Tkinter module now is smart enough to find Tcl/Tk even when the PATH environment variable hasn't been set -- when the import of _tkinter fails, it searches in a standard locations, patches os.environ["PATH"], and tries again. When it still fails, a clearer error message is produced. This should avoid most installation problems with Tkinter use (e.g. in IDLE). - The -i option doesn't make any calls to set[v]buf() for stdin -- this apparently screwed up _kbhit() and the _tkinter main loop. - The ntpath module (and hence, os.path on Windows) now parses out UNC paths (e.g. \\host\mountpoint\dir\file) as "drive letters", so that splitdrive() will \\host\mountpoint as the drive and \dir\file as the path. ** EXPERIMENTAL ** - Added a hack to the exit code so that if (1) the exit status is nonzero and (2) we think we have our own DOS box (i.e. we're not started from a command line shell), we print a message and wait for the user to hit a key before the DOS box is closed. - Updated the installer to WISE 5.0g. Added a dialog warning about the imminent Tcl installation. Added a dialog to specify the program group name in the start menu. Upgraded the Tcl installer to Tcl 8.0.4. Changes to intrinsics --------------------- - The repr() or str() of a module object now shows the __file__ attribute (i.e., the file which it was loaded), or the string "(built-in)" if there is no __file__ attribute. - The range() function now avoids overflow during its calculations (if at all possible). - New info string sys.hexversion, which is an integer encoding the version in hexadecimal. In other words, hex(sys.hexversion) == 0x010502b2 for Python 1.5.2b2. New or improved ports --------------------- - Support for Nextstep descendants (future Mac systems). - Improved BeOS support. - Support dynamic loading of shared libraries on NetBSD platforms that use ELF (i.e., MIPS and Alpha systems). Configuration/build changes --------------------------- - The Lib/test directory is no longer included in the default module search path (sys.path) -- "test" has been a package ever since 1.5. - Now using autoconf 2.13. New library modules ------------------- - New library modules asyncore and asynchat: these form Sam Rushing's famous asynchronous socket library. Sam has gracefully allowed me to incorporate these in the standard Python library. - New module statvfs contains indexing constants for [f]statvfs() return tuple. Changes to the library ---------------------- - The wave module (platform-independent support for Windows sound files) has been fixed to actually make it work. - The sunau module (platform-independent support for Sun/NeXT sound files) has been fixed to work across platforms. Also, a weird encoding bug in the header of the audio test data file has been corrected. - Fix a bug in the urllib module that occasionally tripped up webchecker and other ftp retrieves. - ConfigParser's get() method now accepts an optional keyword argument (vars) that is substituted on top of the defaults that were setup in __init__. You can now also have recusive references in your configuration file. - Some improvements to the Queue module, including a put_nowait() module and an optional "block" second argument, to get() and put(), defaulting to 1. - The updated xmllib module is once again compatible with the version present in Python 1.5.1 (this was accidentally broken in 1.5.2b1). - The bdb module (base class for the debugger) now supports canonicalizing pathnames used in breakpoints. The derived class must override the new canonical() method for this to work. Also changed clear_break() to the backwards compatible old signature, and added clear_bpbynumber() for the new functionality. - In sgmllib (and hence htmllib), recognize attributes even if they don't have space in front of them. I.e. '' will now have two attributes recognized. - In the debugger (pdb), change clear syntax to support three alternatives: clear; clear file:line; clear bpno bpno ... - The os.path module now pretends to be a submodule within the os "package", so you can do things like "from os.path import exists". - The standard exceptions now have doc strings. - In the smtplib module, exceptions are now classes. Also avoid inserting a non-standard space after "TO" in rcpt() command. - The rfc822 module's getaddrlist() method now uses all occurrences of the specified header instead of just the first. Some other bugfixes too (to handle more weird addresses found in a very large test set, and to avoid crashes on certain invalid dates), and a small test module has been added. - Fixed bug in urlparse in the common-case code for HTTP URLs; it would lose the query, fragment, and/or parameter information. - The sndhdr module no longer supports whatraw() -- it depended on a rare extenral program. - The UserList module/class now supports the extend() method, like real list objects. - The uu module now deals better with trailing garbage generated by some broke uuencoders. - The telnet module now has an my_interact() method which uses threads instead of select. The interact() method uses this by default on Windows (where the single-threaded version doesn't work). - Add a class to mailbox.py for dealing with qmail directory mailboxes. The test code was extended to notice these being used as well. Changes to extension modules ---------------------------- - Support for the [f]statvfs() system call, where it exists. - Fixed some bugs in cPickle where bad input could cause it to dump core. - Fixed cStringIO to make the writelines() function actually work. - Added strop.expandtabs() so string.expandtabs() is now much faster. - Added fsync() and fdatasync(), if they appear to exist. - Support for "long files" (64-bit seek pointers). - Fixed a bug in the zlib module's flush() function. - Added access() system call. It returns 1 if access granted, 0 if not. - The curses module implements an optional nlines argument to w.scroll(). (It then calls wscrl(win, nlines) instead of scoll(win).) Changes to tools ---------------- - Some changes to IDLE; see Tools/idle/NEWS.txt. - Latest version of Misc/python-mode.el included. Changes to Tkinter ------------------ - Avoid tracebacks when an image is deleted after its root has been destroyed. Changes to the Python/C API --------------------------- - When parentheses are used in a PyArg_Parse[Tuple]() call, any sequence is now accepted, instead of requiring a tuple. This is in line with the general trend towards accepting arbitrary sequences. - Added PyModule_GetFilename(). - In PyNumber_Power(), remove unneeded and even harmful test for float to the negative power (which is already and better done in floatobject.c). - New version identification symbols; read patchlevel.h for info. The version numbers are now exported by Python.h. - Rolled back the API version change -- it's back to 1007! - The frozenmain.c function calls PyInitFrozenExtensions(). - Added 'N' format character to Py_BuildValue -- like 'O'