What's new in this release? =========================== Below is a list of all relevant changes since release 1.5.1. Older changes are in the file HISTORY. The most recent changes are listed first. A note on attributions: while I have sprinkled some names throughout here, I'm grateful to many more people who remain unnamed. You may find your name in the ACKS file. If you believe you deserve more credit, let me know and I'll add you to the list! ====================================================================== 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' but doesn't INCREF. ====================================================================== From 1.5.2a2 to 1.5.2b1 ======================= Changes to intrinsics --------------------- - New extension NotImplementedError, derived from RuntimeError. Not used, but recommended use is for "abstract" methods to raise this. - The parser will now spit out a warning or error when -t or -tt is used for parser input coming from a string, too. - The code generator now inserts extra SET_LINENO opcodes when compiling multi-line argument lists. - When comparing bound methods, use identity test on the objects, not equality test. New or improved ports --------------------- - Chris Herborth has redone his BeOS port; it now works on PowerPC (R3/R4) and x86 (R4 only). Threads work too in this port. Renaming -------- - Thanks to Chris Herborth, the thread primitives now have proper Py* names in the source code (they already had those for the linker, through some smart macros; but the source still had the old, un-Py names). Configuration/build changes --------------------------- - Improved support for FreeBSD/3. - Check for pthread_detach instead of pthread_create in libc. - The makesetup script now searches EXECINCLUDEPY before INCLUDEPY. - Misc/Makefile.pre.in now also looks at Setup.thread and Setup.local. Otherwise modules such as thread didn't get incorporated in extensions. New library modules ------------------- - shlex.py by Eric Raymond provides a lexical analyzer class for simple shell-like syntaxes. - netrc.py by Eric Raymond provides a parser for .netrc files. (The undocumented Netrc class in ftplib.py is now obsolete.) - codeop.py is a new module that contains the compile_command() function that was previously in code.py. This is so that JPython can provide its own version of this function, while still sharing the higher-level classes in code.py. - turtle.py is a new module for simple turtle graphics. I'm still working on it; let me know if you use this to teach Python to children or other novices without prior programming experience. Obsoleted library modules ------------------------- - poly.py and zmod.py have been moved to Lib/lib-old to emphasize their status of obsoleteness. They don't do a particularly good job and don't seem particularly relevant to the Python core. New tools --------- - I've added IDLE: my Integrated DeveLopment Environment for Python. Requires Tcl/Tk (and Tkinter). Works on Windows and Unix (and should work on Macintosh, but I haven't been able to test it there; it does depend on new features in 1.5.2 and perhaps even new features in 1.5.2b1, especially the new code module). This is very much a work in progress. I'd like to hear how people like it compared to PTUI (or any other IDE they are familiar with). - New tools by Barry Warsaw: = audiopy: controls the Solaris Audio device = pynche: The PYthonically Natural Color and Hue Editor = world: Print mappings between country names and DNS country codes New demos --------- - Demo/scripts/beer.py prints the lyrics to an arithmetic drinking song. - Demo/tkinter/guido/optionmenu.py shows how to do an option menu in Tkinter. (By Fredrik Lundh -- not by me!) Changes to the library ---------------------- - compileall.py now avoids recompiling .py files that haven't changed; it adds a -f option to force recompilation. - New version of xmllib.py by Sjoerd Mullender (0.2 with latest patches). - nntplib.py: statparse() no longer lowercases the message-id. - types.py: use type(__stdin__) for FileType. - urllib.py: fix translations for filenames with "funny" characters. Patch by Sjoerd Mullender. Note that if you subclass one of the URLopener classes, and you have copied code from the old urllib.py, your subclass may stop working. A long-term solution is to provide more methods so that you don't have to copy code. - cgi.py: In read_multi, allow a subclass to override the class we instantiate when we create a recursive instance, by setting the class variable 'FieldStorageClass' to the desired class. By default, this is set to None, in which case we use self.__class__ (as before). Also, a patch by Jim Fulton to pass additional arguments to recursive calls to the FieldStorage constructor from its read_multi method. - UserList.py: In __getslice__, use self.__class__ instead of UserList. - In SimpleHTTPServer.py, the server specified in test() should be BaseHTTPServer.HTTPServer, in case the request handler should want to reference the two attributes added by BaseHTTPServer.server_bind. (By Jeff Rush, for Bobo). Also open the file in binary mode, so serving images from a Windows box might actually work. - In CGIHTTPServer.py, the list of acceptable formats is -split- on spaces but -joined- on commas, resulting in double commas in the joined text. (By Jeff Rush.) - SocketServer.py, patch by Jeff Bauer: a minor change to declare two new threaded versions of Unix Server classes, using the ThreadingMixIn class: ThreadingUnixStreamServer, ThreadingUnixDatagramServer. - bdb.py: fix bomb on deleting a temporary breakpoint: there's no method do_delete(); do_clear() was meant. By Greg Ward. - getopt.py: accept a non-list sequence for the long options (request by Jack Jansen). Because it might be a common mistake to pass a single string, this situation is treated separately. Also added docstrings (copied from the library manual) and removed the (now redundant) module comments. - tempfile.py: improvements to avoid security leaks. - code.py: moved compile_command() to new module codeop.py. - pickle.py: support pickle format 1.3 (binary float added). By Jim Fulton. Also get rid of the undocumented obsolete Pickler dump_special method. - uu.py: Move 'import sys' to top of module, as noted by Tim Peters. - imaplib.py: fix problem with some versions of IMAP4 servers that choose to mix the case in their CAPABILITIES response. - cmp.py: use (f1, f2) as cache key instead of f1 + ' ' + f2. Noted by Fredrik Lundh. Changes to extension modules ---------------------------- - More doc strings for several modules were contributed by Chris Petrilli: math, cmath, fcntl. - Fixed a bug in zlibmodule.c that could cause core dumps on decompression of rarely occurring input. - cPickle.c: new version from Jim Fulton, with Open Source copyright notice. Also, initialize self->safe_constructors early on to prevent crash in early dealloc. - cStringIO.c: new version from Jim Fulton, with Open Source copyright notice. Also fixed a core dump in cStringIO.c when doing seeks. - mpzmodule.c: fix signed character usage in mpz.mpz(stringobjecty). - readline.c: Bernard Herzog pointed out that rl_parse_and_bind modifies its argument string (bad function!), so we make a temporary copy. - sunaudiodev.c: Barry Warsaw added more smarts to get the device and control pseudo-device, per audio(7I). Changes to tools ---------------- - New, improved version of Barry Warsaw's Misc/python-mode.el (editing support for Emacs). - tabnanny.py: added a -q ('quiet') option to tabnanny, which causes only the names of offending files to be printed. - freeze: when printing missing modules, also print the module they were imported from. - untabify.py: patch by Detlef Lannert to implement -t option (set tab size). Changes to Tkinter ------------------ - grid_bbox(): support new Tk API: grid bbox ?column row? ?column2 row2? - _tkinter.c: RajGopal Srinivasan noted that the latest code (1.5.2a2) doesn't work when running in a non-threaded environment. He added some #ifdefs that fix this. Changes to the Python/C API --------------------------- - Bumped API version number to 1008 -- enough things have changed! - There's a new macro, PyThreadState_GET(), which does the same work as PyThreadState_Get() without the overhead of a function call (it also avoids the error check). The two top calling locations of PyThreadState_Get() have been changed to use this macro. - All symbols intended for export from a DLL or shared library are now marked as such (with the DL_IMPORT() macro) in the header file that declares them. This was needed for the BeOS port, and should also make some other ports easier. The PC port no longer needs the file with exported symbols (PC/python_nt.def). There's also a DL_EXPORT macro which is only used for init methods in extension modules, and for Py_Main(). Invisible changes to internals ------------------------------ - Fixed a bug in new_buffersize() in fileobject.c which could return a buffer size that was way too large. - Use PySys_WriteStderr instead of fprintf in most places. - dictobject.c: remove dead code discovered by Vladimir Marangozov. - tupleobject.c: make tuples less hungry -- an extra item was allocated but never used. Tip by Vladimir Marangozov. - mymath.h: Metrowerks PRO4 finally fixes the hypot snafu. (Jack Jansen) - import.c: Jim Fulton fixes a reference count bug in PyEval_GetGlobals. - glmodule.c: check in the changed version after running the stubber again -- this solves the conflict with curses over the 'clear' entry point much nicer. (Jack Jansen had checked in the changes to cstubs eons ago, but I never regenrated glmodule.c :-( ) - frameobject.c: fix reference count bug in PyFrame_New. Vladimir Marangozov. - stropmodule.c: add a missing DECREF in an error exit. Submitted by Jonathan Giddy. ====================================================================== From 1.5.2a1 to 1.5.2a2 ======================= General ------- - It is now a syntax error to have a function argument without a default following one with a default. - __file__ is now set to the .py file if it was parsed (it used to always be the .pyc/.pyo file). - Don't exit with a fatal error during initialization when there's a problem with the exceptions.py module. - New environment variable PYTHONOPTIMIZE can be used to set -O. - New version of python-mode.el for Emacs. Miscellaneous fixed bugs ------------------------ - No longer print the (confusing) error message about stack underflow while compiling. - Some threading and locking bugs fixed. - When errno is zero, report "Error", not "Success". Documentation ------------- - Documentation will be released separately. - Doc strings added to array and md5 modules by Chris Petrilli. Ports and build procedure ------------------------- - Stop installing when a move or copy fails. - New version of the OS/2 port code by Jeff Rush. - The makesetup script handles absolute filenames better. - The 'new' module is now enabled by default in the Setup file. - I *think* I've solved the problem with the Linux build blowing up sometimes due to a conflict between sigcheck/intrcheck and signalmodule. Built-in functions ------------------ - The second argument to apply() can now be any sequence, not just a tuple. Built-in types -------------- - Lists have a new method: L1.extend(L2) is equivalent to the common idiom L1[len(L1):] = L2. - Better error messages when a sequence is indexed with a non-integer. - Bettter error message when calling a non-callable object (include the type in the message). Python services --------------- - New version of cPickle.c fixes some bugs. - pickle.py: improved instantiation error handling. - code.py: reworked quite a bit. New base class InteractiveInterpreter and derived class InteractiveConsole. Fixed several problems in compile_command(). - py_compile.py: print error message and continue on syntax errors. Also fixed an old bug with the fstat code (it was never used). - pyclbr.py: support submodules of packages. String Services --------------- - StringIO.py: raise the right exception (ValueError) for attempted I/O on closed StringIO objects. - re.py: fixed a bug in subn(), which caused .groups() to fail inside the replacement function called by sub(). - The struct module has a new format 'P': void * in native mode. Generic OS Services ------------------- - Module time: Y2K robustness. 2-digit year acceptance depends on value of time.accept2dyear, initialized from env var PYTHONY2K, default 0. Years 00-68 mean 2000-2068, while 69-99 mean 1969-1999 (POSIX or X/Open recommendation). - os.path: normpath(".//x") should return "x", not "/x". - getpass.py: fall back on default_getpass() when sys.stdin.fileno() doesn't work. - tempfile.py: regenerate the template after a fork() call. Optional OS Services -------------------- - In the signal module, disable restarting interrupted system calls when we have siginterrupt(). Debugger -------- - No longer set __args__; this feature is no longer supported and can affect the debugged code. - cmd.py, pdb.py and bdb.py have been overhauled by Richard Wolff, who added aliases and some other useful new features, e.g. much better breakpoint support: temporary breakpoint, disabled breakpoints, breakpoints with ignore counts, and conditions; breakpoints can be set on a file before it is loaded. Profiler -------- - Changes so that JPython can use it. Also fix the calibration code so it actually works again . Internet Protocols and Support ------------------------------ - imaplib.py: new version from Piers Lauder. - smtplib.py: change sendmail() method to accept a single string or a list or strings as the destination (commom newbie mistake). - poplib.py: LIST with a msg argument fixed. - urlparse.py: some optimizations for common case (http). - urllib.py: support content-length in info() for ftp protocol; support for a progress meter through a third argument to urlretrieve(); commented out gopher test (the test site is dead). Internet Data handling ---------------------- - sgmllib.py: support tags with - or . in their name. - mimetypes.py: guess_type() understands 'data' URLs. Restricted Execution -------------------- - The classes rexec.RModuleLoader and rexec.RModuleImporter no longer exist. Tkinter ------- - When reporting an exception, store its info in sys.last_*. Also, write all of it to stderr. - Added NS, EW, and NSEW constants, for grid's sticky option. - Fixed last-minute bug in 1.5.2a1 release: need to include "mytime.h". - Make bind variants without a sequence return a tuple of sequences (formerly it returned a string, which wasn't very convenient). - Add image commands to the Text widget (these are new in Tk 8.0). - Added new listbox and canvas methods: {xview,yview}_{scroll,moveto}.) - Improved the thread code (but you still can't call update() from another thread on Windows). - Fixed unnecessary references to _default_root in the new dialog modules. - Miscellaneous problems fixed. Windows General --------------- - Call LoadLibraryEx(..., ..., LOAD_WITH_ALTERED_SEARCH_PATH) to search for dependent dlls in the directory containing the .pyd. - In debugging mode, call DebugBreak() in Py_FatalError(). Windows Installer ----------------- - Install zlib.dll in the DLLs directory instead of in the win32 system directory, to avoid conflicts with other applications that have their own zlib.dll. Test Suite ---------- - test_long.py: new test for long integers, by Tim Peters. - regrtest.py: improved so it can be used for other test suites as well. - test_strftime.py: use re to compare test results, to support legal variants (e.g. on Linux). Tools and Demos --------------- - Four new scripts in Tools/scripts: crlf.py and lfcr.py (to remove/add Windows style '\r\n' line endings), untabify.py (to remove tabs), and rgrep.yp (reverse grep). - Improvements to Tools/freeze/. Each Python module is now written to its own C file. This prevents some compilers or assemblers from blowing up on large frozen programs, and saves recompilation time if only a few modules are changed. Other changes too, e.g. new command line options -x and -i. - Much improved (and smaller!) version of Tools/scripts/mailerdaemon.py. Python/C API ------------ - New mechanism to support extensions of the type object while remaining backward compatible with extensions compiled for previous versions of Python 1.5. A flags field indicates presence of certain fields. - Addition to the buffer API to differentiate access to bytes and 8-bit characters (in anticipation of Unicode characters). - New argument parsing format t# ("text") to indicate 8-bit characters; s# simply means 8-bit bytes, for backwards compatibility. - New object type, bufferobject.c is an example and can be used to create buffers from memory. - Some support for 64-bit longs, including some MS platforms. - Many calls to fprintf(stderr, ...) have been replaced with calls to PySys_WriteStderr(...). - The calling context for PyOS_Readline() has changed: it must now be called with the interpreter lock held! It releases the lock around the call to the function pointed to by PyOS_ReadlineFunctionPointer (default PyOS_StdioReadline()). - New APIs PyLong_FromVoidPtr() and PyLong_AsVoidPtr(). - Renamed header file "thread.h" to "pythread.h". - The code string of code objects may now be anything that supports the buffer API. ====================================================================== From 1.5.1 to 1.5.2a1 ===================== General ------- - When searching for the library, a landmark that is a compiled module (string.pyc or string.pyo) is also accepted. - When following symbolic links to the python executable, use a loop so that a symlink to a symlink can work. - Added a hack so that when you type 'quit' or 'exit' at the interpreter, you get a friendly explanation of how to press Ctrl-D (or Ctrl-Z) to exit. - New and improved Misc/python-mode.el (Python mode for Emacs). - Revert a new feature in Unix dynamic loading: for one or two revisions, modules were loaded using the RTLD_GLOBAL flag. It turned out to be a bad idea. Miscellaneous fixed bugs ------------------------ - All patches on the patch page have been integrated. (But much more has been done!) - Several memory leaks plugged (e.g. the one for classes with a __getattr__ method). - Removed the only use of calloc(). This triggered an obscure bug on multiprocessor Sparc Solaris 2.6. - Fix a peculiar bug that would allow "import sys.time" to succeed (believing the built-in time module to be a part of the sys package). - Fix a bug in the overflow checking when converting a Python long to a C long (failed to convert -2147483648L, and some other cases). Documentation ------------- - Doc strings have been added to many extension modules: __builtin__, errno, select, signal, socket, sys, thread, time. Also to methods of list objects (try [].append.__doc__). A doc string on a type will now automatically be propagated to an instance if the instance has methods that are accessed in the usual way. - The documentation has been expanded and the formatting improved. (Remember that the documentation is now unbundled and has its own release cycle though; see http://www.python.org/doc/.) - Added Misc/Porting -- a mini-FAQ on porting to a new platform. Ports and build procedure ------------------------- - The BeOS port is now integrated. Courtesy Chris Herborth. - Symbol files for FreeBSD 2.x and 3.x have been contributed (Lib/plat-freebsd[23]/*). - Support HPUX 10.20 DCE threads. - Finally fixed the configure script so that (on SGI) if -OPT:Olimit=0 works, it won't also use -Olimit 1500 (which gives a warning for every file). Also support the SGI_ABI environment variable better. - The makesetup script now understands absolute pathnames ending in .o in the module -- it assumes it's a file for which we have no source. - Other miscellaneous improvements to the configure script and Makefiles. - The test suite now uses a different sound sample. Built-in functions ------------------ - Better checks for invalid input to int(), long(), string.atoi(), string.atol(). (Formerly, a sign without digits would be accepted as a legal ways to spell zero.) - Changes to map() and filter() to use the length of a sequence only as a hint -- if an IndexError happens earlier, take that. (Formerly, this was considered an error.) - Experimental feature in getattr(): a third argument can specify a default (instead of raising AttributeError). - Implement round() slightly different, so that for negative ndigits no additional errors happen in the last step. - The open() function now adds the filename to the exception when it fails. Built-in exceptions ------------------- - New standard exceptions EnvironmentError and PosixError. EnvironmentError is the base class for IOError and PosixError; PosixError is the same as os.error. All this so that either exception class can be instantiated with a third argument indicating a filename. The built-in function open() and most os/posix functions that take a filename argument now use this. Built-in types -------------- - List objects now have an experimental pop() method; l.pop() returns and removes the last item; l.pop(i) returns and removes the item at i. Also, the sort() method is faster again. Sorting is now also safer: it is impossible for the sorting function to modify the list while the sort is going on (which could cause core dumps). - Changes to comparisons: numbers are now smaller than any other type. This is done to prevent the circularity where [] < 0L < 1 < [] is true. As a side effect, cmp(None, 0) is now positive instead of negative. This *shouldn't* affect any working code, but I've found that the change caused several "sleeping" bugs to become active, so beware! - Instance methods may now have other callable objects than just Python functions as their im_func. Use new.instancemethod() or write your own C code to create them; new.instancemethod() may be called with None for the instance to create an unbound method. - Assignment to __name__, __dict__ or __bases__ of a class object is now allowed (with stringent type checks); also allow assignment to __getattr__ etc. The cached values for __getattr__ etc. are recomputed after such assignments (but not for derived classes :-( ). - Allow assignment to some attributes of function objects: func_code, func_defaults and func_doc / __doc__. (With type checks except for __doc__ / func_doc .) Python services --------------- - New tests (in Lib/test): reperf.py (regular expression benchmark), sortperf.py (list sorting benchmark), test_MimeWriter.py (test case for the MimeWriter module). - Generalized test/regrtest.py so that it is useful for testing other packages. - The ihooks.py module now understands package imports. - In code.py, add a class that subsumes Fredrik Lundh's PythonInterpreter class. The interact() function now uses this. - In rlcompleter.py, in completer(), return None instead of raising an IndexError when there are no more completions left. - Fixed the marshal module to test for certain common kinds of invalid input. (It's still not foolproof!) - In the operator module, add an alias (now the preferred name) "contains" for "sequenceincludes". String Services --------------- - In the string and strop modules, in the replace() function, treat an empty pattern as an error (since it's not clear what was meant!). - Some speedups to re.py, especially the string substitution and split functions. Also added new function/method findall(), to find all occurrences of a given substring. - In cStringIO, add better argument type checking and support the readonly 'closed' attribute (like regular files). - In the struct module, unsigned 1-2 byte sized formats no longer result in long integer values. Miscellaneous services ---------------------- - In whrandom.py, added new method and function randrange(), same as choice(range(start, stop, step)) but faster. This addresses the problem that randint() was accidentally defined as taking an inclusive range. Also, randint(a, b) is now redefined as randrange(a, b+1), adding extra range and type checking to its arguments! - Add some semi-thread-safety to random.gauss() (it used to be able to crash when invoked from separate threads; now the worst it can do is give a duplicate result occasionally). - Some restructuring and generalization done to cmd.py. - Major upgrade to ConfigParser.py; converted to using 're', added new exceptions, support underscore in section header and option name. No longer add 'name' option to every section; instead, add '__name__'. - In getpass.py, don't use raw_input() to ask for the password -- we don't want it to show up in the readline history! Also don't catch interrupts (the try-finally already does all necessary cleanup). Generic OS Services ------------------- - New functions in os.py: makedirs(), removedirs(), renames(). New variable: linesep (the line separator as found in binary files, i.e. '\n' on Unix, '\r\n' on DOS/Windows, '\r' on Mac. Do *not* use this with files opened in (default) text mode; the line separator used will always be '\n'! - Changes to the 'os.path' submodule of os.py: added getsize(), getmtime(), getatime() -- these fetch the most popular items from the stat return tuple. - In the time module, add strptime(), if it exists. (This parses a time according to a format -- the inverse of strftime().) Also, remove the call to mktime() from strftime() -- it messed up the formatting of some non-local times. - In the socket module, added a new function gethostbyname_ex(). Also, don't use #ifdef to test for some symbols that are enums on some platforms (and should exist everywhere). Optional OS Services -------------------- - Some fixes to gzip.py. In particular, the readlines() method now returns the lines *with* trailing newline characters, like readlines() of regular file objects. Also, it didn't work together with cPickle; fixed that. - In whichdb.py, support byte-swapped dbhash (bsddb) files. - In anydbm.py, look at the type of an existing database to determine which module to use to open it. (The anydbm.error exception is now a tuple.) Unix Services ------------- - In the termios module, in tcsetattr(), initialize the structure vy calling tcgetattr(). - Added some of the "wait status inspection" macros as functions to the posix module (and thus to the os module): WEXITSTATUS(), WIFEXITED(), WIFSIGNALED(), WIFSTOPPED(), WSTOPSIG(), WTERMSIG(). - In the syslog module, make the default facility more intuitive (matching the docs). Debugger -------- - In pdb.py, support for setting breaks on files/modules that haven't been loaded yet. Internet Protocols and Support ------------------------------ - Changes in urllib.py; sped up unquote() and quote(). Fixed an obscure bug in quote_plus(). Added urlencode(dict) -- convenience function for sending a POST request with urlopen(). Use the getpass module to ask for a password. Rewrote the (test) main program so that when used as a script, it can retrieve one or more URLs to stdout. Use -t to run the self-test. Made the proxy code work again. - In cgi.py, treat "HEAD" the same as "GET", so that CGI scripts don't fail when someone asks for their HEAD. Also, for POST, set the default content-type to application/x-www-form-urlencoded. Also, in FieldStorage.__init__(), when method='GET', always get the query string from environ['QUERY_STRING'] or sys.argv[1] -- ignore an explicitly passed in fp. - The smtplib.py module now supports ESMTP and has improved standard compliance, for picky servers. - Improved imaplib.py. - Fixed UDP support in SocketServer.py (it never worked). - Fixed a small bug in CGIHTTPServer.py. Internet Data handling ---------------------- - In rfc822.py, add a new class AddressList. Also support a new overridable method, isheader(). Also add a get() method similar to dictionaries (and make getheader() an alias for it). Also, be smarter about seekable (test whether fp.tell() works) and test for presence of unread() method before trying seeks. - In sgmllib.py, restore the call to report_unbalanced() that was lost long ago. Also some other improvements: handle , allow . and - in entity names, and allow \r\n as line separator. - Some restructuring and generalization done to multifile.py; support a 'seekable' flag. Restricted Execution -------------------- - Improvements to rexec.py: package support; support a (minimal) sys.exc_info(). Also made the (test) main program a bit fancier (you can now use it to run arbitrary Python scripts in restricted mode). Tkinter ------- - On Unix, Tkinter can now safely be used from a multi-threaded application. (Formerly, no threads would make progress while Tkinter's mainloop() was active, because it didn't release the Python interpreter lock.) Unfortunately, on Windows, threads other than the main thread should not call update() or update_idletasks() because this will deadlock the application. - An interactive interpreter that uses readline and Tkinter no longer uses up all available CPU time. - Even if readline is not used, Tk windows created in an interactive interpreter now get continuously updated. (This even works in Windows as long as you don't hit a key.) - New demos in Demo/tkinter/guido/: brownian.py, redemo.py, switch.py. - No longer register Tcl_finalize() as a low-level exit handler. It may call back into Python, and that's a bad idea. - Allow binding of Tcl commands (given as a string). - Some minor speedups; replace explicitly coded getint() with int() in most places. - In FileDialog.py, remember the directory of the selected file, if given. - Change the names of all methods in the Wm class: they are now wm_title(), etc. The old names (title() etc.) are still defined as aliases. - Add a new method of interpreter objects, interpaddr(). This returns the address of the Tcl interpreter object, as an integer. Not very useful for the Python programmer, but this can be called by another C extension that needs to make calls into the Tcl/Tk C API and needs to get the address of the Tcl interpreter object. A simple cast of the return value to (Tcl_Interp *) will do the trick. Windows General --------------- - Don't insist on proper case for module source files if the filename is all uppercase (e.g. FOO.PY now matches foo; but FOO.py still doesn't). This should address problems with this feature on oldfashioned filesystems (Novell servers?). Windows Library --------------- - os.environ is now all uppercase, but accesses are case insensitive, and the putenv() calls made as a side effect of changing os.environ are case preserving. - Removed samefile(), sameopenfile(), samestat() from os.path (aka ntpath.py) -- these cannot be made to work reliably (at least I wouldn't know how). - Fixed os.pipe() so that it returns file descriptors acceptable to os.read() and os.write() (like it does on Unix), rather than Windows file handles. - Added a table of WSA error codes to socket.py. - In the select module, put the (huge) file descriptor arrays on the heap. - The getpass module now raises KeyboardInterrupt when it sees ^C. - In mailbox.py, fix tell/seek when using files opened in text mode. - In rfc822.py, fix tell/seek when using files opened in text mode. - In the msvcrt extension module, release the interpreter lock for calls that may block: _locking(), _getch(), _getche(). Also fix a bogus error return when open_osfhandle() doesn't have the right argument list. Windows Installer ----------------- - The registry key used is now "1.5" instead of "1.5.x" -- so future versions of 1.5 and Mark Hammond's win32all installer don't need to be resynchronized. Windows Tools ------------- - Several improvements to freeze specifically for Windows. Windows Build Procedure ----------------------- - The VC++ project files and the WISE installer have been moved to the PCbuild subdirectory, so they are distributed in the same subdirectory where they must be used. This avoids confusion. - New project files for Windows 3.1 port by Jim Ahlstrom. - Got rid of the obsolete subdirectory PC/setup_nt/. - The projects now use distinct filenames for the .exe, .dll, .lib and .pyd files built in debug mode (by appending "_d" to the base name, before the extension). This makes it easier to switch between the two and get the right versions. There's a pragma in config.h that directs the linker to include the appropriate .lib file (so python15.lib no longer needs to be explicit in your project). - The installer now installs more files (e.g. config.h). The idea is that you shouldn't need the source distribution if you want build your own extensions in C or C++. Tools and Demos --------------- - New script nm2def.py by Marc-Andre Lemburg, to construct PC/python_nt.def automatically (some hand editing still required). - New tool ndiff.py: Tim Peters' text diffing tool. - Various and sundry improvements to the freeze script. - The script texi2html.py (which was part of the Doc tree but is no longer used there) has been moved to the Tools/scripts subdirectory. - Some generalizations in the webchecker code. There's now a primnitive gui for websucker.py: wsgui.py. (In Tools/webchecker/.) - The ftpmirror.py script now handles symbolic links properly, and also files with multiple spaces in their names. - The 1.5.1 tabnanny.py suffers an assert error if fed a script whose last line is both indented and lacks a newline. This is now fixed. Python/C API ------------ - Added missing prototypes for PyEval_CallFunction() and PyEval_CallMethod(). - New macro PyList_SET_ITEM(). - New macros to access object members for PyFunction, PyCFunction objects. - New APIs PyImport_AppendInittab() an PyImport_ExtendInittab() to dynamically add one or many entries to the table of built-in modules. - New macro Py_InitModule3(name, methods, doc) which calls Py_InitModule4() with appropriate arguments. (The -4 variant requires you to pass an obscure version number constant which is always the same.) - New APIs PySys_WriteStdout() and PySys_WriteStderr() to write to sys.stdout or sys.stderr using a printf-like interface. (Used in _tkinter.c, for example.) - New APIs for conversion between Python longs and C 'long long' if your compiler supports it. - PySequence_In() is now called PySequence_Contains(). (PySequence_In() is still supported for b/w compatibility; it is declared obsolete because its argument order is confusing.) - PyDict_GetItem() and PyDict_GetItemString() are changed so that they *never* raise an exception -- (even if the hash() fails, simply clear the error). This was necessary because there is lots of code out there that already assumes this. - Changes to PySequence_Tuple() and PySequence_List() to use the length of a sequence only as a hint -- if an IndexError happens earlier, take that. (Formerly, this was considered an error.) - Reformatted abstract.c to give it a more familiar "look" and fixed many error checking bugs. - Add NULL pointer checks to all calls of a C function through a type object and extensions (e.g. nb_add). - The code that initializes sys.path now calls Py_GetPythonHome() instead of getenv("PYTHONHOME"). This, together with the new API Py_SetPythonHome(), makes it easier for embedding applications to change the notion of Python's "home" directory (where the libraries etc. are sought). - Fixed a very old bug in the parsing of "O?" format specifiers. ======================================================================