blob: 0d78e7f9ceafffd3295242cc8ea665668cf213eb [file] [log] [blame]
Jeremy Hyltond6e20232000-10-16 20:08:38 +00001What's New in Python 2.0?
Fred Drake1a640502000-10-16 20:27:25 +00002=========================
Guido van Rossum61000331997-08-15 04:39:58 +00003
Guido van Rossum8ed602b2000-09-01 22:34:33 +00004Below is a list of all relevant changes since release 1.6. Older
Guido van Rossumf2ffce02000-09-05 04:38:34 +00005changes are in the file HISTORY. If you are making the jump directly
6from Python 1.5.2 to 2.0, make sure to read the section for 1.6 in the
7HISTORY file! Many important changes listed there.
Guido van Rossum61000331997-08-15 04:39:58 +00008
Guido van Rossumf2ffce02000-09-05 04:38:34 +00009Alternatively, a good overview of the changes between 1.5.2 and 2.0 is
10the document "What's New in Python 2.0" by Kuchling and Moshe Zadka:
11http://starship.python.net/crew/amk/python/writing/new-python/.
Guido van Rossum1f83cce1997-10-06 21:04:35 +000012
Guido van Rossumf2ffce02000-09-05 04:38:34 +000013--Guido van Rossum (home page: http://www.pythonlabs.com/~guido/)
Guido van Rossum437cfe81999-04-08 20:17:57 +000014
15======================================================================
16
Jeremy Hyltond6e20232000-10-16 20:08:38 +000017What's new in 2.0 (since release candidate 1)?
18==============================================
19
20Standard library
21
22- The copy_reg module was modified to clarify its intended use: to
23 register pickle support for extension types, not for classes.
24 pickle() will raise a TypeError if it is passed a class.
25
26- Fixed a bug in gettext's "normalize and expand" code that prevented
27 it from finding an existing .mo file.
28
29- Restored support for HTTP/0.9 servers in httplib.
30
Tim Peters989b7b92000-10-16 20:24:53 +000031- The math module was changed to stop raising OverflowError in case of
32 underflow, and return 0 instead in underflow cases. Whether Python
33 used to raise OverflowError in case of underflow was platform-
34 dependent (it did when the platform math library set errno to ERANGE
35 on underflow).
Jeremy Hyltond6e20232000-10-16 20:08:38 +000036
37- Fixed a bug in StringIO that occurred when the file position was not
38 at the end of the file and write() was called with enough data to
39 extend past the end of the file.
40
41- Fixed a bug that caused Tkinter error messages to get lost on
42 Windows. The bug was fixed by replacing direct use of
43 interp->result with Tcl_GetStringResult(interp).
44
45- Fixed bug in urllib2 that caused it to fail when it received an HTTP
46 redirect response.
47
48- Several changes were made to distutils: Some debugging code was
49 removed from util. Fixed the installer used when an external zip
50 program (like WinZip) is not found; the source code for this
51 installer is in Misc/distutils. check_lib() was modified to behave
52 more like AC_CHECK_LIB by add other_libraries() as a parameter. The
53 test for whether installed modules are on sys.path was changed to
54 use both normcase() and normpath().
55
Jeremy Hyltond867a2c2000-10-16 20:41:38 +000056- Several minor bugs were fixed in the xml package (the minidom,
57 pulldom, expatreader, and saxutils modules).
Jeremy Hyltond6e20232000-10-16 20:08:38 +000058
59- The regression test driver (regrtest.py) behavior when invoked with
60 -l changed: It now reports a count of objects that are recognized as
61 garbage but not freed by the garbage collector.
62
Tim Peters989b7b92000-10-16 20:24:53 +000063- The regression test for the math module was changed to test
64 exceptional behavior when the test is run in verbose mode. Python
65 cannot yet guarantee consistent exception behavior across platforms,
66 so the exception part of test_math is run only in verbose mode, and
67 may fail on your platform.
Jeremy Hyltond6e20232000-10-16 20:08:38 +000068
69Internals
70
71- PyOS_CheckStack() has been disabled on Win64, where it caused
72 test_sre to fail.
73
74Build issues
75
76- Changed compiler flags, so that gcc is always invoked with -Wall and
77 -Wstrict-prototypes. Users compiling Python with GCC should see
78 exactly one warning, except if they have passed configure the
Tim Peters989b7b92000-10-16 20:24:53 +000079 --with-pydebug flag. The expected warning is for getopt() in
Tim Petersadfb94f2000-10-16 20:51:33 +000080 Modules/main.c. This warning will be fixed for Python 2.1.
Jeremy Hyltond6e20232000-10-16 20:08:38 +000081
82- Fixed configure to add -threads argument during linking on OSF1.
83
84Tools and other miscellany
85
86- The compiler in Tools/compiler was updated to support the new
87 language features introduced in 2.0: extended print statement, list
88 comprehensions, and augmented assignments. The new compiler should
89 also be backwards compatible with Python 1.5.2; the compiler will
90 always generate code for the version of the interpreter it runs
91 under.
92
Jeremy Hyltoned9e6442000-10-09 18:26:42 +000093What's new in 2.0 release candidate 1 (since beta 2)?
94=====================================================
95
Jeremy Hylton6040aaa2000-10-09 21:27:22 +000096What is release candidate 1?
97
98We believe that release candidate 1 will fix all known bugs that we
99intend to fix for the 2.0 final release. This release should be a bit
100more stable than the previous betas. We would like to see even more
101widespread testing before the final release, so we are producing this
102release candidate. The final release will be exactly the same unless
103any show-stopping (or brown bag) bugs are found by testers of the
104release candidate.
105
Jeremy Hyltoned9e6442000-10-09 18:26:42 +0000106All the changes since the last beta release are bug fixes or changes
Jeremy Hyltond6e20232000-10-16 20:08:38 +0000107to support building Python for specific platforms.
Jeremy Hyltoned9e6442000-10-09 18:26:42 +0000108
109Core language, builtins, and interpreter
110
111- A bug that caused crashes when __coerce__ was used with augmented
112 assignment, e.g. +=, was fixed.
113
114- Raise ZeroDivisionError when raising zero to a negative number,
115 e.g. 0.0 ** -2.0. Note that math.pow is unrelated to the builtin
116 power operator and the result of math.pow(0.0, -2.0) will vary by
117 platform. On Linux, it raises a ValueError.
118
119- A bug in Unicode string interpolation was fixed that occasionally
120 caused errors with formats including "%%". For example, the
121 following expression "%% %s" % u"abc" no longer raises a TypeError.
122
123- Compilation of deeply nested expressions raises MemoryError instead
124 of SyntaxError, e.g. eval("[" * 50 + "]" * 50).
125
126- In 2.0b2 on Windows, the interpreter wrote .pyc files in text mode,
127 rendering them useless. They are now written in binary mode again.
128
129Standard library
130
131- Keyword arguments are now accepted for most pattern and match object
132 methods in SRE, the standard regular expression engine.
133
Jeremy Hyltond6e20232000-10-16 20:08:38 +0000134- In SRE, fixed error with negative lookahead and lookbehind that
Jeremy Hylton32e20ff2000-10-09 19:48:11 +0000135 manifested itself as a runtime error in patterns like "(?<!abc)(def)".
Jeremy Hyltoned9e6442000-10-09 18:26:42 +0000136
Jeremy Hyltond6e20232000-10-16 20:08:38 +0000137- Several bugs in the Unicode handling and error handling in _tkinter
138 were fixed.
Jeremy Hyltoned9e6442000-10-09 18:26:42 +0000139
140- Fix memory management errors in Merge() and Tkapp_Call() routines.
141
142- Several changes were made to cStringIO to make it compatible with
143 the file-like object interface and with StringIO. If operations are
144 performed on a closed object, an exception is raised. The truncate
145 method now accepts a position argument and readline accepts a size
146 argument.
147
148- There were many changes made to the linuxaudiodev module and its
149 test suite; as a result, a short, unexpected audio sample should now
150 play when the regression test is run.
151
152 Note that this module is named poorly, because it should work
153 correctly on any platform that supports the Open Sound System
154 (OSS).
155
156 The module now raises exceptions when errors occur instead of
157 crashing. It also defines the AFMT_A_LAW format (logarithmic A-law
158 audio) and defines a getptr() method that calls the
159 SNDCTL_DSP_GETxPTR ioctl defined in the OSS Programmer's Guide.
160
161- The library_version attribute, introduced in an earlier beta, was
162 removed because it can not be supported with early versions of the C
163 readline library, which provides no way to determine the version at
164 compile-time.
165
166- The binascii module is now enabled on Win64.
167
Tim Peters46446d62000-10-09 21:19:31 +0000168- tokenize.py no longer suffers "recursion depth" errors when parsing
169 programs with very long string literals.
170
Jeremy Hyltoned9e6442000-10-09 18:26:42 +0000171Internals
172
Jeremy Hyltond6e20232000-10-16 20:08:38 +0000173- Fixed several buffer overflow vulnerabilities in calculate_path(),
Jeremy Hyltoned9e6442000-10-09 18:26:42 +0000174 which is called when the interpreter starts up to determine where
175 the standard library is installed. These vulnerabilities affect all
176 previous versions of Python and can be exploited by setting very
177 long values for PYTHONHOME or argv[0]. The risk is greatest for a
178 setuid Python script, although use of the wrapper in
179 Misc/setuid-prog.c will eliminate the vulnerability.
180
181- Fixed garbage collection bugs in instance creation that were
182 triggered when errors occurred during initialization. The solution,
183 applied in cPickle and in PyInstance_New(), is to call
184 PyObject_GC_Init() after the initialization of the object's
185 container attributes is complete.
186
187- pyexpat adds definitions of PyModule_AddStringConstant and
188 PyModule_AddObject if the Python version is less than 2.0, which
189 provides compatibility with PyXML on Python 1.5.2.
190
191- If the platform has a bogus definition for LONG_BIT (the number of
192 bits in a long), an error will be reported at compile time.
193
194- Fix bugs in _PyTuple_Resize() which caused hard-to-interpret garbage
195 collection crashes and possibly other, unreported crashes.
196
197- Fixed a memory leak in _PyUnicode_Fini().
198
199Build issues
200
201- configure now accepts a --with-suffix option that specifies the
Jeremy Hyltond6e20232000-10-16 20:08:38 +0000202 executable suffix. This is useful for builds on Cygwin and Mac OS
203 X, for example.
Jeremy Hyltoned9e6442000-10-09 18:26:42 +0000204
205- The mmap.PAGESIZE constant is now initialized using sysconf when
206 possible, which eliminates a dependency on -lucb for Reliant UNIX.
207
208- The md5 file should now compile on all platforms.
209
210- The select module now compiles on platforms that do not define
211 POLLRDNORM and related constants.
212
213- Darwin (Mac OS X): Initial support for static builds on this
214 platform.
215
Jeremy Hylton10921202000-10-09 18:34:12 +0000216- BeOS: A number of changes were made to the build and installation
217 process. ar-fake now operates on a directory of object files.
218 dl_export.h is gone, and its macros now appear on the mwcc command
219 line during build on PPC BeOS.
220
Jeremy Hyltond6e20232000-10-16 20:08:38 +0000221- Platform directory in lib/python2.0 is "plat-beos5" (or
Jeremy Hylton10921202000-10-09 18:34:12 +0000222 "plat-beos4", if building on BeOS 4.5), rather than "plat-beos".
Jeremy Hyltoned9e6442000-10-09 18:26:42 +0000223
224- Cygwin: Support for shared libraries, Tkinter, and sockets.
225
226- SunOS 4.1.4_JL: Fix test for directory existence in configure.
227
228Tools and other miscellany
229
230- Removed debugging prints from main used with freeze.
231
Tim Peters46446d62000-10-09 21:19:31 +0000232- IDLE auto-indent no longer crashes when it encounters Unicode
233 characters.
Jeremy Hylton1b618592000-09-26 05:32:36 +0000234
235What's new in 2.0 beta 2 (since beta 1)?
236========================================
237
238Core language, builtins, and interpreter
239
Tim Peters482c0212000-09-26 06:33:09 +0000240- Add support for unbounded ints in %d,i,u,x,X,o formats; for example
Guido van Rossumf62ed9c2000-09-26 11:16:10 +0000241 "%d" % 2L**64 == "18446744073709551616".
Jeremy Hylton1b618592000-09-26 05:32:36 +0000242
Guido van Rossumf62ed9c2000-09-26 11:16:10 +0000243- Add -h and -V command line options to print the usage message and
244 Python version number and exit immediately.
245
Jeremy Hyltonfa2e2c12000-09-26 16:31:30 +0000246- eval() and exec accept Unicode objects as code parameters.
247
248- getattr() and setattr() now also accept Unicode objects for the
249 attribute name, which are converted to strings using the default
250 encoding before lookup.
251
252- Multiplication on string and Unicode now does proper bounds
253 checking; e.g. 'a' * 65536 * 65536 will raise ValueError, "repeated
254 string is too long."
255
256- Better error message when continue is found in try statement in a
257 loop.
258
Jeremy Hylton1b618592000-09-26 05:32:36 +0000259
260Standard library and extensions
261
Guido van Rossumf62ed9c2000-09-26 11:16:10 +0000262- array: reverse() method of array now works. buffer_info() now does
Jeremy Hylton1b618592000-09-26 05:32:36 +0000263 argument checking; it still takes no arguments.
264
Guido van Rossumf62ed9c2000-09-26 11:16:10 +0000265- asyncore/asynchat: Included most recent version from Sam Rushing.
Jeremy Hylton1b618592000-09-26 05:32:36 +0000266
Guido van Rossumf62ed9c2000-09-26 11:16:10 +0000267- cgi: Accept '&' or ';' as separator characters when parsing form data.
Jeremy Hylton1b618592000-09-26 05:32:36 +0000268
Guido van Rossumf62ed9c2000-09-26 11:16:10 +0000269- CGIHTTPServer: Now works on Windows (and perhaps even Mac).
Jeremy Hylton1b618592000-09-26 05:32:36 +0000270
271- ConfigParser: When reading the file, options spelled in upper case
Guido van Rossumf62ed9c2000-09-26 11:16:10 +0000272 letters are now correctly converted to lowercase.
Jeremy Hylton1b618592000-09-26 05:32:36 +0000273
274- copy: Copy Unicode objects atomically.
275
Guido van Rossumf62ed9c2000-09-26 11:16:10 +0000276- cPickle: Fail gracefully when copy_reg can't be imported.
Jeremy Hylton1b618592000-09-26 05:32:36 +0000277
Guido van Rossumf62ed9c2000-09-26 11:16:10 +0000278- cStringIO: Implemented readlines() method.
Jeremy Hylton1b618592000-09-26 05:32:36 +0000279
Fred Drake67233bc2000-09-26 16:40:27 +0000280- dbm: Add get() and setdefault() methods to dbm object. Add constant
281 `library' to module that names the library used. Added doc strings
282 and method names to error messages. Uses configure to determine
283 which ndbm.h file to include; Berkeley DB's nbdm and GDBM's ndbm is
284 now available options.
Jeremy Hylton1b618592000-09-26 05:32:36 +0000285
286- distutils: Update to version 0.9.3.
287
288- dl: Add several dl.RTLD_ constants.
289
290- fpectl: Now supported on FreeBSD.
291
292- gc: Add DEBUG_SAVEALL option. When enabled all garbage objects
293 found by the collector will be saved in gc.garbage. This is useful
294 for debugging a program that creates reference cycles.
295
Guido van Rossumf62ed9c2000-09-26 11:16:10 +0000296- httplib: Three changes: Restore support for set_debuglevel feature
Jeremy Hylton1b618592000-09-26 05:32:36 +0000297 of HTTP class. Do not close socket on zero-length response. Do not
298 crash when server sends invalid content-length header.
299
Guido van Rossumf62ed9c2000-09-26 11:16:10 +0000300- mailbox: Mailbox class conforms better to qmail specifications.
Jeremy Hylton1b618592000-09-26 05:32:36 +0000301
Jeremy Hyltonfa2e2c12000-09-26 16:31:30 +0000302- marshal: When reading a short, sign-extend on platforms where shorts
303 are bigger than 16 bits. When reading a long, repair the unportable
304 sign extension that was being done for 64-bit machines. (It assumed
305 that signed right shift sign-extends.)
306
Guido van Rossumf62ed9c2000-09-26 11:16:10 +0000307- operator: Add contains(), invert(), __invert__() as aliases for
308 __contains__(), inv(), and __inv__() respectively.
Jeremy Hylton1b618592000-09-26 05:32:36 +0000309
Guido van Rossumf62ed9c2000-09-26 11:16:10 +0000310- os: Add support for popen2() and popen3() on all platforms where
311 fork() exists. (popen4() is still in the works.)
Jeremy Hylton1b618592000-09-26 05:32:36 +0000312
Guido van Rossumf62ed9c2000-09-26 11:16:10 +0000313- os: (Windows only:) Add startfile() function that acts like double-
Tim Peters482c0212000-09-26 06:33:09 +0000314 clicking on a file in Explorer (or passing the file name to the
315 DOS "start" command).
Jeremy Hylton1b618592000-09-26 05:32:36 +0000316
Guido van Rossumf62ed9c2000-09-26 11:16:10 +0000317- os.path: (Windows, DOS:) Treat trailing colon correctly in
Tim Peters482c0212000-09-26 06:33:09 +0000318 os.path.join. os.path.join("a:", "b") yields "a:b".
Jeremy Hylton1b618592000-09-26 05:32:36 +0000319
320- pickle: Now raises ValueError when an invalid pickle that contains
321 a non-string repr where a string repr was expected. This behavior
322 matches cPickle.
323
Guido van Rossumf62ed9c2000-09-26 11:16:10 +0000324- posixfile: Remove broken __del__() method.
Jeremy Hylton1b618592000-09-26 05:32:36 +0000325
Guido van Rossumf62ed9c2000-09-26 11:16:10 +0000326- py_compile: support CR+LF line terminators in source file.
Jeremy Hylton1b618592000-09-26 05:32:36 +0000327
328- readline: Does not immediately exit when ^C is hit when readline and
Jeremy Hyltonfa2e2c12000-09-26 16:31:30 +0000329 threads are configured. Adds definition of rl_library_version. (The
Guido van Rossumf62ed9c2000-09-26 11:16:10 +0000330 latter addition requires GNU readline 2.2 or later.)
Jeremy Hylton1b618592000-09-26 05:32:36 +0000331
332- rfc822: Domain literals returned by AddrlistClass method
Guido van Rossumf62ed9c2000-09-26 11:16:10 +0000333 getdomainliteral() are now properly wrapped in brackets.
Jeremy Hylton1b618592000-09-26 05:32:36 +0000334
335- site: sys.setdefaultencoding() should only be called in case the
Tim Peters482c0212000-09-26 06:33:09 +0000336 standard default encoding ("ascii") is changed. This saves quite a
Jeremy Hylton1b618592000-09-26 05:32:36 +0000337 few cycles during startup since the first call to
338 setdefaultencoding() will initialize the codec registry and the
339 encodings package.
340
Guido van Rossumf62ed9c2000-09-26 11:16:10 +0000341- socket: Support for size hint in readlines() method of object returned
342 by makefile().
Jeremy Hylton1b618592000-09-26 05:32:36 +0000343
Guido van Rossumf62ed9c2000-09-26 11:16:10 +0000344- sre: Added experimental expand() method to match objects. Does not
Jeremy Hylton625915e2000-10-02 13:43:33 +0000345 use buffer interface on Unicode strings. Does not hang if group id
Jeremy Hylton1b618592000-09-26 05:32:36 +0000346 is followed by whitespace.
347
Fred Drake64bb3802000-09-26 16:21:35 +0000348- StringIO: Size hint in readlines() is now supported as documented.
Jeremy Hylton1b618592000-09-26 05:32:36 +0000349
350- struct: Check ranges for bytes and shorts.
351
352- urllib: Improved handling of win32 proxy settings. Fixed quote and
Guido van Rossumf62ed9c2000-09-26 11:16:10 +0000353 quote_plus functions so that the always encode a comma.
Jeremy Hylton1b618592000-09-26 05:32:36 +0000354
355- Tkinter: Image objects are now guaranteed to have unique ids. Set
356 event.delta to zero if Tk version doesn't support mousewheel.
357 Removed some debugging prints.
358
Guido van Rossumf62ed9c2000-09-26 11:16:10 +0000359- UserList: now implements __contains__().
Jeremy Hylton1b618592000-09-26 05:32:36 +0000360
Fred Drake67233bc2000-09-26 16:40:27 +0000361- webbrowser: On Windows, use os.startfile() instead of os.popen(),
Guido van Rossumf62ed9c2000-09-26 11:16:10 +0000362 which works around a bug in Norton AntiVirus 2000 that leads directly
363 to a Blue Screen freeze.
Jeremy Hylton1b618592000-09-26 05:32:36 +0000364
365- xml: New version detection code allows PyXML to override standard
366 XML package if PyXML version is greater than 0.6.1.
367
Fred Drake64bb3802000-09-26 16:21:35 +0000368- xml.dom: DOM level 1 support for basic XML. Includes xml.dom.minidom
369 (conventional DOM), and xml.dom.pulldom, which allows building the DOM
370 tree only for nodes which are sufficiently interesting to a specific
371 application. Does not provide the HTML-specific extensions. Still
372 undocumented.
Jeremy Hylton1b618592000-09-26 05:32:36 +0000373
Fred Drake64bb3802000-09-26 16:21:35 +0000374- xml.sax: SAX 2 support for Python, including all the handler
375 interfaces needed to process XML 1.0 compliant XML. Some
376 documentation is already available.
Jeremy Hylton1b618592000-09-26 05:32:36 +0000377
Fred Drake64bb3802000-09-26 16:21:35 +0000378- pyexpat: Renamed to xml.parsers.expat since this is part of the new,
379 packagized XML support.
Jeremy Hylton1b618592000-09-26 05:32:36 +0000380
Guido van Rossumf62ed9c2000-09-26 11:16:10 +0000381
Jeremy Hylton1b618592000-09-26 05:32:36 +0000382C API
383
384- Add three new convenience functions for module initialization --
385 PyModule_AddObject(), PyModule_AddIntConstant(), and
386 PyModule_AddStringConstant().
387
Jeremy Hyltonfa2e2c12000-09-26 16:31:30 +0000388- Cleaned up definition of NULL in C source code; all definitions were
Jeremy Hylton1b618592000-09-26 05:32:36 +0000389 removed and add #error to Python.h if NULL isn't defined after
390 #include of stdio.h.
391
Guido van Rossumf62ed9c2000-09-26 11:16:10 +0000392- Py_PROTO() macros that were removed in 2.0b1 have been restored for
Jeremy Hylton1b618592000-09-26 05:32:36 +0000393 backwards compatibility (at the source level) with old extensions.
394
Guido van Rossumf62ed9c2000-09-26 11:16:10 +0000395- A wrapper API was added for signal() and sigaction(). Instead of
396 either function, always use PyOS_getsig() to get a signal handler
397 and PyOS_setsig() to set one. A new convenience typedef
398 PyOS_sighandler_t is defined for the type of signal handlers.
Jeremy Hylton1b618592000-09-26 05:32:36 +0000399
Guido van Rossumf62ed9c2000-09-26 11:16:10 +0000400- Add PyString_AsStringAndSize() function that provides access to the
Jeremy Hylton1b618592000-09-26 05:32:36 +0000401 internal data buffer and size of a string object -- or the default
402 encoded version of a Unicode object.
403
Jeremy Hyltonfa2e2c12000-09-26 16:31:30 +0000404- PyString_Size() and PyString_AsString() accept Unicode objects.
405
Guido van Rossumf62ed9c2000-09-26 11:16:10 +0000406- The standard header <limits.h> is now included by Python.h (if it
Fred Drake64bb3802000-09-26 16:21:35 +0000407 exists). INT_MAX and LONG_MAX will always be defined, even if
408 <limits.h> is not available.
Guido van Rossumf62ed9c2000-09-26 11:16:10 +0000409
Jeremy Hyltonfa2e2c12000-09-26 16:31:30 +0000410- PyFloat_FromString takes a second argument, pend, that was
411 effectively useless. It is now officially useless but preserved for
412 backwards compatibility. If the pend argument is not NULL, *pend is
413 set to NULL.
414
415- PyObject_GetAttr() and PyObject_SetAttr() now accept Unicode objects
416 for the attribute name. See note on getattr() above.
417
418- A few bug fixes to argument processing for Unicode.
419 PyArg_ParseTupleAndKeywords() now accepts "es#" and "es".
420 PyArg_Parse() special cases "s#" for Unicode objects; it returns a
421 pointer to the default encoded string data instead of to the raw
422 UTF-16.
423
424- Py_BuildValue accepts B format (for bgen-generated code).
425
Guido van Rossumf62ed9c2000-09-26 11:16:10 +0000426
Jeremy Hylton1b618592000-09-26 05:32:36 +0000427Internals
428
429- On Unix, fix code for finding Python installation directory so that
430 it works when argv[0] is a relative path.
431
Jeremy Hyltonfa2e2c12000-09-26 16:31:30 +0000432- Added a true tnicode_internal_encode() function and fixed the
Guido van Rossumf62ed9c2000-09-26 11:16:10 +0000433 unicode_internal_decode function() to support Unicode objects directly
Jeremy Hylton1b618592000-09-26 05:32:36 +0000434 rather than by generating a copy of the object.
435
Tim Peters482c0212000-09-26 06:33:09 +0000436- Several of the internal Unicode tables are much smaller now, and
437 the source code should be much friendlier to weaker compilers.
Jeremy Hylton1b618592000-09-26 05:32:36 +0000438
Jeremy Hylton97693b02000-09-26 17:42:51 +0000439- In the garbage collector: Fixed bug in collection of tuples. Fixed
440 bug that caused some instances to be removed from the container set
441 while they were still live. Fixed parsing in gc.set_debug() for
442 platforms where sizeof(long) > sizeof(int).
Jeremy Hyltonfa2e2c12000-09-26 16:31:30 +0000443
444- Fixed refcount problem in instance deallocation that only occurred
445 when Py_REF_DEBUG was defined and Py_TRACE_REFS was not.
446
Jeremy Hyltonfa2e2c12000-09-26 16:31:30 +0000447- On Windows, getpythonregpath is now protected against null data in
448 registry key.
449
450- On Unix, create .pyc/.pyo files with O_EXCL flag to avoid a race
451 condition.
452
Guido van Rossumf62ed9c2000-09-26 11:16:10 +0000453
Jeremy Hylton1b618592000-09-26 05:32:36 +0000454Build and platform-specific issues
455
456- Better support of GNU Pth via --with-pth configure option.
457
Jeremy Hyltonfa2e2c12000-09-26 16:31:30 +0000458- Python/C API now properly exposed to dynamically-loaded extension
459 modules on Reliant UNIX.
Jeremy Hylton1b618592000-09-26 05:32:36 +0000460
461- Changes for the benefit of SunOS 4.1.4 (really!). mmapmodule.c:
462 Don't define MS_SYNC to be zero when it is undefined. Added missing
463 prototypes in posixmodule.c.
464
Jeremy Hyltonfa2e2c12000-09-26 16:31:30 +0000465- Improved support for HP-UX build. Threads should now be correctly
Guido van Rossumf62ed9c2000-09-26 11:16:10 +0000466 configured (on HP-UX 10.20 and 11.00).
Jeremy Hylton1b618592000-09-26 05:32:36 +0000467
Jeremy Hyltonfa2e2c12000-09-26 16:31:30 +0000468- Fix largefile support on older NetBSD systems and OpenBSD by adding
469 define for TELL64.
470
471
472Tools and other miscellany
473
474- ftpmirror: Call to main() is wrapped in if __name__ == "__main__".
475
476- freeze: The modulefinder now works with 2.0 opcodes.
477
478- IDLE:
479 Move hackery of sys.argv until after the Tk instance has been
480 created, which allows the application-specific Tkinter
481 initialization to be executed if present; also pass an explicit
482 className parameter to the Tk() constructor.
Fred Drake64bb3802000-09-26 16:21:35 +0000483
Jeremy Hylton1b618592000-09-26 05:32:36 +0000484
485What's new in 2.0 beta 1?
486=========================
487
Guido van Rossumf2ffce02000-09-05 04:38:34 +0000488Source Incompatibilities
489------------------------
490
491None. Note that 1.6 introduced several incompatibilities with 1.5.2,
492such as single-argument append(), connect() and bind(), and changes to
493str(long) and repr(float).
494
495
496Binary Incompatibilities
497------------------------
498
499- Third party extensions built for Python 1.5.x or 1.6 cannot be used
500with Python 2.0; these extensions will have to be rebuilt for Python
5012.0.
502
503- On Windows, attempting to import a third party extension built for
504Python 1.5.x or 1.6 results in an immediate crash; there's not much we
505can do about this. Check your PYTHONPATH environment variable!
506
507- Python bytecode files (*.pyc and *.pyo) are not compatible between
508releases.
509
510
511Overview of Changes Since 1.6
512-----------------------------
513
514There are many new modules (including brand new XML support through
515the xml package, and i18n support through the gettext module); a list
516of all new modules is included below. Lots of bugs have been fixed.
517
Jeremy Hylton24c3d602000-09-05 19:36:26 +0000518The process for making major new changes to the language has changed
519since Python 1.6. Enhancements must now be documented by a Python
520Enhancement Proposal (PEP) before they can be accepted.
521
Guido van Rossumf2ffce02000-09-05 04:38:34 +0000522There are several important syntax enhancements, described in more
523detail below:
524
525 - Augmented assignment, e.g. x += 1
526
527 - List comprehensions, e.g. [x**2 for x in range(10)]
528
529 - Extended import statement, e.g. import Module as Name
530
531 - Extended print statement, e.g. print >> file, "Hello"
532
533Other important changes:
534
535 - Optional collection of cyclical garbage
536
Jeremy Hylton24c3d602000-09-05 19:36:26 +0000537Python Enhancement Proposal (PEP)
538---------------------------------
539
540PEP stands for Python Enhancement Proposal. A PEP is a design
541document providing information to the Python community, or describing
542a new feature for Python. The PEP should provide a concise technical
543specification of the feature and a rationale for the feature.
544
545We intend PEPs to be the primary mechanisms for proposing new
546features, for collecting community input on an issue, and for
547documenting the design decisions that have gone into Python. The PEP
548author is responsible for building consensus within the community and
549documenting dissenting opinions.
550
551The PEPs are available at http://python.sourceforge.net/peps/.
Guido van Rossumf2ffce02000-09-05 04:38:34 +0000552
553Augmented Assignment
554--------------------
555
556This must have been the most-requested feature of the past years!
557Eleven new assignment operators were added:
558
Guido van Rossume905e952000-09-05 12:42:46 +0000559 += -= *= /= %= **= <<= >>= &= ^= |=
Guido van Rossumf2ffce02000-09-05 04:38:34 +0000560
561For example,
562
563 A += B
564
565is similar to
566
567 A = A + B
568
569except that A is evaluated only once (relevant when A is something
570like dict[index].attr).
571
572However, if A is a mutable object, A may be modified in place. Thus,
573if A is a number or a string, A += B has the same effect as A = A+B
574(except A is only evaluated once); but if a is a list, A += B has the
575same effect as A.extend(B)!
576
577Classes and built-in object types can override the new operators in
578order to implement the in-place behavior; the not-in-place behavior is
579used automatically as a fallback when an object doesn't implement the
580in-place behavior. For classes, the method name is derived from the
581method name for the corresponding not-in-place operator by inserting
582an 'i' in front of the name, e.g. __iadd__ implements in-place
583__add__.
584
585Augmented assignment was implemented by Thomas Wouters.
586
587
588List Comprehensions
589-------------------
590
591This is a flexible new notation for lists whose elements are computed
592from another list (or lists). The simplest form is:
593
594 [<expression> for <variable> in <sequence>]
595
Guido van Rossum56db0952000-09-06 23:34:25 +0000596For example, [i**2 for i in range(4)] yields the list [0, 1, 4, 9].
Guido van Rossumf62ed9c2000-09-26 11:16:10 +0000597This is more efficient than a for loop with a list.append() call.
Guido van Rossumf2ffce02000-09-05 04:38:34 +0000598
599You can also add a condition:
600
601 [<expression> for <variable> in <sequence> if <condition>]
602
603For example, [w for w in words if w == w.lower()] would yield the list
604of words that contain no uppercase characters. This is more efficient
Guido van Rossumf62ed9c2000-09-26 11:16:10 +0000605than a for loop with an if statement and a list.append() call.
Guido van Rossumf2ffce02000-09-05 04:38:34 +0000606
607You can also have nested for loops and more than one 'if' clause. For
608example, here's a function that flattens a sequence of sequences::
609
610 def flatten(seq):
611 return [x for subseq in seq for x in subseq]
612
613 flatten([[0], [1,2,3], [4,5], [6,7,8,9], []])
614
615This prints
616
617 [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
618
619List comprehensions originated as a patch set from Greg Ewing; Skip
Jeremy Hylton24c3d602000-09-05 19:36:26 +0000620Montanaro and Thomas Wouters also contributed. Described by PEP 202.
Guido van Rossumf2ffce02000-09-05 04:38:34 +0000621
622
623Extended Import Statement
624-------------------------
625
626Many people have asked for a way to import a module under a different
627name. This can be accomplished like this:
628
629 import foo
630 bar = foo
631 del foo
632
633but this common idiom gets old quickly. A simple extension of the
634import statement now allows this to be written as follows:
635
636 import foo as bar
637
638There's also a variant for 'from ... import':
639
640 from foo import bar as spam
641
642This also works with packages; e.g. you can write this:
643
644 import test.regrtest as regrtest
645
646Note that 'as' is not a new keyword -- it is recognized only in this
647context (this is only possible because the syntax for the import
648statement doesn't involve expressions).
649
Jeremy Hylton24c3d602000-09-05 19:36:26 +0000650Implemented by Thomas Wouters. Described by PEP 221.
Guido van Rossumf2ffce02000-09-05 04:38:34 +0000651
652
653Extended Print Statement
654------------------------
655
656Easily the most controversial new feature, this extension to the print
657statement adds an option to make the output go to a different file
658than the default sys.stdout.
659
660For example, to write an error message to sys.stderr, you can now
661write:
662
663 print >> sys.stderr, "Error: bad dog!"
664
665As a special feature, if the expression used to indicate the file
Fred Drake45888ff2000-09-29 17:09:11 +0000666evaluates to None, the current value of sys.stdout is used. Thus:
Guido van Rossumf2ffce02000-09-05 04:38:34 +0000667
668 print >> None, "Hello world"
669
670is equivalent to
671
672 print "Hello world"
673
Jeremy Hylton24c3d602000-09-05 19:36:26 +0000674Design and implementation by Barry Warsaw. Described by PEP 214.
Guido van Rossumf2ffce02000-09-05 04:38:34 +0000675
676
677Optional Collection of Cyclical Garbage
678---------------------------------------
679
680Python is now equipped with a garbage collector that can hunt down
681cyclical references between Python objects. It's no replacement for
682reference counting; in fact, it depends on the reference counts being
683correct, and decides that a set of objects belong to a cycle if all
684their reference counts can be accounted for from their references to
685each other. This devious scheme was first proposed by Eric Tiedemann,
686and brought to implementation by Neil Schemenauer.
687
688There's a module "gc" that lets you control some parameters of the
689garbage collection. There's also an option to the configure script
690that lets you enable or disable the garbage collection. In 2.0b1,
691it's on by default, so that we (hopefully) can collect decent user
692experience with this new feature. There are some questions about its
Fred Drake9f11cf82000-09-29 17:54:40 +0000693performance. If it proves to be too much of a problem, we'll turn it
Guido van Rossumf2ffce02000-09-05 04:38:34 +0000694off by default in the final 2.0 release.
695
696
697Smaller Changes
698---------------
699
700A new function zip() was added. zip(seq1, seq2, ...) is equivalent to
701map(None, seq1, seq2, ...) when the sequences have the same length;
702i.e. zip([1,2,3], [10,20,30]) returns [(1,10), (2,20), (3,30)]. When
703the lists are not all the same length, the shortest list wins:
Jeremy Hylton24c3d602000-09-05 19:36:26 +0000704zip([1,2,3], [10,20]) returns [(1,10), (2,20)]. See PEP 201.
Guido van Rossumf2ffce02000-09-05 04:38:34 +0000705
706sys.version_info is a tuple (major, minor, micro, level, serial).
707
708Dictionaries have an odd new method, setdefault(key, default).
709dict.setdefault(key, default) returns dict[key] if it exists; if not,
710it sets dict[key] to default and returns that value. Thus:
711
712 dict.setdefault(key, []).append(item)
713
714does the same work as this common idiom:
715
716 if not dict.has_key(key):
717 dict[key] = []
718 dict[key].append(item)
719
Jeremy Hylton24c3d602000-09-05 19:36:26 +0000720There are two new variants of SyntaxError that are raised for
721indentation-related errors: IndentationError and TabError.
722
723Changed \x to consume exactly two hex digits; see PEP 223. Added \U
724escape that consumes exactly eight hex digits.
Jeremy Hyltonbdebd542000-09-05 18:28:54 +0000725
726The limits on the size of expressions and file in Python source code
727have been raised from 2**16 to 2**32. Previous versions of Python
728were limited because the maximum argument size the Python VM accepted
729was 2**16. This limited the size of object constructor expressions,
730e.g. [1,2,3] or {'a':1, 'b':2}, and the size of source files. This
731limit was raised thanks to a patch by Charles Waldman that effectively
732fixes the problem. It is now much more likely that you will be
733limited by available memory than by an arbitrary limit in Python.
734
735The interpreter's maximum recursion depth can be modified by Python
736programs using sys.getrecursionlimit and sys.setrecursionlimit. This
737limit is the maximum number of recursive calls that can be made by
738Python code. The limit exists to prevent infinite recursion from
739overflowing the C stack and causing a core dump. The default value is
7401000. The maximum safe value for a particular platform can be found
741by running Misc/find_recursionlimit.py.
Guido van Rossumf2ffce02000-09-05 04:38:34 +0000742
743New Modules and Packages
744------------------------
745
746atexit - for registering functions to be called when Python exits.
747
748imputil - Greg Stein's alternative API for writing custom import
749hooks.
750
751pyexpat - an interface to the Expat XML parser, contributed by Paul
752Prescod.
753
754xml - a new package with XML support code organized (so far) in three
755subpackages: xml.dom, xml.sax, and xml.parsers. Describing these
756would fill a volume. There's a special feature whereby a
757user-installed package named _xmlplus overrides the standard
758xmlpackage; this is intended to give the XML SIG a hook to distribute
759backwards-compatible updates to the standard xml package.
760
761webbrowser - a platform-independent API to launch a web browser.
762
763
Guido van Rossume905e952000-09-05 12:42:46 +0000764Changed Modules
765---------------
766
Jeremy Hylton24c3d602000-09-05 19:36:26 +0000767array -- new methods for array objects: count, extend, index, pop, and
768remove
769
770binascii -- new functions b2a_hex and a2b_hex that convert between
771binary data and its hex representation
772
Jeremy Hyltonbdebd542000-09-05 18:28:54 +0000773calendar -- Many new functions that support features including control
774over which day of the week is the first day, returning strings instead
775of printing them. Also new symbolic constants for days of week,
776e.g. MONDAY, ..., SUNDAY.
777
778cgi -- FieldStorage objects have a getvalue method that works like a
779dictionary's get method and returns the value attribute of the object.
780
781ConfigParser -- The parser object has new methods has_option,
782remove_section, remove_option, set, and write. They allow the module
783to be used for writing config files as well as reading them.
784
785ftplib -- ntransfercmd(), transfercmd(), and retrbinary() all now
Guido van Rossume905e952000-09-05 12:42:46 +0000786optionally support the RFC 959 REST command.
787
Jeremy Hyltonbdebd542000-09-05 18:28:54 +0000788gzip -- readline and readlines now accept optional size arguments
Guido van Rossume905e952000-09-05 12:42:46 +0000789
Jeremy Hyltonbdebd542000-09-05 18:28:54 +0000790httplib -- New interfaces and support for HTTP/1.1 by Greg Stein. See
791the module doc strings for details.
Guido van Rossum830ca2a2000-09-05 15:34:16 +0000792
Jeremy Hylton24c3d602000-09-05 19:36:26 +0000793locale -- implement getdefaultlocale for Win32 and Macintosh
794
795marshal -- no longer dumps core when marshaling deeply nested or
796recursive data structures
797
798os -- new functions isatty, seteuid, setegid, setreuid, setregid
799
Jeremy Hyltonbdebd542000-09-05 18:28:54 +0000800os/popen2 -- popen2/popen3/popen4 support under Windows. popen2/popen3
801support under Unix.
802
Jeremy Hylton24c3d602000-09-05 19:36:26 +0000803os/pty -- support for openpty and forkpty
Jeremy Hyltonbdebd542000-09-05 18:28:54 +0000804
805os.path -- fix semantics of os.path.commonprefix
806
807smtplib -- support for sending very long messages
808
809socket -- new function getfqdn()
810
811readline -- new functions to read, write and truncate history files.
812The readline section of the library reference manual contains an
813example.
814
Jeremy Hylton24c3d602000-09-05 19:36:26 +0000815select -- add interface to poll system call
816
Jeremy Hyltonbdebd542000-09-05 18:28:54 +0000817shutil -- new copyfileobj function
818
819SimpleHTTPServer, CGIHTTPServer -- Fix problems with buffering in the
820HTTP server.
821
Jeremy Hylton24c3d602000-09-05 19:36:26 +0000822Tkinter -- optimization of function flatten
Jeremy Hyltonbdebd542000-09-05 18:28:54 +0000823
824urllib -- scans environment variables for proxy configuration,
Tim Peters8b092332000-09-05 20:15:25 +0000825e.g. http_proxy.
Jeremy Hyltonbdebd542000-09-05 18:28:54 +0000826
827whichdb -- recognizes dumbdbm format
Guido van Rossume905e952000-09-05 12:42:46 +0000828
829
830Obsolete Modules
831----------------
832
833None. However note that 1.6 made a whole slew of modules obsolete:
834stdwin, soundex, cml, cmpcache, dircache, dump, find, grep, packmail,
835poly, zmod, strop, util, whatsound.
836
837
838Changed, New, Obsolete Tools
839----------------------------
840
Tim Peters8b092332000-09-05 20:15:25 +0000841None.
Guido van Rossume905e952000-09-05 12:42:46 +0000842
843
Guido van Rossumf2ffce02000-09-05 04:38:34 +0000844C-level Changes
845---------------
846
847Several cleanup jobs were carried out throughout the source code.
848
849All C code was converted to ANSI C; we got rid of all uses of the
850Py_PROTO() macro, which makes the header files a lot more readable.
851
852Most of the portability hacks were moved to a new header file,
853pyport.h; several other new header files were added and some old
854header files were removed, in an attempt to create a more rational set
855of header files. (Few of these ever need to be included explicitly;
856they are all included by Python.h.)
857
Guido van Rossumf2ffce02000-09-05 04:38:34 +0000858Trent Mick ensured portability to 64-bit platforms, under both Linux
Jeremy Hylton24c3d602000-09-05 19:36:26 +0000859and Win64, especially for the new Intel Itanium processor. Mick also
860added large file support for Linux64 and Win64.
Guido van Rossumf2ffce02000-09-05 04:38:34 +0000861
Jeremy Hyltonbdebd542000-09-05 18:28:54 +0000862The C APIs to return an object's size have been update to consistently
863use the form PyXXX_Size, e.g. PySequence_Size and PyDict_Size. In
864previous versions, the abstract interfaces used PyXXX_Length and the
865concrete interfaces used PyXXX_Size. The old names,
866e.g. PyObject_Length, are still available for backwards compatibility
867at the API level, but are deprecated.
868
Jeremy Hylton24c3d602000-09-05 19:36:26 +0000869The PyOS_CheckStack function has been implemented on Windows by
870Fredrik Lundh. It prevents Python from failing with a stack overflow
871on Windows.
Jeremy Hyltonbdebd542000-09-05 18:28:54 +0000872
873The GC changes resulted in creation of two new slots on object,
874tp_traverse and tp_clear. The augmented assignment changes result in
Guido van Rossum4338a282000-09-06 13:02:08 +0000875the creation of a new slot for each in-place operator.
Jeremy Hyltonbdebd542000-09-05 18:28:54 +0000876
877The GC API creates new requirements for container types implemented in
Guido van Rossum4338a282000-09-06 13:02:08 +0000878C extension modules. See Include/objimpl.h for details.
Jeremy Hyltonbdebd542000-09-05 18:28:54 +0000879
Jeremy Hylton24c3d602000-09-05 19:36:26 +0000880PyErr_Format has been updated to automatically calculate the size of
881the buffer needed to hold the formatted result string. This change
882prevents crashes caused by programmer error.
Jeremy Hyltonbdebd542000-09-05 18:28:54 +0000883
Jeremy Hylton24c3d602000-09-05 19:36:26 +0000884New C API calls: PyObject_AsFileDescriptor, PyErr_WriteUnraisable.
Guido van Rossume905e952000-09-05 12:42:46 +0000885
Jeremy Hylton24c3d602000-09-05 19:36:26 +0000886PyRun_AnyFileEx, PyRun_SimpleFileEx, PyRun_FileEx -- New functions
887that are the same as their non-Ex counterparts except they take an
888extra flag argument that tells them to close the file when done.
889
890XXX There were other API changes that should be fleshed out here.
Guido van Rossumab9d6f01998-08-10 22:01:13 +0000891
Tim Peters8b092332000-09-05 20:15:25 +0000892
893Windows Changes
894---------------
895
896New popen2/popen3/peopen4 in os module (see Changed Modules above).
897
898os.popen is much more usable on Windows 95 and 98. See Microsoft
899Knowledge Base article Q150956. The Win9x workaround described there
900is implemented by the new w9xpopen.exe helper in the root of your
901Python installation. Note that Python uses this internally; it is not
902a standalone program.
903
904Administrator privileges are no longer required to install Python
905on Windows NT or Windows 2000. If you have administrator privileges,
906Python's registry info will be written under HKEY_LOCAL_MACHINE.
907Otherwise the installer backs off to writing Python's registry info
Guido van Rossum4338a282000-09-06 13:02:08 +0000908under HKEY_CURRENT_USER. The latter is sufficient for all "normal"
Tim Peters8b092332000-09-05 20:15:25 +0000909uses of Python, but will prevent some advanced uses from working
910(for example, running a Python script as an NT service, or possibly
911from CGI).
912
913[This was new in 1.6] The installer no longer runs a separate Tcl/Tk
914installer; instead, it installs the needed Tcl/Tk files directly in the
915Python directory. If you already have a Tcl/Tk installation, this
916wastes some disk space (about 4 Megs) but avoids problems with
917conflicting Tcl/Tk installations, and makes it much easier for Python
918to ensure that Tcl/Tk can find all its files.
919
920[This was new in 1.6] The Windows installer now installs by default in
921\Python20\ on the default volume, instead of \Program Files\Python-2.0\.
922
Guido van Rossumf62ed9c2000-09-26 11:16:10 +0000923
924Updates to the changes between 1.5.2 and 1.6
925--------------------------------------------
926
927The 1.6 NEWS file can't be changed after the release is done, so here
928is some late-breaking news:
929
930New APIs in locale.py: normalize(), getdefaultlocale(), resetlocale(),
931and changes to getlocale() and setlocale().
932
933The new module is now enabled per default.
934
935It is not true that the encodings codecs cannot be used for normal
936strings: the string.encode() (which is also present on 8-bit strings
937!) allows using them for 8-bit strings too, e.g. to convert files from
938cp1252 (Windows) to latin-1 or vice-versa.
939
940Japanese codecs are available from Tamito KAJIYAMA:
941http://pseudo.grad.sccs.chukyo-u.ac.jp/~kajiyama/python/
942
943
Guido van Rossumab9d6f01998-08-10 22:01:13 +0000944======================================================================