blob: cbb06db9770b7f0e63d9f54de4a9962f2410a47b [file] [log] [blame]
Jeremy Hyltond6e20232000-10-16 20:08:38 +00001What's New in Python 2.0?
Guido van Rossum61000331997-08-15 04:39:58 +00002===========================
3
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
31- XXX The math module was changed to suppress underflow errors and
32 just return 0.
33
34- Fixed a bug in StringIO that occurred when the file position was not
35 at the end of the file and write() was called with enough data to
36 extend past the end of the file.
37
38- Fixed a bug that caused Tkinter error messages to get lost on
39 Windows. The bug was fixed by replacing direct use of
40 interp->result with Tcl_GetStringResult(interp).
41
42- Fixed bug in urllib2 that caused it to fail when it received an HTTP
43 redirect response.
44
45- Several changes were made to distutils: Some debugging code was
46 removed from util. Fixed the installer used when an external zip
47 program (like WinZip) is not found; the source code for this
48 installer is in Misc/distutils. check_lib() was modified to behave
49 more like AC_CHECK_LIB by add other_libraries() as a parameter. The
50 test for whether installed modules are on sys.path was changed to
51 use both normcase() and normpath().
52
53- XXX xml minidom, pulldom, expatreader, and saxutils changes (can't
54 tell what happened from the CVS logs)
55
56- The regression test driver (regrtest.py) behavior when invoked with
57 -l changed: It now reports a count of objects that are recognized as
58 garbage but not freed by the garbage collector.
59
60- The regression test for the math module was changed to report
61 exceptional behavior when the test is run in verbose mode.
62
63Internals
64
65- PyOS_CheckStack() has been disabled on Win64, where it caused
66 test_sre to fail.
67
68Build issues
69
70- Changed compiler flags, so that gcc is always invoked with -Wall and
71 -Wstrict-prototypes. Users compiling Python with GCC should see
72 exactly one warning, except if they have passed configure the
73 --with-pydebug flag. The expect warning is for getopt() in
74 Modules/main.c.
75
76- Fixed configure to add -threads argument during linking on OSF1.
77
78Tools and other miscellany
79
80- The compiler in Tools/compiler was updated to support the new
81 language features introduced in 2.0: extended print statement, list
82 comprehensions, and augmented assignments. The new compiler should
83 also be backwards compatible with Python 1.5.2; the compiler will
84 always generate code for the version of the interpreter it runs
85 under.
86
Jeremy Hyltoned9e6442000-10-09 18:26:42 +000087What's new in 2.0 release candidate 1 (since beta 2)?
88=====================================================
89
Jeremy Hylton6040aaa2000-10-09 21:27:22 +000090What is release candidate 1?
91
92We believe that release candidate 1 will fix all known bugs that we
93intend to fix for the 2.0 final release. This release should be a bit
94more stable than the previous betas. We would like to see even more
95widespread testing before the final release, so we are producing this
96release candidate. The final release will be exactly the same unless
97any show-stopping (or brown bag) bugs are found by testers of the
98release candidate.
99
Jeremy Hyltoned9e6442000-10-09 18:26:42 +0000100All the changes since the last beta release are bug fixes or changes
Jeremy Hyltond6e20232000-10-16 20:08:38 +0000101to support building Python for specific platforms.
Jeremy Hyltoned9e6442000-10-09 18:26:42 +0000102
103Core language, builtins, and interpreter
104
105- A bug that caused crashes when __coerce__ was used with augmented
106 assignment, e.g. +=, was fixed.
107
108- Raise ZeroDivisionError when raising zero to a negative number,
109 e.g. 0.0 ** -2.0. Note that math.pow is unrelated to the builtin
110 power operator and the result of math.pow(0.0, -2.0) will vary by
111 platform. On Linux, it raises a ValueError.
112
113- A bug in Unicode string interpolation was fixed that occasionally
114 caused errors with formats including "%%". For example, the
115 following expression "%% %s" % u"abc" no longer raises a TypeError.
116
117- Compilation of deeply nested expressions raises MemoryError instead
118 of SyntaxError, e.g. eval("[" * 50 + "]" * 50).
119
120- In 2.0b2 on Windows, the interpreter wrote .pyc files in text mode,
121 rendering them useless. They are now written in binary mode again.
122
123Standard library
124
125- Keyword arguments are now accepted for most pattern and match object
126 methods in SRE, the standard regular expression engine.
127
Jeremy Hyltond6e20232000-10-16 20:08:38 +0000128- In SRE, fixed error with negative lookahead and lookbehind that
Jeremy Hylton32e20ff2000-10-09 19:48:11 +0000129 manifested itself as a runtime error in patterns like "(?<!abc)(def)".
Jeremy Hyltoned9e6442000-10-09 18:26:42 +0000130
Jeremy Hyltond6e20232000-10-16 20:08:38 +0000131- Several bugs in the Unicode handling and error handling in _tkinter
132 were fixed.
Jeremy Hyltoned9e6442000-10-09 18:26:42 +0000133
134- Fix memory management errors in Merge() and Tkapp_Call() routines.
135
136- Several changes were made to cStringIO to make it compatible with
137 the file-like object interface and with StringIO. If operations are
138 performed on a closed object, an exception is raised. The truncate
139 method now accepts a position argument and readline accepts a size
140 argument.
141
142- There were many changes made to the linuxaudiodev module and its
143 test suite; as a result, a short, unexpected audio sample should now
144 play when the regression test is run.
145
146 Note that this module is named poorly, because it should work
147 correctly on any platform that supports the Open Sound System
148 (OSS).
149
150 The module now raises exceptions when errors occur instead of
151 crashing. It also defines the AFMT_A_LAW format (logarithmic A-law
152 audio) and defines a getptr() method that calls the
153 SNDCTL_DSP_GETxPTR ioctl defined in the OSS Programmer's Guide.
154
155- The library_version attribute, introduced in an earlier beta, was
156 removed because it can not be supported with early versions of the C
157 readline library, which provides no way to determine the version at
158 compile-time.
159
160- The binascii module is now enabled on Win64.
161
Tim Peters46446d62000-10-09 21:19:31 +0000162- tokenize.py no longer suffers "recursion depth" errors when parsing
163 programs with very long string literals.
164
Jeremy Hyltoned9e6442000-10-09 18:26:42 +0000165Internals
166
Jeremy Hyltond6e20232000-10-16 20:08:38 +0000167- Fixed several buffer overflow vulnerabilities in calculate_path(),
Jeremy Hyltoned9e6442000-10-09 18:26:42 +0000168 which is called when the interpreter starts up to determine where
169 the standard library is installed. These vulnerabilities affect all
170 previous versions of Python and can be exploited by setting very
171 long values for PYTHONHOME or argv[0]. The risk is greatest for a
172 setuid Python script, although use of the wrapper in
173 Misc/setuid-prog.c will eliminate the vulnerability.
174
175- Fixed garbage collection bugs in instance creation that were
176 triggered when errors occurred during initialization. The solution,
177 applied in cPickle and in PyInstance_New(), is to call
178 PyObject_GC_Init() after the initialization of the object's
179 container attributes is complete.
180
181- pyexpat adds definitions of PyModule_AddStringConstant and
182 PyModule_AddObject if the Python version is less than 2.0, which
183 provides compatibility with PyXML on Python 1.5.2.
184
185- If the platform has a bogus definition for LONG_BIT (the number of
186 bits in a long), an error will be reported at compile time.
187
188- Fix bugs in _PyTuple_Resize() which caused hard-to-interpret garbage
189 collection crashes and possibly other, unreported crashes.
190
191- Fixed a memory leak in _PyUnicode_Fini().
192
193Build issues
194
195- configure now accepts a --with-suffix option that specifies the
Jeremy Hyltond6e20232000-10-16 20:08:38 +0000196 executable suffix. This is useful for builds on Cygwin and Mac OS
197 X, for example.
Jeremy Hyltoned9e6442000-10-09 18:26:42 +0000198
199- The mmap.PAGESIZE constant is now initialized using sysconf when
200 possible, which eliminates a dependency on -lucb for Reliant UNIX.
201
202- The md5 file should now compile on all platforms.
203
204- The select module now compiles on platforms that do not define
205 POLLRDNORM and related constants.
206
207- Darwin (Mac OS X): Initial support for static builds on this
208 platform.
209
Jeremy Hylton10921202000-10-09 18:34:12 +0000210- BeOS: A number of changes were made to the build and installation
211 process. ar-fake now operates on a directory of object files.
212 dl_export.h is gone, and its macros now appear on the mwcc command
213 line during build on PPC BeOS.
214
Jeremy Hyltond6e20232000-10-16 20:08:38 +0000215- Platform directory in lib/python2.0 is "plat-beos5" (or
Jeremy Hylton10921202000-10-09 18:34:12 +0000216 "plat-beos4", if building on BeOS 4.5), rather than "plat-beos".
Jeremy Hyltoned9e6442000-10-09 18:26:42 +0000217
218- Cygwin: Support for shared libraries, Tkinter, and sockets.
219
220- SunOS 4.1.4_JL: Fix test for directory existence in configure.
221
222Tools and other miscellany
223
224- Removed debugging prints from main used with freeze.
225
Tim Peters46446d62000-10-09 21:19:31 +0000226- IDLE auto-indent no longer crashes when it encounters Unicode
227 characters.
Jeremy Hylton1b618592000-09-26 05:32:36 +0000228
229What's new in 2.0 beta 2 (since beta 1)?
230========================================
231
232Core language, builtins, and interpreter
233
Tim Peters482c0212000-09-26 06:33:09 +0000234- Add support for unbounded ints in %d,i,u,x,X,o formats; for example
Guido van Rossumf62ed9c2000-09-26 11:16:10 +0000235 "%d" % 2L**64 == "18446744073709551616".
Jeremy Hylton1b618592000-09-26 05:32:36 +0000236
Guido van Rossumf62ed9c2000-09-26 11:16:10 +0000237- Add -h and -V command line options to print the usage message and
238 Python version number and exit immediately.
239
Jeremy Hyltonfa2e2c12000-09-26 16:31:30 +0000240- eval() and exec accept Unicode objects as code parameters.
241
242- getattr() and setattr() now also accept Unicode objects for the
243 attribute name, which are converted to strings using the default
244 encoding before lookup.
245
246- Multiplication on string and Unicode now does proper bounds
247 checking; e.g. 'a' * 65536 * 65536 will raise ValueError, "repeated
248 string is too long."
249
250- Better error message when continue is found in try statement in a
251 loop.
252
Jeremy Hylton1b618592000-09-26 05:32:36 +0000253
254Standard library and extensions
255
Guido van Rossumf62ed9c2000-09-26 11:16:10 +0000256- array: reverse() method of array now works. buffer_info() now does
Jeremy Hylton1b618592000-09-26 05:32:36 +0000257 argument checking; it still takes no arguments.
258
Guido van Rossumf62ed9c2000-09-26 11:16:10 +0000259- asyncore/asynchat: Included most recent version from Sam Rushing.
Jeremy Hylton1b618592000-09-26 05:32:36 +0000260
Guido van Rossumf62ed9c2000-09-26 11:16:10 +0000261- cgi: Accept '&' or ';' as separator characters when parsing form data.
Jeremy Hylton1b618592000-09-26 05:32:36 +0000262
Guido van Rossumf62ed9c2000-09-26 11:16:10 +0000263- CGIHTTPServer: Now works on Windows (and perhaps even Mac).
Jeremy Hylton1b618592000-09-26 05:32:36 +0000264
265- ConfigParser: When reading the file, options spelled in upper case
Guido van Rossumf62ed9c2000-09-26 11:16:10 +0000266 letters are now correctly converted to lowercase.
Jeremy Hylton1b618592000-09-26 05:32:36 +0000267
268- copy: Copy Unicode objects atomically.
269
Guido van Rossumf62ed9c2000-09-26 11:16:10 +0000270- cPickle: Fail gracefully when copy_reg can't be imported.
Jeremy Hylton1b618592000-09-26 05:32:36 +0000271
Guido van Rossumf62ed9c2000-09-26 11:16:10 +0000272- cStringIO: Implemented readlines() method.
Jeremy Hylton1b618592000-09-26 05:32:36 +0000273
Fred Drake67233bc2000-09-26 16:40:27 +0000274- dbm: Add get() and setdefault() methods to dbm object. Add constant
275 `library' to module that names the library used. Added doc strings
276 and method names to error messages. Uses configure to determine
277 which ndbm.h file to include; Berkeley DB's nbdm and GDBM's ndbm is
278 now available options.
Jeremy Hylton1b618592000-09-26 05:32:36 +0000279
280- distutils: Update to version 0.9.3.
281
282- dl: Add several dl.RTLD_ constants.
283
284- fpectl: Now supported on FreeBSD.
285
286- gc: Add DEBUG_SAVEALL option. When enabled all garbage objects
287 found by the collector will be saved in gc.garbage. This is useful
288 for debugging a program that creates reference cycles.
289
Guido van Rossumf62ed9c2000-09-26 11:16:10 +0000290- httplib: Three changes: Restore support for set_debuglevel feature
Jeremy Hylton1b618592000-09-26 05:32:36 +0000291 of HTTP class. Do not close socket on zero-length response. Do not
292 crash when server sends invalid content-length header.
293
Guido van Rossumf62ed9c2000-09-26 11:16:10 +0000294- mailbox: Mailbox class conforms better to qmail specifications.
Jeremy Hylton1b618592000-09-26 05:32:36 +0000295
Jeremy Hyltonfa2e2c12000-09-26 16:31:30 +0000296- marshal: When reading a short, sign-extend on platforms where shorts
297 are bigger than 16 bits. When reading a long, repair the unportable
298 sign extension that was being done for 64-bit machines. (It assumed
299 that signed right shift sign-extends.)
300
Guido van Rossumf62ed9c2000-09-26 11:16:10 +0000301- operator: Add contains(), invert(), __invert__() as aliases for
302 __contains__(), inv(), and __inv__() respectively.
Jeremy Hylton1b618592000-09-26 05:32:36 +0000303
Guido van Rossumf62ed9c2000-09-26 11:16:10 +0000304- os: Add support for popen2() and popen3() on all platforms where
305 fork() exists. (popen4() is still in the works.)
Jeremy Hylton1b618592000-09-26 05:32:36 +0000306
Guido van Rossumf62ed9c2000-09-26 11:16:10 +0000307- os: (Windows only:) Add startfile() function that acts like double-
Tim Peters482c0212000-09-26 06:33:09 +0000308 clicking on a file in Explorer (or passing the file name to the
309 DOS "start" command).
Jeremy Hylton1b618592000-09-26 05:32:36 +0000310
Guido van Rossumf62ed9c2000-09-26 11:16:10 +0000311- os.path: (Windows, DOS:) Treat trailing colon correctly in
Tim Peters482c0212000-09-26 06:33:09 +0000312 os.path.join. os.path.join("a:", "b") yields "a:b".
Jeremy Hylton1b618592000-09-26 05:32:36 +0000313
314- pickle: Now raises ValueError when an invalid pickle that contains
315 a non-string repr where a string repr was expected. This behavior
316 matches cPickle.
317
Guido van Rossumf62ed9c2000-09-26 11:16:10 +0000318- posixfile: Remove broken __del__() method.
Jeremy Hylton1b618592000-09-26 05:32:36 +0000319
Guido van Rossumf62ed9c2000-09-26 11:16:10 +0000320- py_compile: support CR+LF line terminators in source file.
Jeremy Hylton1b618592000-09-26 05:32:36 +0000321
322- readline: Does not immediately exit when ^C is hit when readline and
Jeremy Hyltonfa2e2c12000-09-26 16:31:30 +0000323 threads are configured. Adds definition of rl_library_version. (The
Guido van Rossumf62ed9c2000-09-26 11:16:10 +0000324 latter addition requires GNU readline 2.2 or later.)
Jeremy Hylton1b618592000-09-26 05:32:36 +0000325
326- rfc822: Domain literals returned by AddrlistClass method
Guido van Rossumf62ed9c2000-09-26 11:16:10 +0000327 getdomainliteral() are now properly wrapped in brackets.
Jeremy Hylton1b618592000-09-26 05:32:36 +0000328
329- site: sys.setdefaultencoding() should only be called in case the
Tim Peters482c0212000-09-26 06:33:09 +0000330 standard default encoding ("ascii") is changed. This saves quite a
Jeremy Hylton1b618592000-09-26 05:32:36 +0000331 few cycles during startup since the first call to
332 setdefaultencoding() will initialize the codec registry and the
333 encodings package.
334
Guido van Rossumf62ed9c2000-09-26 11:16:10 +0000335- socket: Support for size hint in readlines() method of object returned
336 by makefile().
Jeremy Hylton1b618592000-09-26 05:32:36 +0000337
Guido van Rossumf62ed9c2000-09-26 11:16:10 +0000338- sre: Added experimental expand() method to match objects. Does not
Jeremy Hylton625915e2000-10-02 13:43:33 +0000339 use buffer interface on Unicode strings. Does not hang if group id
Jeremy Hylton1b618592000-09-26 05:32:36 +0000340 is followed by whitespace.
341
Fred Drake64bb3802000-09-26 16:21:35 +0000342- StringIO: Size hint in readlines() is now supported as documented.
Jeremy Hylton1b618592000-09-26 05:32:36 +0000343
344- struct: Check ranges for bytes and shorts.
345
346- urllib: Improved handling of win32 proxy settings. Fixed quote and
Guido van Rossumf62ed9c2000-09-26 11:16:10 +0000347 quote_plus functions so that the always encode a comma.
Jeremy Hylton1b618592000-09-26 05:32:36 +0000348
349- Tkinter: Image objects are now guaranteed to have unique ids. Set
350 event.delta to zero if Tk version doesn't support mousewheel.
351 Removed some debugging prints.
352
Guido van Rossumf62ed9c2000-09-26 11:16:10 +0000353- UserList: now implements __contains__().
Jeremy Hylton1b618592000-09-26 05:32:36 +0000354
Fred Drake67233bc2000-09-26 16:40:27 +0000355- webbrowser: On Windows, use os.startfile() instead of os.popen(),
Guido van Rossumf62ed9c2000-09-26 11:16:10 +0000356 which works around a bug in Norton AntiVirus 2000 that leads directly
357 to a Blue Screen freeze.
Jeremy Hylton1b618592000-09-26 05:32:36 +0000358
359- xml: New version detection code allows PyXML to override standard
360 XML package if PyXML version is greater than 0.6.1.
361
Fred Drake64bb3802000-09-26 16:21:35 +0000362- xml.dom: DOM level 1 support for basic XML. Includes xml.dom.minidom
363 (conventional DOM), and xml.dom.pulldom, which allows building the DOM
364 tree only for nodes which are sufficiently interesting to a specific
365 application. Does not provide the HTML-specific extensions. Still
366 undocumented.
Jeremy Hylton1b618592000-09-26 05:32:36 +0000367
Fred Drake64bb3802000-09-26 16:21:35 +0000368- xml.sax: SAX 2 support for Python, including all the handler
369 interfaces needed to process XML 1.0 compliant XML. Some
370 documentation is already available.
Jeremy Hylton1b618592000-09-26 05:32:36 +0000371
Fred Drake64bb3802000-09-26 16:21:35 +0000372- pyexpat: Renamed to xml.parsers.expat since this is part of the new,
373 packagized XML support.
Jeremy Hylton1b618592000-09-26 05:32:36 +0000374
Guido van Rossumf62ed9c2000-09-26 11:16:10 +0000375
Jeremy Hylton1b618592000-09-26 05:32:36 +0000376C API
377
378- Add three new convenience functions for module initialization --
379 PyModule_AddObject(), PyModule_AddIntConstant(), and
380 PyModule_AddStringConstant().
381
Jeremy Hyltonfa2e2c12000-09-26 16:31:30 +0000382- Cleaned up definition of NULL in C source code; all definitions were
Jeremy Hylton1b618592000-09-26 05:32:36 +0000383 removed and add #error to Python.h if NULL isn't defined after
384 #include of stdio.h.
385
Guido van Rossumf62ed9c2000-09-26 11:16:10 +0000386- Py_PROTO() macros that were removed in 2.0b1 have been restored for
Jeremy Hylton1b618592000-09-26 05:32:36 +0000387 backwards compatibility (at the source level) with old extensions.
388
Guido van Rossumf62ed9c2000-09-26 11:16:10 +0000389- A wrapper API was added for signal() and sigaction(). Instead of
390 either function, always use PyOS_getsig() to get a signal handler
391 and PyOS_setsig() to set one. A new convenience typedef
392 PyOS_sighandler_t is defined for the type of signal handlers.
Jeremy Hylton1b618592000-09-26 05:32:36 +0000393
Guido van Rossumf62ed9c2000-09-26 11:16:10 +0000394- Add PyString_AsStringAndSize() function that provides access to the
Jeremy Hylton1b618592000-09-26 05:32:36 +0000395 internal data buffer and size of a string object -- or the default
396 encoded version of a Unicode object.
397
Jeremy Hyltonfa2e2c12000-09-26 16:31:30 +0000398- PyString_Size() and PyString_AsString() accept Unicode objects.
399
Guido van Rossumf62ed9c2000-09-26 11:16:10 +0000400- The standard header <limits.h> is now included by Python.h (if it
Fred Drake64bb3802000-09-26 16:21:35 +0000401 exists). INT_MAX and LONG_MAX will always be defined, even if
402 <limits.h> is not available.
Guido van Rossumf62ed9c2000-09-26 11:16:10 +0000403
Jeremy Hyltonfa2e2c12000-09-26 16:31:30 +0000404- PyFloat_FromString takes a second argument, pend, that was
405 effectively useless. It is now officially useless but preserved for
406 backwards compatibility. If the pend argument is not NULL, *pend is
407 set to NULL.
408
409- PyObject_GetAttr() and PyObject_SetAttr() now accept Unicode objects
410 for the attribute name. See note on getattr() above.
411
412- A few bug fixes to argument processing for Unicode.
413 PyArg_ParseTupleAndKeywords() now accepts "es#" and "es".
414 PyArg_Parse() special cases "s#" for Unicode objects; it returns a
415 pointer to the default encoded string data instead of to the raw
416 UTF-16.
417
418- Py_BuildValue accepts B format (for bgen-generated code).
419
Guido van Rossumf62ed9c2000-09-26 11:16:10 +0000420
Jeremy Hylton1b618592000-09-26 05:32:36 +0000421Internals
422
423- On Unix, fix code for finding Python installation directory so that
424 it works when argv[0] is a relative path.
425
Jeremy Hyltonfa2e2c12000-09-26 16:31:30 +0000426- Added a true tnicode_internal_encode() function and fixed the
Guido van Rossumf62ed9c2000-09-26 11:16:10 +0000427 unicode_internal_decode function() to support Unicode objects directly
Jeremy Hylton1b618592000-09-26 05:32:36 +0000428 rather than by generating a copy of the object.
429
Tim Peters482c0212000-09-26 06:33:09 +0000430- Several of the internal Unicode tables are much smaller now, and
431 the source code should be much friendlier to weaker compilers.
Jeremy Hylton1b618592000-09-26 05:32:36 +0000432
Jeremy Hylton97693b02000-09-26 17:42:51 +0000433- In the garbage collector: Fixed bug in collection of tuples. Fixed
434 bug that caused some instances to be removed from the container set
435 while they were still live. Fixed parsing in gc.set_debug() for
436 platforms where sizeof(long) > sizeof(int).
Jeremy Hyltonfa2e2c12000-09-26 16:31:30 +0000437
438- Fixed refcount problem in instance deallocation that only occurred
439 when Py_REF_DEBUG was defined and Py_TRACE_REFS was not.
440
Jeremy Hyltonfa2e2c12000-09-26 16:31:30 +0000441- On Windows, getpythonregpath is now protected against null data in
442 registry key.
443
444- On Unix, create .pyc/.pyo files with O_EXCL flag to avoid a race
445 condition.
446
Guido van Rossumf62ed9c2000-09-26 11:16:10 +0000447
Jeremy Hylton1b618592000-09-26 05:32:36 +0000448Build and platform-specific issues
449
450- Better support of GNU Pth via --with-pth configure option.
451
Jeremy Hyltonfa2e2c12000-09-26 16:31:30 +0000452- Python/C API now properly exposed to dynamically-loaded extension
453 modules on Reliant UNIX.
Jeremy Hylton1b618592000-09-26 05:32:36 +0000454
455- Changes for the benefit of SunOS 4.1.4 (really!). mmapmodule.c:
456 Don't define MS_SYNC to be zero when it is undefined. Added missing
457 prototypes in posixmodule.c.
458
Jeremy Hyltonfa2e2c12000-09-26 16:31:30 +0000459- Improved support for HP-UX build. Threads should now be correctly
Guido van Rossumf62ed9c2000-09-26 11:16:10 +0000460 configured (on HP-UX 10.20 and 11.00).
Jeremy Hylton1b618592000-09-26 05:32:36 +0000461
Jeremy Hyltonfa2e2c12000-09-26 16:31:30 +0000462- Fix largefile support on older NetBSD systems and OpenBSD by adding
463 define for TELL64.
464
465
466Tools and other miscellany
467
468- ftpmirror: Call to main() is wrapped in if __name__ == "__main__".
469
470- freeze: The modulefinder now works with 2.0 opcodes.
471
472- IDLE:
473 Move hackery of sys.argv until after the Tk instance has been
474 created, which allows the application-specific Tkinter
475 initialization to be executed if present; also pass an explicit
476 className parameter to the Tk() constructor.
Fred Drake64bb3802000-09-26 16:21:35 +0000477
Jeremy Hylton1b618592000-09-26 05:32:36 +0000478
479What's new in 2.0 beta 1?
480=========================
481
Guido van Rossumf2ffce02000-09-05 04:38:34 +0000482Source Incompatibilities
483------------------------
484
485None. Note that 1.6 introduced several incompatibilities with 1.5.2,
486such as single-argument append(), connect() and bind(), and changes to
487str(long) and repr(float).
488
489
490Binary Incompatibilities
491------------------------
492
493- Third party extensions built for Python 1.5.x or 1.6 cannot be used
494with Python 2.0; these extensions will have to be rebuilt for Python
4952.0.
496
497- On Windows, attempting to import a third party extension built for
498Python 1.5.x or 1.6 results in an immediate crash; there's not much we
499can do about this. Check your PYTHONPATH environment variable!
500
501- Python bytecode files (*.pyc and *.pyo) are not compatible between
502releases.
503
504
505Overview of Changes Since 1.6
506-----------------------------
507
508There are many new modules (including brand new XML support through
509the xml package, and i18n support through the gettext module); a list
510of all new modules is included below. Lots of bugs have been fixed.
511
Jeremy Hylton24c3d602000-09-05 19:36:26 +0000512The process for making major new changes to the language has changed
513since Python 1.6. Enhancements must now be documented by a Python
514Enhancement Proposal (PEP) before they can be accepted.
515
Guido van Rossumf2ffce02000-09-05 04:38:34 +0000516There are several important syntax enhancements, described in more
517detail below:
518
519 - Augmented assignment, e.g. x += 1
520
521 - List comprehensions, e.g. [x**2 for x in range(10)]
522
523 - Extended import statement, e.g. import Module as Name
524
525 - Extended print statement, e.g. print >> file, "Hello"
526
527Other important changes:
528
529 - Optional collection of cyclical garbage
530
Jeremy Hylton24c3d602000-09-05 19:36:26 +0000531Python Enhancement Proposal (PEP)
532---------------------------------
533
534PEP stands for Python Enhancement Proposal. A PEP is a design
535document providing information to the Python community, or describing
536a new feature for Python. The PEP should provide a concise technical
537specification of the feature and a rationale for the feature.
538
539We intend PEPs to be the primary mechanisms for proposing new
540features, for collecting community input on an issue, and for
541documenting the design decisions that have gone into Python. The PEP
542author is responsible for building consensus within the community and
543documenting dissenting opinions.
544
545The PEPs are available at http://python.sourceforge.net/peps/.
Guido van Rossumf2ffce02000-09-05 04:38:34 +0000546
547Augmented Assignment
548--------------------
549
550This must have been the most-requested feature of the past years!
551Eleven new assignment operators were added:
552
Guido van Rossume905e952000-09-05 12:42:46 +0000553 += -= *= /= %= **= <<= >>= &= ^= |=
Guido van Rossumf2ffce02000-09-05 04:38:34 +0000554
555For example,
556
557 A += B
558
559is similar to
560
561 A = A + B
562
563except that A is evaluated only once (relevant when A is something
564like dict[index].attr).
565
566However, if A is a mutable object, A may be modified in place. Thus,
567if A is a number or a string, A += B has the same effect as A = A+B
568(except A is only evaluated once); but if a is a list, A += B has the
569same effect as A.extend(B)!
570
571Classes and built-in object types can override the new operators in
572order to implement the in-place behavior; the not-in-place behavior is
573used automatically as a fallback when an object doesn't implement the
574in-place behavior. For classes, the method name is derived from the
575method name for the corresponding not-in-place operator by inserting
576an 'i' in front of the name, e.g. __iadd__ implements in-place
577__add__.
578
579Augmented assignment was implemented by Thomas Wouters.
580
581
582List Comprehensions
583-------------------
584
585This is a flexible new notation for lists whose elements are computed
586from another list (or lists). The simplest form is:
587
588 [<expression> for <variable> in <sequence>]
589
Guido van Rossum56db0952000-09-06 23:34:25 +0000590For example, [i**2 for i in range(4)] yields the list [0, 1, 4, 9].
Guido van Rossumf62ed9c2000-09-26 11:16:10 +0000591This is more efficient than a for loop with a list.append() call.
Guido van Rossumf2ffce02000-09-05 04:38:34 +0000592
593You can also add a condition:
594
595 [<expression> for <variable> in <sequence> if <condition>]
596
597For example, [w for w in words if w == w.lower()] would yield the list
598of words that contain no uppercase characters. This is more efficient
Guido van Rossumf62ed9c2000-09-26 11:16:10 +0000599than a for loop with an if statement and a list.append() call.
Guido van Rossumf2ffce02000-09-05 04:38:34 +0000600
601You can also have nested for loops and more than one 'if' clause. For
602example, here's a function that flattens a sequence of sequences::
603
604 def flatten(seq):
605 return [x for subseq in seq for x in subseq]
606
607 flatten([[0], [1,2,3], [4,5], [6,7,8,9], []])
608
609This prints
610
611 [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
612
613List comprehensions originated as a patch set from Greg Ewing; Skip
Jeremy Hylton24c3d602000-09-05 19:36:26 +0000614Montanaro and Thomas Wouters also contributed. Described by PEP 202.
Guido van Rossumf2ffce02000-09-05 04:38:34 +0000615
616
617Extended Import Statement
618-------------------------
619
620Many people have asked for a way to import a module under a different
621name. This can be accomplished like this:
622
623 import foo
624 bar = foo
625 del foo
626
627but this common idiom gets old quickly. A simple extension of the
628import statement now allows this to be written as follows:
629
630 import foo as bar
631
632There's also a variant for 'from ... import':
633
634 from foo import bar as spam
635
636This also works with packages; e.g. you can write this:
637
638 import test.regrtest as regrtest
639
640Note that 'as' is not a new keyword -- it is recognized only in this
641context (this is only possible because the syntax for the import
642statement doesn't involve expressions).
643
Jeremy Hylton24c3d602000-09-05 19:36:26 +0000644Implemented by Thomas Wouters. Described by PEP 221.
Guido van Rossumf2ffce02000-09-05 04:38:34 +0000645
646
647Extended Print Statement
648------------------------
649
650Easily the most controversial new feature, this extension to the print
651statement adds an option to make the output go to a different file
652than the default sys.stdout.
653
654For example, to write an error message to sys.stderr, you can now
655write:
656
657 print >> sys.stderr, "Error: bad dog!"
658
659As a special feature, if the expression used to indicate the file
Fred Drake45888ff2000-09-29 17:09:11 +0000660evaluates to None, the current value of sys.stdout is used. Thus:
Guido van Rossumf2ffce02000-09-05 04:38:34 +0000661
662 print >> None, "Hello world"
663
664is equivalent to
665
666 print "Hello world"
667
Jeremy Hylton24c3d602000-09-05 19:36:26 +0000668Design and implementation by Barry Warsaw. Described by PEP 214.
Guido van Rossumf2ffce02000-09-05 04:38:34 +0000669
670
671Optional Collection of Cyclical Garbage
672---------------------------------------
673
674Python is now equipped with a garbage collector that can hunt down
675cyclical references between Python objects. It's no replacement for
676reference counting; in fact, it depends on the reference counts being
677correct, and decides that a set of objects belong to a cycle if all
678their reference counts can be accounted for from their references to
679each other. This devious scheme was first proposed by Eric Tiedemann,
680and brought to implementation by Neil Schemenauer.
681
682There's a module "gc" that lets you control some parameters of the
683garbage collection. There's also an option to the configure script
684that lets you enable or disable the garbage collection. In 2.0b1,
685it's on by default, so that we (hopefully) can collect decent user
686experience with this new feature. There are some questions about its
Fred Drake9f11cf82000-09-29 17:54:40 +0000687performance. If it proves to be too much of a problem, we'll turn it
Guido van Rossumf2ffce02000-09-05 04:38:34 +0000688off by default in the final 2.0 release.
689
690
691Smaller Changes
692---------------
693
694A new function zip() was added. zip(seq1, seq2, ...) is equivalent to
695map(None, seq1, seq2, ...) when the sequences have the same length;
696i.e. zip([1,2,3], [10,20,30]) returns [(1,10), (2,20), (3,30)]. When
697the lists are not all the same length, the shortest list wins:
Jeremy Hylton24c3d602000-09-05 19:36:26 +0000698zip([1,2,3], [10,20]) returns [(1,10), (2,20)]. See PEP 201.
Guido van Rossumf2ffce02000-09-05 04:38:34 +0000699
700sys.version_info is a tuple (major, minor, micro, level, serial).
701
702Dictionaries have an odd new method, setdefault(key, default).
703dict.setdefault(key, default) returns dict[key] if it exists; if not,
704it sets dict[key] to default and returns that value. Thus:
705
706 dict.setdefault(key, []).append(item)
707
708does the same work as this common idiom:
709
710 if not dict.has_key(key):
711 dict[key] = []
712 dict[key].append(item)
713
Jeremy Hylton24c3d602000-09-05 19:36:26 +0000714There are two new variants of SyntaxError that are raised for
715indentation-related errors: IndentationError and TabError.
716
717Changed \x to consume exactly two hex digits; see PEP 223. Added \U
718escape that consumes exactly eight hex digits.
Jeremy Hyltonbdebd542000-09-05 18:28:54 +0000719
720The limits on the size of expressions and file in Python source code
721have been raised from 2**16 to 2**32. Previous versions of Python
722were limited because the maximum argument size the Python VM accepted
723was 2**16. This limited the size of object constructor expressions,
724e.g. [1,2,3] or {'a':1, 'b':2}, and the size of source files. This
725limit was raised thanks to a patch by Charles Waldman that effectively
726fixes the problem. It is now much more likely that you will be
727limited by available memory than by an arbitrary limit in Python.
728
729The interpreter's maximum recursion depth can be modified by Python
730programs using sys.getrecursionlimit and sys.setrecursionlimit. This
731limit is the maximum number of recursive calls that can be made by
732Python code. The limit exists to prevent infinite recursion from
733overflowing the C stack and causing a core dump. The default value is
7341000. The maximum safe value for a particular platform can be found
735by running Misc/find_recursionlimit.py.
Guido van Rossumf2ffce02000-09-05 04:38:34 +0000736
737New Modules and Packages
738------------------------
739
740atexit - for registering functions to be called when Python exits.
741
742imputil - Greg Stein's alternative API for writing custom import
743hooks.
744
745pyexpat - an interface to the Expat XML parser, contributed by Paul
746Prescod.
747
748xml - a new package with XML support code organized (so far) in three
749subpackages: xml.dom, xml.sax, and xml.parsers. Describing these
750would fill a volume. There's a special feature whereby a
751user-installed package named _xmlplus overrides the standard
752xmlpackage; this is intended to give the XML SIG a hook to distribute
753backwards-compatible updates to the standard xml package.
754
755webbrowser - a platform-independent API to launch a web browser.
756
757
Guido van Rossume905e952000-09-05 12:42:46 +0000758Changed Modules
759---------------
760
Jeremy Hylton24c3d602000-09-05 19:36:26 +0000761array -- new methods for array objects: count, extend, index, pop, and
762remove
763
764binascii -- new functions b2a_hex and a2b_hex that convert between
765binary data and its hex representation
766
Jeremy Hyltonbdebd542000-09-05 18:28:54 +0000767calendar -- Many new functions that support features including control
768over which day of the week is the first day, returning strings instead
769of printing them. Also new symbolic constants for days of week,
770e.g. MONDAY, ..., SUNDAY.
771
772cgi -- FieldStorage objects have a getvalue method that works like a
773dictionary's get method and returns the value attribute of the object.
774
775ConfigParser -- The parser object has new methods has_option,
776remove_section, remove_option, set, and write. They allow the module
777to be used for writing config files as well as reading them.
778
779ftplib -- ntransfercmd(), transfercmd(), and retrbinary() all now
Guido van Rossume905e952000-09-05 12:42:46 +0000780optionally support the RFC 959 REST command.
781
Jeremy Hyltonbdebd542000-09-05 18:28:54 +0000782gzip -- readline and readlines now accept optional size arguments
Guido van Rossume905e952000-09-05 12:42:46 +0000783
Jeremy Hyltonbdebd542000-09-05 18:28:54 +0000784httplib -- New interfaces and support for HTTP/1.1 by Greg Stein. See
785the module doc strings for details.
Guido van Rossum830ca2a2000-09-05 15:34:16 +0000786
Jeremy Hylton24c3d602000-09-05 19:36:26 +0000787locale -- implement getdefaultlocale for Win32 and Macintosh
788
789marshal -- no longer dumps core when marshaling deeply nested or
790recursive data structures
791
792os -- new functions isatty, seteuid, setegid, setreuid, setregid
793
Jeremy Hyltonbdebd542000-09-05 18:28:54 +0000794os/popen2 -- popen2/popen3/popen4 support under Windows. popen2/popen3
795support under Unix.
796
Jeremy Hylton24c3d602000-09-05 19:36:26 +0000797os/pty -- support for openpty and forkpty
Jeremy Hyltonbdebd542000-09-05 18:28:54 +0000798
799os.path -- fix semantics of os.path.commonprefix
800
801smtplib -- support for sending very long messages
802
803socket -- new function getfqdn()
804
805readline -- new functions to read, write and truncate history files.
806The readline section of the library reference manual contains an
807example.
808
Jeremy Hylton24c3d602000-09-05 19:36:26 +0000809select -- add interface to poll system call
810
Jeremy Hyltonbdebd542000-09-05 18:28:54 +0000811shutil -- new copyfileobj function
812
813SimpleHTTPServer, CGIHTTPServer -- Fix problems with buffering in the
814HTTP server.
815
Jeremy Hylton24c3d602000-09-05 19:36:26 +0000816Tkinter -- optimization of function flatten
Jeremy Hyltonbdebd542000-09-05 18:28:54 +0000817
818urllib -- scans environment variables for proxy configuration,
Tim Peters8b092332000-09-05 20:15:25 +0000819e.g. http_proxy.
Jeremy Hyltonbdebd542000-09-05 18:28:54 +0000820
821whichdb -- recognizes dumbdbm format
Guido van Rossume905e952000-09-05 12:42:46 +0000822
823
824Obsolete Modules
825----------------
826
827None. However note that 1.6 made a whole slew of modules obsolete:
828stdwin, soundex, cml, cmpcache, dircache, dump, find, grep, packmail,
829poly, zmod, strop, util, whatsound.
830
831
832Changed, New, Obsolete Tools
833----------------------------
834
Tim Peters8b092332000-09-05 20:15:25 +0000835None.
Guido van Rossume905e952000-09-05 12:42:46 +0000836
837
Guido van Rossumf2ffce02000-09-05 04:38:34 +0000838C-level Changes
839---------------
840
841Several cleanup jobs were carried out throughout the source code.
842
843All C code was converted to ANSI C; we got rid of all uses of the
844Py_PROTO() macro, which makes the header files a lot more readable.
845
846Most of the portability hacks were moved to a new header file,
847pyport.h; several other new header files were added and some old
848header files were removed, in an attempt to create a more rational set
849of header files. (Few of these ever need to be included explicitly;
850they are all included by Python.h.)
851
Guido van Rossumf2ffce02000-09-05 04:38:34 +0000852Trent Mick ensured portability to 64-bit platforms, under both Linux
Jeremy Hylton24c3d602000-09-05 19:36:26 +0000853and Win64, especially for the new Intel Itanium processor. Mick also
854added large file support for Linux64 and Win64.
Guido van Rossumf2ffce02000-09-05 04:38:34 +0000855
Jeremy Hyltonbdebd542000-09-05 18:28:54 +0000856The C APIs to return an object's size have been update to consistently
857use the form PyXXX_Size, e.g. PySequence_Size and PyDict_Size. In
858previous versions, the abstract interfaces used PyXXX_Length and the
859concrete interfaces used PyXXX_Size. The old names,
860e.g. PyObject_Length, are still available for backwards compatibility
861at the API level, but are deprecated.
862
Jeremy Hylton24c3d602000-09-05 19:36:26 +0000863The PyOS_CheckStack function has been implemented on Windows by
864Fredrik Lundh. It prevents Python from failing with a stack overflow
865on Windows.
Jeremy Hyltonbdebd542000-09-05 18:28:54 +0000866
867The GC changes resulted in creation of two new slots on object,
868tp_traverse and tp_clear. The augmented assignment changes result in
Guido van Rossum4338a282000-09-06 13:02:08 +0000869the creation of a new slot for each in-place operator.
Jeremy Hyltonbdebd542000-09-05 18:28:54 +0000870
871The GC API creates new requirements for container types implemented in
Guido van Rossum4338a282000-09-06 13:02:08 +0000872C extension modules. See Include/objimpl.h for details.
Jeremy Hyltonbdebd542000-09-05 18:28:54 +0000873
Jeremy Hylton24c3d602000-09-05 19:36:26 +0000874PyErr_Format has been updated to automatically calculate the size of
875the buffer needed to hold the formatted result string. This change
876prevents crashes caused by programmer error.
Jeremy Hyltonbdebd542000-09-05 18:28:54 +0000877
Jeremy Hylton24c3d602000-09-05 19:36:26 +0000878New C API calls: PyObject_AsFileDescriptor, PyErr_WriteUnraisable.
Guido van Rossume905e952000-09-05 12:42:46 +0000879
Jeremy Hylton24c3d602000-09-05 19:36:26 +0000880PyRun_AnyFileEx, PyRun_SimpleFileEx, PyRun_FileEx -- New functions
881that are the same as their non-Ex counterparts except they take an
882extra flag argument that tells them to close the file when done.
883
884XXX There were other API changes that should be fleshed out here.
Guido van Rossumab9d6f01998-08-10 22:01:13 +0000885
Tim Peters8b092332000-09-05 20:15:25 +0000886
887Windows Changes
888---------------
889
890New popen2/popen3/peopen4 in os module (see Changed Modules above).
891
892os.popen is much more usable on Windows 95 and 98. See Microsoft
893Knowledge Base article Q150956. The Win9x workaround described there
894is implemented by the new w9xpopen.exe helper in the root of your
895Python installation. Note that Python uses this internally; it is not
896a standalone program.
897
898Administrator privileges are no longer required to install Python
899on Windows NT or Windows 2000. If you have administrator privileges,
900Python's registry info will be written under HKEY_LOCAL_MACHINE.
901Otherwise the installer backs off to writing Python's registry info
Guido van Rossum4338a282000-09-06 13:02:08 +0000902under HKEY_CURRENT_USER. The latter is sufficient for all "normal"
Tim Peters8b092332000-09-05 20:15:25 +0000903uses of Python, but will prevent some advanced uses from working
904(for example, running a Python script as an NT service, or possibly
905from CGI).
906
907[This was new in 1.6] The installer no longer runs a separate Tcl/Tk
908installer; instead, it installs the needed Tcl/Tk files directly in the
909Python directory. If you already have a Tcl/Tk installation, this
910wastes some disk space (about 4 Megs) but avoids problems with
911conflicting Tcl/Tk installations, and makes it much easier for Python
912to ensure that Tcl/Tk can find all its files.
913
914[This was new in 1.6] The Windows installer now installs by default in
915\Python20\ on the default volume, instead of \Program Files\Python-2.0\.
916
Guido van Rossumf62ed9c2000-09-26 11:16:10 +0000917
918Updates to the changes between 1.5.2 and 1.6
919--------------------------------------------
920
921The 1.6 NEWS file can't be changed after the release is done, so here
922is some late-breaking news:
923
924New APIs in locale.py: normalize(), getdefaultlocale(), resetlocale(),
925and changes to getlocale() and setlocale().
926
927The new module is now enabled per default.
928
929It is not true that the encodings codecs cannot be used for normal
930strings: the string.encode() (which is also present on 8-bit strings
931!) allows using them for 8-bit strings too, e.g. to convert files from
932cp1252 (Windows) to latin-1 or vice-versa.
933
934Japanese codecs are available from Tamito KAJIYAMA:
935http://pseudo.grad.sccs.chukyo-u.ac.jp/~kajiyama/python/
936
937
Guido van Rossumab9d6f01998-08-10 22:01:13 +0000938======================================================================