blob: f75f5a66ae56c4edcf6e2b70d48a0d749d715bad [file] [log] [blame]
Jeremy Hylton1b618592000-09-26 05:32:36 +00001What's New in Python 2.0b2?
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 Hylton1b618592000-09-26 05:32:36 +000017
18What's new in 2.0 beta 2 (since beta 1)?
19========================================
20
21Core language, builtins, and interpreter
22
Tim Peters482c0212000-09-26 06:33:09 +000023- Add support for unbounded ints in %d,i,u,x,X,o formats; for example
Guido van Rossumf62ed9c2000-09-26 11:16:10 +000024 "%d" % 2L**64 == "18446744073709551616".
Jeremy Hylton1b618592000-09-26 05:32:36 +000025
Guido van Rossumf62ed9c2000-09-26 11:16:10 +000026- Add -h and -V command line options to print the usage message and
27 Python version number and exit immediately.
28
Jeremy Hyltonfa2e2c12000-09-26 16:31:30 +000029- eval() and exec accept Unicode objects as code parameters.
30
31- getattr() and setattr() now also accept Unicode objects for the
32 attribute name, which are converted to strings using the default
33 encoding before lookup.
34
35- Multiplication on string and Unicode now does proper bounds
36 checking; e.g. 'a' * 65536 * 65536 will raise ValueError, "repeated
37 string is too long."
38
39- Better error message when continue is found in try statement in a
40 loop.
41
Jeremy Hylton1b618592000-09-26 05:32:36 +000042
43Standard library and extensions
44
Guido van Rossumf62ed9c2000-09-26 11:16:10 +000045- array: reverse() method of array now works. buffer_info() now does
Jeremy Hylton1b618592000-09-26 05:32:36 +000046 argument checking; it still takes no arguments.
47
Guido van Rossumf62ed9c2000-09-26 11:16:10 +000048- asyncore/asynchat: Included most recent version from Sam Rushing.
Jeremy Hylton1b618592000-09-26 05:32:36 +000049
Guido van Rossumf62ed9c2000-09-26 11:16:10 +000050- cgi: Accept '&' or ';' as separator characters when parsing form data.
Jeremy Hylton1b618592000-09-26 05:32:36 +000051
Guido van Rossumf62ed9c2000-09-26 11:16:10 +000052- CGIHTTPServer: Now works on Windows (and perhaps even Mac).
Jeremy Hylton1b618592000-09-26 05:32:36 +000053
54- ConfigParser: When reading the file, options spelled in upper case
Guido van Rossumf62ed9c2000-09-26 11:16:10 +000055 letters are now correctly converted to lowercase.
Jeremy Hylton1b618592000-09-26 05:32:36 +000056
57- copy: Copy Unicode objects atomically.
58
Guido van Rossumf62ed9c2000-09-26 11:16:10 +000059- cPickle: Fail gracefully when copy_reg can't be imported.
Jeremy Hylton1b618592000-09-26 05:32:36 +000060
Guido van Rossumf62ed9c2000-09-26 11:16:10 +000061- cStringIO: Implemented readlines() method.
Jeremy Hylton1b618592000-09-26 05:32:36 +000062
Fred Drake67233bc2000-09-26 16:40:27 +000063- dbm: Add get() and setdefault() methods to dbm object. Add constant
64 `library' to module that names the library used. Added doc strings
65 and method names to error messages. Uses configure to determine
66 which ndbm.h file to include; Berkeley DB's nbdm and GDBM's ndbm is
67 now available options.
Jeremy Hylton1b618592000-09-26 05:32:36 +000068
69- distutils: Update to version 0.9.3.
70
71- dl: Add several dl.RTLD_ constants.
72
73- fpectl: Now supported on FreeBSD.
74
75- gc: Add DEBUG_SAVEALL option. When enabled all garbage objects
76 found by the collector will be saved in gc.garbage. This is useful
77 for debugging a program that creates reference cycles.
78
Guido van Rossumf62ed9c2000-09-26 11:16:10 +000079- httplib: Three changes: Restore support for set_debuglevel feature
Jeremy Hylton1b618592000-09-26 05:32:36 +000080 of HTTP class. Do not close socket on zero-length response. Do not
81 crash when server sends invalid content-length header.
82
Guido van Rossumf62ed9c2000-09-26 11:16:10 +000083- mailbox: Mailbox class conforms better to qmail specifications.
Jeremy Hylton1b618592000-09-26 05:32:36 +000084
Jeremy Hyltonfa2e2c12000-09-26 16:31:30 +000085- marshal: When reading a short, sign-extend on platforms where shorts
86 are bigger than 16 bits. When reading a long, repair the unportable
87 sign extension that was being done for 64-bit machines. (It assumed
88 that signed right shift sign-extends.)
89
Guido van Rossumf62ed9c2000-09-26 11:16:10 +000090- operator: Add contains(), invert(), __invert__() as aliases for
91 __contains__(), inv(), and __inv__() respectively.
Jeremy Hylton1b618592000-09-26 05:32:36 +000092
Guido van Rossumf62ed9c2000-09-26 11:16:10 +000093- os: Add support for popen2() and popen3() on all platforms where
94 fork() exists. (popen4() is still in the works.)
Jeremy Hylton1b618592000-09-26 05:32:36 +000095
Guido van Rossumf62ed9c2000-09-26 11:16:10 +000096- os: (Windows only:) Add startfile() function that acts like double-
Tim Peters482c0212000-09-26 06:33:09 +000097 clicking on a file in Explorer (or passing the file name to the
98 DOS "start" command).
Jeremy Hylton1b618592000-09-26 05:32:36 +000099
Guido van Rossumf62ed9c2000-09-26 11:16:10 +0000100- os.path: (Windows, DOS:) Treat trailing colon correctly in
Tim Peters482c0212000-09-26 06:33:09 +0000101 os.path.join. os.path.join("a:", "b") yields "a:b".
Jeremy Hylton1b618592000-09-26 05:32:36 +0000102
103- pickle: Now raises ValueError when an invalid pickle that contains
104 a non-string repr where a string repr was expected. This behavior
105 matches cPickle.
106
Guido van Rossumf62ed9c2000-09-26 11:16:10 +0000107- posixfile: Remove broken __del__() method.
Jeremy Hylton1b618592000-09-26 05:32:36 +0000108
Guido van Rossumf62ed9c2000-09-26 11:16:10 +0000109- py_compile: support CR+LF line terminators in source file.
Jeremy Hylton1b618592000-09-26 05:32:36 +0000110
111- readline: Does not immediately exit when ^C is hit when readline and
Jeremy Hyltonfa2e2c12000-09-26 16:31:30 +0000112 threads are configured. Adds definition of rl_library_version. (The
Guido van Rossumf62ed9c2000-09-26 11:16:10 +0000113 latter addition requires GNU readline 2.2 or later.)
Jeremy Hylton1b618592000-09-26 05:32:36 +0000114
115- rfc822: Domain literals returned by AddrlistClass method
Guido van Rossumf62ed9c2000-09-26 11:16:10 +0000116 getdomainliteral() are now properly wrapped in brackets.
Jeremy Hylton1b618592000-09-26 05:32:36 +0000117
118- site: sys.setdefaultencoding() should only be called in case the
Tim Peters482c0212000-09-26 06:33:09 +0000119 standard default encoding ("ascii") is changed. This saves quite a
Jeremy Hylton1b618592000-09-26 05:32:36 +0000120 few cycles during startup since the first call to
121 setdefaultencoding() will initialize the codec registry and the
122 encodings package.
123
Guido van Rossumf62ed9c2000-09-26 11:16:10 +0000124- socket: Support for size hint in readlines() method of object returned
125 by makefile().
Jeremy Hylton1b618592000-09-26 05:32:36 +0000126
Guido van Rossumf62ed9c2000-09-26 11:16:10 +0000127- sre: Added experimental expand() method to match objects. Does not
Jeremy Hylton1b618592000-09-26 05:32:36 +0000128 user buffer interface on Unicode strings. Does not hang if group id
129 is followed by whitespace.
130
Fred Drake64bb3802000-09-26 16:21:35 +0000131- StringIO: Size hint in readlines() is now supported as documented.
Jeremy Hylton1b618592000-09-26 05:32:36 +0000132
133- struct: Check ranges for bytes and shorts.
134
135- urllib: Improved handling of win32 proxy settings. Fixed quote and
Guido van Rossumf62ed9c2000-09-26 11:16:10 +0000136 quote_plus functions so that the always encode a comma.
Jeremy Hylton1b618592000-09-26 05:32:36 +0000137
138- Tkinter: Image objects are now guaranteed to have unique ids. Set
139 event.delta to zero if Tk version doesn't support mousewheel.
140 Removed some debugging prints.
141
Guido van Rossumf62ed9c2000-09-26 11:16:10 +0000142- UserList: now implements __contains__().
Jeremy Hylton1b618592000-09-26 05:32:36 +0000143
Fred Drake67233bc2000-09-26 16:40:27 +0000144- webbrowser: On Windows, use os.startfile() instead of os.popen(),
Guido van Rossumf62ed9c2000-09-26 11:16:10 +0000145 which works around a bug in Norton AntiVirus 2000 that leads directly
146 to a Blue Screen freeze.
Jeremy Hylton1b618592000-09-26 05:32:36 +0000147
148- xml: New version detection code allows PyXML to override standard
149 XML package if PyXML version is greater than 0.6.1.
150
Fred Drake64bb3802000-09-26 16:21:35 +0000151- xml.dom: DOM level 1 support for basic XML. Includes xml.dom.minidom
152 (conventional DOM), and xml.dom.pulldom, which allows building the DOM
153 tree only for nodes which are sufficiently interesting to a specific
154 application. Does not provide the HTML-specific extensions. Still
155 undocumented.
Jeremy Hylton1b618592000-09-26 05:32:36 +0000156
Fred Drake64bb3802000-09-26 16:21:35 +0000157- xml.sax: SAX 2 support for Python, including all the handler
158 interfaces needed to process XML 1.0 compliant XML. Some
159 documentation is already available.
Jeremy Hylton1b618592000-09-26 05:32:36 +0000160
Fred Drake64bb3802000-09-26 16:21:35 +0000161- pyexpat: Renamed to xml.parsers.expat since this is part of the new,
162 packagized XML support.
Jeremy Hylton1b618592000-09-26 05:32:36 +0000163
Guido van Rossumf62ed9c2000-09-26 11:16:10 +0000164
Jeremy Hylton1b618592000-09-26 05:32:36 +0000165C API
166
167- Add three new convenience functions for module initialization --
168 PyModule_AddObject(), PyModule_AddIntConstant(), and
169 PyModule_AddStringConstant().
170
Jeremy Hyltonfa2e2c12000-09-26 16:31:30 +0000171- Cleaned up definition of NULL in C source code; all definitions were
Jeremy Hylton1b618592000-09-26 05:32:36 +0000172 removed and add #error to Python.h if NULL isn't defined after
173 #include of stdio.h.
174
Guido van Rossumf62ed9c2000-09-26 11:16:10 +0000175- Py_PROTO() macros that were removed in 2.0b1 have been restored for
Jeremy Hylton1b618592000-09-26 05:32:36 +0000176 backwards compatibility (at the source level) with old extensions.
177
Guido van Rossumf62ed9c2000-09-26 11:16:10 +0000178- A wrapper API was added for signal() and sigaction(). Instead of
179 either function, always use PyOS_getsig() to get a signal handler
180 and PyOS_setsig() to set one. A new convenience typedef
181 PyOS_sighandler_t is defined for the type of signal handlers.
Jeremy Hylton1b618592000-09-26 05:32:36 +0000182
Guido van Rossumf62ed9c2000-09-26 11:16:10 +0000183- Add PyString_AsStringAndSize() function that provides access to the
Jeremy Hylton1b618592000-09-26 05:32:36 +0000184 internal data buffer and size of a string object -- or the default
185 encoded version of a Unicode object.
186
Jeremy Hyltonfa2e2c12000-09-26 16:31:30 +0000187- PyString_Size() and PyString_AsString() accept Unicode objects.
188
Guido van Rossumf62ed9c2000-09-26 11:16:10 +0000189- The standard header <limits.h> is now included by Python.h (if it
Fred Drake64bb3802000-09-26 16:21:35 +0000190 exists). INT_MAX and LONG_MAX will always be defined, even if
191 <limits.h> is not available.
Guido van Rossumf62ed9c2000-09-26 11:16:10 +0000192
Jeremy Hyltonfa2e2c12000-09-26 16:31:30 +0000193- PyFloat_FromString takes a second argument, pend, that was
194 effectively useless. It is now officially useless but preserved for
195 backwards compatibility. If the pend argument is not NULL, *pend is
196 set to NULL.
197
198- PyObject_GetAttr() and PyObject_SetAttr() now accept Unicode objects
199 for the attribute name. See note on getattr() above.
200
201- A few bug fixes to argument processing for Unicode.
202 PyArg_ParseTupleAndKeywords() now accepts "es#" and "es".
203 PyArg_Parse() special cases "s#" for Unicode objects; it returns a
204 pointer to the default encoded string data instead of to the raw
205 UTF-16.
206
207- Py_BuildValue accepts B format (for bgen-generated code).
208
Guido van Rossumf62ed9c2000-09-26 11:16:10 +0000209
Jeremy Hylton1b618592000-09-26 05:32:36 +0000210Internals
211
212- On Unix, fix code for finding Python installation directory so that
213 it works when argv[0] is a relative path.
214
Jeremy Hyltonfa2e2c12000-09-26 16:31:30 +0000215- Added a true tnicode_internal_encode() function and fixed the
Guido van Rossumf62ed9c2000-09-26 11:16:10 +0000216 unicode_internal_decode function() to support Unicode objects directly
Jeremy Hylton1b618592000-09-26 05:32:36 +0000217 rather than by generating a copy of the object.
218
Tim Peters482c0212000-09-26 06:33:09 +0000219- Several of the internal Unicode tables are much smaller now, and
220 the source code should be much friendlier to weaker compilers.
Jeremy Hylton1b618592000-09-26 05:32:36 +0000221
Jeremy Hyltonfa2e2c12000-09-26 16:31:30 +0000222- Fixed GC bug that caused some instances to be removed from the
223 container set while they were still live.
224
225- Fixed refcount problem in instance deallocation that only occurred
226 when Py_REF_DEBUG was defined and Py_TRACE_REFS was not.
227
228- In the garbage collector: No longer sets an object's type slot to
229 NULL. Fix bug in collection of tuples.
230
231- On Windows, getpythonregpath is now protected against null data in
232 registry key.
233
234- On Unix, create .pyc/.pyo files with O_EXCL flag to avoid a race
235 condition.
236
Guido van Rossumf62ed9c2000-09-26 11:16:10 +0000237
Jeremy Hylton1b618592000-09-26 05:32:36 +0000238Build and platform-specific issues
239
240- Better support of GNU Pth via --with-pth configure option.
241
Jeremy Hyltonfa2e2c12000-09-26 16:31:30 +0000242- Python/C API now properly exposed to dynamically-loaded extension
243 modules on Reliant UNIX.
Jeremy Hylton1b618592000-09-26 05:32:36 +0000244
245- Changes for the benefit of SunOS 4.1.4 (really!). mmapmodule.c:
246 Don't define MS_SYNC to be zero when it is undefined. Added missing
247 prototypes in posixmodule.c.
248
Jeremy Hyltonfa2e2c12000-09-26 16:31:30 +0000249- Improved support for HP-UX build. Threads should now be correctly
Guido van Rossumf62ed9c2000-09-26 11:16:10 +0000250 configured (on HP-UX 10.20 and 11.00).
Jeremy Hylton1b618592000-09-26 05:32:36 +0000251
Jeremy Hyltonfa2e2c12000-09-26 16:31:30 +0000252- Fix largefile support on older NetBSD systems and OpenBSD by adding
253 define for TELL64.
254
255
256Tools and other miscellany
257
258- ftpmirror: Call to main() is wrapped in if __name__ == "__main__".
259
260- freeze: The modulefinder now works with 2.0 opcodes.
261
262- IDLE:
263 Move hackery of sys.argv until after the Tk instance has been
264 created, which allows the application-specific Tkinter
265 initialization to be executed if present; also pass an explicit
266 className parameter to the Tk() constructor.
Fred Drake64bb3802000-09-26 16:21:35 +0000267
Jeremy Hylton1b618592000-09-26 05:32:36 +0000268
269What's new in 2.0 beta 1?
270=========================
271
Guido van Rossumf2ffce02000-09-05 04:38:34 +0000272Source Incompatibilities
273------------------------
274
275None. Note that 1.6 introduced several incompatibilities with 1.5.2,
276such as single-argument append(), connect() and bind(), and changes to
277str(long) and repr(float).
278
279
280Binary Incompatibilities
281------------------------
282
283- Third party extensions built for Python 1.5.x or 1.6 cannot be used
284with Python 2.0; these extensions will have to be rebuilt for Python
2852.0.
286
287- On Windows, attempting to import a third party extension built for
288Python 1.5.x or 1.6 results in an immediate crash; there's not much we
289can do about this. Check your PYTHONPATH environment variable!
290
291- Python bytecode files (*.pyc and *.pyo) are not compatible between
292releases.
293
294
295Overview of Changes Since 1.6
296-----------------------------
297
298There are many new modules (including brand new XML support through
299the xml package, and i18n support through the gettext module); a list
300of all new modules is included below. Lots of bugs have been fixed.
301
Jeremy Hylton24c3d602000-09-05 19:36:26 +0000302The process for making major new changes to the language has changed
303since Python 1.6. Enhancements must now be documented by a Python
304Enhancement Proposal (PEP) before they can be accepted.
305
Guido van Rossumf2ffce02000-09-05 04:38:34 +0000306There are several important syntax enhancements, described in more
307detail below:
308
309 - Augmented assignment, e.g. x += 1
310
311 - List comprehensions, e.g. [x**2 for x in range(10)]
312
313 - Extended import statement, e.g. import Module as Name
314
315 - Extended print statement, e.g. print >> file, "Hello"
316
317Other important changes:
318
319 - Optional collection of cyclical garbage
320
Jeremy Hylton24c3d602000-09-05 19:36:26 +0000321Python Enhancement Proposal (PEP)
322---------------------------------
323
324PEP stands for Python Enhancement Proposal. A PEP is a design
325document providing information to the Python community, or describing
326a new feature for Python. The PEP should provide a concise technical
327specification of the feature and a rationale for the feature.
328
329We intend PEPs to be the primary mechanisms for proposing new
330features, for collecting community input on an issue, and for
331documenting the design decisions that have gone into Python. The PEP
332author is responsible for building consensus within the community and
333documenting dissenting opinions.
334
335The PEPs are available at http://python.sourceforge.net/peps/.
Guido van Rossumf2ffce02000-09-05 04:38:34 +0000336
337Augmented Assignment
338--------------------
339
340This must have been the most-requested feature of the past years!
341Eleven new assignment operators were added:
342
Guido van Rossume905e952000-09-05 12:42:46 +0000343 += -= *= /= %= **= <<= >>= &= ^= |=
Guido van Rossumf2ffce02000-09-05 04:38:34 +0000344
345For example,
346
347 A += B
348
349is similar to
350
351 A = A + B
352
353except that A is evaluated only once (relevant when A is something
354like dict[index].attr).
355
356However, if A is a mutable object, A may be modified in place. Thus,
357if A is a number or a string, A += B has the same effect as A = A+B
358(except A is only evaluated once); but if a is a list, A += B has the
359same effect as A.extend(B)!
360
361Classes and built-in object types can override the new operators in
362order to implement the in-place behavior; the not-in-place behavior is
363used automatically as a fallback when an object doesn't implement the
364in-place behavior. For classes, the method name is derived from the
365method name for the corresponding not-in-place operator by inserting
366an 'i' in front of the name, e.g. __iadd__ implements in-place
367__add__.
368
369Augmented assignment was implemented by Thomas Wouters.
370
371
372List Comprehensions
373-------------------
374
375This is a flexible new notation for lists whose elements are computed
376from another list (or lists). The simplest form is:
377
378 [<expression> for <variable> in <sequence>]
379
Guido van Rossum56db0952000-09-06 23:34:25 +0000380For example, [i**2 for i in range(4)] yields the list [0, 1, 4, 9].
Guido van Rossumf62ed9c2000-09-26 11:16:10 +0000381This is more efficient than a for loop with a list.append() call.
Guido van Rossumf2ffce02000-09-05 04:38:34 +0000382
383You can also add a condition:
384
385 [<expression> for <variable> in <sequence> if <condition>]
386
387For example, [w for w in words if w == w.lower()] would yield the list
388of words that contain no uppercase characters. This is more efficient
Guido van Rossumf62ed9c2000-09-26 11:16:10 +0000389than a for loop with an if statement and a list.append() call.
Guido van Rossumf2ffce02000-09-05 04:38:34 +0000390
391You can also have nested for loops and more than one 'if' clause. For
392example, here's a function that flattens a sequence of sequences::
393
394 def flatten(seq):
395 return [x for subseq in seq for x in subseq]
396
397 flatten([[0], [1,2,3], [4,5], [6,7,8,9], []])
398
399This prints
400
401 [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
402
403List comprehensions originated as a patch set from Greg Ewing; Skip
Jeremy Hylton24c3d602000-09-05 19:36:26 +0000404Montanaro and Thomas Wouters also contributed. Described by PEP 202.
Guido van Rossumf2ffce02000-09-05 04:38:34 +0000405
406
407Extended Import Statement
408-------------------------
409
410Many people have asked for a way to import a module under a different
411name. This can be accomplished like this:
412
413 import foo
414 bar = foo
415 del foo
416
417but this common idiom gets old quickly. A simple extension of the
418import statement now allows this to be written as follows:
419
420 import foo as bar
421
422There's also a variant for 'from ... import':
423
424 from foo import bar as spam
425
426This also works with packages; e.g. you can write this:
427
428 import test.regrtest as regrtest
429
430Note that 'as' is not a new keyword -- it is recognized only in this
431context (this is only possible because the syntax for the import
432statement doesn't involve expressions).
433
Jeremy Hylton24c3d602000-09-05 19:36:26 +0000434Implemented by Thomas Wouters. Described by PEP 221.
Guido van Rossumf2ffce02000-09-05 04:38:34 +0000435
436
437Extended Print Statement
438------------------------
439
440Easily the most controversial new feature, this extension to the print
441statement adds an option to make the output go to a different file
442than the default sys.stdout.
443
444For example, to write an error message to sys.stderr, you can now
445write:
446
447 print >> sys.stderr, "Error: bad dog!"
448
449As a special feature, if the expression used to indicate the file
450evaluates to None, the current value of sys.stdout used. Thus:
451
452 print >> None, "Hello world"
453
454is equivalent to
455
456 print "Hello world"
457
Jeremy Hylton24c3d602000-09-05 19:36:26 +0000458Design and implementation by Barry Warsaw. Described by PEP 214.
Guido van Rossumf2ffce02000-09-05 04:38:34 +0000459
460
461Optional Collection of Cyclical Garbage
462---------------------------------------
463
464Python is now equipped with a garbage collector that can hunt down
465cyclical references between Python objects. It's no replacement for
466reference counting; in fact, it depends on the reference counts being
467correct, and decides that a set of objects belong to a cycle if all
468their reference counts can be accounted for from their references to
469each other. This devious scheme was first proposed by Eric Tiedemann,
470and brought to implementation by Neil Schemenauer.
471
472There's a module "gc" that lets you control some parameters of the
473garbage collection. There's also an option to the configure script
474that lets you enable or disable the garbage collection. In 2.0b1,
475it's on by default, so that we (hopefully) can collect decent user
476experience with this new feature. There are some questions about its
477performance. if it proves to be too much of a problem, we'll turn it
478off by default in the final 2.0 release.
479
480
481Smaller Changes
482---------------
483
484A new function zip() was added. zip(seq1, seq2, ...) is equivalent to
485map(None, seq1, seq2, ...) when the sequences have the same length;
486i.e. zip([1,2,3], [10,20,30]) returns [(1,10), (2,20), (3,30)]. When
487the lists are not all the same length, the shortest list wins:
Jeremy Hylton24c3d602000-09-05 19:36:26 +0000488zip([1,2,3], [10,20]) returns [(1,10), (2,20)]. See PEP 201.
Guido van Rossumf2ffce02000-09-05 04:38:34 +0000489
490sys.version_info is a tuple (major, minor, micro, level, serial).
491
492Dictionaries have an odd new method, setdefault(key, default).
493dict.setdefault(key, default) returns dict[key] if it exists; if not,
494it sets dict[key] to default and returns that value. Thus:
495
496 dict.setdefault(key, []).append(item)
497
498does the same work as this common idiom:
499
500 if not dict.has_key(key):
501 dict[key] = []
502 dict[key].append(item)
503
Jeremy Hylton24c3d602000-09-05 19:36:26 +0000504There are two new variants of SyntaxError that are raised for
505indentation-related errors: IndentationError and TabError.
506
507Changed \x to consume exactly two hex digits; see PEP 223. Added \U
508escape that consumes exactly eight hex digits.
Jeremy Hyltonbdebd542000-09-05 18:28:54 +0000509
510The limits on the size of expressions and file in Python source code
511have been raised from 2**16 to 2**32. Previous versions of Python
512were limited because the maximum argument size the Python VM accepted
513was 2**16. This limited the size of object constructor expressions,
514e.g. [1,2,3] or {'a':1, 'b':2}, and the size of source files. This
515limit was raised thanks to a patch by Charles Waldman that effectively
516fixes the problem. It is now much more likely that you will be
517limited by available memory than by an arbitrary limit in Python.
518
519The interpreter's maximum recursion depth can be modified by Python
520programs using sys.getrecursionlimit and sys.setrecursionlimit. This
521limit is the maximum number of recursive calls that can be made by
522Python code. The limit exists to prevent infinite recursion from
523overflowing the C stack and causing a core dump. The default value is
5241000. The maximum safe value for a particular platform can be found
525by running Misc/find_recursionlimit.py.
Guido van Rossumf2ffce02000-09-05 04:38:34 +0000526
527New Modules and Packages
528------------------------
529
530atexit - for registering functions to be called when Python exits.
531
532imputil - Greg Stein's alternative API for writing custom import
533hooks.
534
535pyexpat - an interface to the Expat XML parser, contributed by Paul
536Prescod.
537
538xml - a new package with XML support code organized (so far) in three
539subpackages: xml.dom, xml.sax, and xml.parsers. Describing these
540would fill a volume. There's a special feature whereby a
541user-installed package named _xmlplus overrides the standard
542xmlpackage; this is intended to give the XML SIG a hook to distribute
543backwards-compatible updates to the standard xml package.
544
545webbrowser - a platform-independent API to launch a web browser.
546
547
Guido van Rossume905e952000-09-05 12:42:46 +0000548Changed Modules
549---------------
550
Jeremy Hylton24c3d602000-09-05 19:36:26 +0000551array -- new methods for array objects: count, extend, index, pop, and
552remove
553
554binascii -- new functions b2a_hex and a2b_hex that convert between
555binary data and its hex representation
556
Jeremy Hyltonbdebd542000-09-05 18:28:54 +0000557calendar -- Many new functions that support features including control
558over which day of the week is the first day, returning strings instead
559of printing them. Also new symbolic constants for days of week,
560e.g. MONDAY, ..., SUNDAY.
561
562cgi -- FieldStorage objects have a getvalue method that works like a
563dictionary's get method and returns the value attribute of the object.
564
565ConfigParser -- The parser object has new methods has_option,
566remove_section, remove_option, set, and write. They allow the module
567to be used for writing config files as well as reading them.
568
569ftplib -- ntransfercmd(), transfercmd(), and retrbinary() all now
Guido van Rossume905e952000-09-05 12:42:46 +0000570optionally support the RFC 959 REST command.
571
Jeremy Hyltonbdebd542000-09-05 18:28:54 +0000572gzip -- readline and readlines now accept optional size arguments
Guido van Rossume905e952000-09-05 12:42:46 +0000573
Jeremy Hyltonbdebd542000-09-05 18:28:54 +0000574httplib -- New interfaces and support for HTTP/1.1 by Greg Stein. See
575the module doc strings for details.
Guido van Rossum830ca2a2000-09-05 15:34:16 +0000576
Jeremy Hylton24c3d602000-09-05 19:36:26 +0000577locale -- implement getdefaultlocale for Win32 and Macintosh
578
579marshal -- no longer dumps core when marshaling deeply nested or
580recursive data structures
581
582os -- new functions isatty, seteuid, setegid, setreuid, setregid
583
Jeremy Hyltonbdebd542000-09-05 18:28:54 +0000584os/popen2 -- popen2/popen3/popen4 support under Windows. popen2/popen3
585support under Unix.
586
Jeremy Hylton24c3d602000-09-05 19:36:26 +0000587os/pty -- support for openpty and forkpty
Jeremy Hyltonbdebd542000-09-05 18:28:54 +0000588
589os.path -- fix semantics of os.path.commonprefix
590
591smtplib -- support for sending very long messages
592
593socket -- new function getfqdn()
594
595readline -- new functions to read, write and truncate history files.
596The readline section of the library reference manual contains an
597example.
598
Jeremy Hylton24c3d602000-09-05 19:36:26 +0000599select -- add interface to poll system call
600
Jeremy Hyltonbdebd542000-09-05 18:28:54 +0000601shutil -- new copyfileobj function
602
603SimpleHTTPServer, CGIHTTPServer -- Fix problems with buffering in the
604HTTP server.
605
Jeremy Hylton24c3d602000-09-05 19:36:26 +0000606Tkinter -- optimization of function flatten
Jeremy Hyltonbdebd542000-09-05 18:28:54 +0000607
608urllib -- scans environment variables for proxy configuration,
Tim Peters8b092332000-09-05 20:15:25 +0000609e.g. http_proxy.
Jeremy Hyltonbdebd542000-09-05 18:28:54 +0000610
611whichdb -- recognizes dumbdbm format
Guido van Rossume905e952000-09-05 12:42:46 +0000612
613
614Obsolete Modules
615----------------
616
617None. However note that 1.6 made a whole slew of modules obsolete:
618stdwin, soundex, cml, cmpcache, dircache, dump, find, grep, packmail,
619poly, zmod, strop, util, whatsound.
620
621
622Changed, New, Obsolete Tools
623----------------------------
624
Tim Peters8b092332000-09-05 20:15:25 +0000625None.
Guido van Rossume905e952000-09-05 12:42:46 +0000626
627
Guido van Rossumf2ffce02000-09-05 04:38:34 +0000628C-level Changes
629---------------
630
631Several cleanup jobs were carried out throughout the source code.
632
633All C code was converted to ANSI C; we got rid of all uses of the
634Py_PROTO() macro, which makes the header files a lot more readable.
635
636Most of the portability hacks were moved to a new header file,
637pyport.h; several other new header files were added and some old
638header files were removed, in an attempt to create a more rational set
639of header files. (Few of these ever need to be included explicitly;
640they are all included by Python.h.)
641
Guido van Rossumf2ffce02000-09-05 04:38:34 +0000642Trent Mick ensured portability to 64-bit platforms, under both Linux
Jeremy Hylton24c3d602000-09-05 19:36:26 +0000643and Win64, especially for the new Intel Itanium processor. Mick also
644added large file support for Linux64 and Win64.
Guido van Rossumf2ffce02000-09-05 04:38:34 +0000645
Jeremy Hyltonbdebd542000-09-05 18:28:54 +0000646The C APIs to return an object's size have been update to consistently
647use the form PyXXX_Size, e.g. PySequence_Size and PyDict_Size. In
648previous versions, the abstract interfaces used PyXXX_Length and the
649concrete interfaces used PyXXX_Size. The old names,
650e.g. PyObject_Length, are still available for backwards compatibility
651at the API level, but are deprecated.
652
Jeremy Hylton24c3d602000-09-05 19:36:26 +0000653The PyOS_CheckStack function has been implemented on Windows by
654Fredrik Lundh. It prevents Python from failing with a stack overflow
655on Windows.
Jeremy Hyltonbdebd542000-09-05 18:28:54 +0000656
657The GC changes resulted in creation of two new slots on object,
658tp_traverse and tp_clear. The augmented assignment changes result in
Guido van Rossum4338a282000-09-06 13:02:08 +0000659the creation of a new slot for each in-place operator.
Jeremy Hyltonbdebd542000-09-05 18:28:54 +0000660
661The GC API creates new requirements for container types implemented in
Guido van Rossum4338a282000-09-06 13:02:08 +0000662C extension modules. See Include/objimpl.h for details.
Jeremy Hyltonbdebd542000-09-05 18:28:54 +0000663
Jeremy Hylton24c3d602000-09-05 19:36:26 +0000664PyErr_Format has been updated to automatically calculate the size of
665the buffer needed to hold the formatted result string. This change
666prevents crashes caused by programmer error.
Jeremy Hyltonbdebd542000-09-05 18:28:54 +0000667
Jeremy Hylton24c3d602000-09-05 19:36:26 +0000668New C API calls: PyObject_AsFileDescriptor, PyErr_WriteUnraisable.
Guido van Rossume905e952000-09-05 12:42:46 +0000669
Jeremy Hylton24c3d602000-09-05 19:36:26 +0000670PyRun_AnyFileEx, PyRun_SimpleFileEx, PyRun_FileEx -- New functions
671that are the same as their non-Ex counterparts except they take an
672extra flag argument that tells them to close the file when done.
673
674XXX There were other API changes that should be fleshed out here.
Guido van Rossumab9d6f01998-08-10 22:01:13 +0000675
Tim Peters8b092332000-09-05 20:15:25 +0000676
677Windows Changes
678---------------
679
680New popen2/popen3/peopen4 in os module (see Changed Modules above).
681
682os.popen is much more usable on Windows 95 and 98. See Microsoft
683Knowledge Base article Q150956. The Win9x workaround described there
684is implemented by the new w9xpopen.exe helper in the root of your
685Python installation. Note that Python uses this internally; it is not
686a standalone program.
687
688Administrator privileges are no longer required to install Python
689on Windows NT or Windows 2000. If you have administrator privileges,
690Python's registry info will be written under HKEY_LOCAL_MACHINE.
691Otherwise the installer backs off to writing Python's registry info
Guido van Rossum4338a282000-09-06 13:02:08 +0000692under HKEY_CURRENT_USER. The latter is sufficient for all "normal"
Tim Peters8b092332000-09-05 20:15:25 +0000693uses of Python, but will prevent some advanced uses from working
694(for example, running a Python script as an NT service, or possibly
695from CGI).
696
697[This was new in 1.6] The installer no longer runs a separate Tcl/Tk
698installer; instead, it installs the needed Tcl/Tk files directly in the
699Python directory. If you already have a Tcl/Tk installation, this
700wastes some disk space (about 4 Megs) but avoids problems with
701conflicting Tcl/Tk installations, and makes it much easier for Python
702to ensure that Tcl/Tk can find all its files.
703
704[This was new in 1.6] The Windows installer now installs by default in
705\Python20\ on the default volume, instead of \Program Files\Python-2.0\.
706
Guido van Rossumf62ed9c2000-09-26 11:16:10 +0000707
708Updates to the changes between 1.5.2 and 1.6
709--------------------------------------------
710
711The 1.6 NEWS file can't be changed after the release is done, so here
712is some late-breaking news:
713
714New APIs in locale.py: normalize(), getdefaultlocale(), resetlocale(),
715and changes to getlocale() and setlocale().
716
717The new module is now enabled per default.
718
719It is not true that the encodings codecs cannot be used for normal
720strings: the string.encode() (which is also present on 8-bit strings
721!) allows using them for 8-bit strings too, e.g. to convert files from
722cp1252 (Windows) to latin-1 or vice-versa.
723
724Japanese codecs are available from Tamito KAJIYAMA:
725http://pseudo.grad.sccs.chukyo-u.ac.jp/~kajiyama/python/
726
727
Guido van Rossumab9d6f01998-08-10 22:01:13 +0000728======================================================================