Notice: While JavaScript is not essential for this website, your interaction with the content will be limited. Please turn JavaScript on for the full experience.

Python 1.6.1

Python 1.6.1

Note: See the download pages for more recent releases.

What's new?

Python 1.6 was the last of the versions developed at CNRI and the only version issued by CNRI with an open source license. Following the release of Python 1.6, and after Guido van Rossum left CNRI to work with commercial software developers, it became clear that the ability to use Python with software available under the GNU General Public License (GPL) was very desirable. CNRI and the Free Software Foundation (FSF) interacted to develop enabling wording changes to the Python license. Python 1.6.1 is essentially the same as Python 1.6, with a few minor bug fixes, and with a GPL-compatible license.

Note: according to CNRI, Python 1.6.1 is GPL-compatible, but the FSF's lawyer, has said that Python 1.6.1 is not compatible with the GPL. CNRI disagrees, and states the FSF's lawyer has told CNRI's lawyer that 1.6.1 is "not incompatible" with the GPL.

Download

Python 1.6.1 is available for download now. It is released under the CNRI Open Source GPL-Compatible License.

Notes for Windows users: Some browsers remove the ".exe" suffix of the downloaded installer file. If this happens to you, simply rename the downloaded file to "python16.exe" before you double-click it to run the installer. Also, if you have ever installed an older Python version (especially distributions from PythonWare), you may have to remove references to it from your autoexec.bat. Incompatibility warning: Norton Antivirus 2000 can cause blue screen crashes on Windows 98 when a function in the os.popen*() family is invoked. To prevent this problem, disable Norton Antivirus when using Python. (Confirmed on Windows 98 Second Edition with Norton Antivirus version 6.10.20. The same Norton Antivirus version doesn't have this problem on Windows 2000. Norton Antivirus version 5 on Windows 98SE doesn't have this problem either.)

Bugs and Patches

To report a bug, always use the SourceForge Bug Tracker. If you have a patch, please use the SourceForge Patch Manager. Be sure to indicate that this is a bug report or patch for Python 1.6.1!

What's new in release 1.6.1?

  • A new license (see above).
  • A core dump in the C API function PyList_Reverse() has been fixed.
  • The 1.6 release accidentally contained a number of .pyc files; these have been removed.

What's new in release 1.6?

Here 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://starship.python.net/crew/amk/python/writing/new-python/.

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 a 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.

Vladimir Marangozov designed more rational C APIs for allocating memory. See mymalloc.h.

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 conflicting 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 Python16on the default volume, instead of Program FilesPython-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 <file>.writelines() with a list containing non-string objects would crash, and there were situations where a lost SyntaxError could dump core.

The <list>.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.