blob: def0dd3fd1c0b4cfaff787e746efe0bc35b2375b [file] [log] [blame]
Tim Petersd7b5e882001-01-25 03:36:26 +00001What's New in Python 2.1 alpha 2?
2=================================
3Core language, builtins, and interpreter
4
5
6Standard library
7
8- random.py is now self-contained, and offers all the functionality of
9 the now-deprecated whrandom.py. See the docs for details. random.py
10 also supports new functions getstate() and setstate(), for saving
Tim Petersd52269b2001-01-25 06:23:18 +000011 and restoring the internal state of the generator; and jumpahead(n),
12 for quickly forcing the internal state to be the same as if n calls to
13 random() had been made. The latter is particularly useful for multi-
14 threaded programs, creating one instance of the random.Random() class for
15 each thread, then using .jumpahead() to force each instance to use a
16 non-overlapping segment of the full period.
Tim Petersd7b5e882001-01-25 03:36:26 +000017
18
Tim Petersa3a3a032000-11-30 05:22:44 +000019What's New in Python 2.1 alpha 1?
20=================================
21
22Core language, builtins, and interpreter
23
Marc-André Lemburgebb195b2001-01-20 10:34:52 +000024- There is a new Unicode companion to the PyObject_Str() API
25 called PyObject_Unicode(). It behaves in the same way as the
26 former, but assures that the returned value is an Unicode object
27 (applying the usual coercion if necessary).
Marc-André Lemburgad7c98e2001-01-17 17:09:53 +000028
Guido van Rossumf98eda02001-01-17 15:54:45 +000029- The comparison operators support "rich comparison overloading" (PEP
30 207). C extension types can provide a rich comparison function in
31 the new tp_richcompare slot in the type object. The cmp() function
32 and the C function PyObject_Compare() first try the new rich
33 comparison operators before trying the old 3-way comparison. There
34 is also a new C API PyObject_RichCompare() (which also falls back on
35 the old 3-way comparison, but does not constrain the outcome of the
36 rich comparison to a Boolean result).
37
38 The rich comparison function takes two objects (at least one of
39 which is guaranteed to have the type that provided the function) and
40 an integer indicating the opcode, which can be Py_LT, Py_LE, Py_EQ,
41 Py_NE, Py_GT, Py_GE (for <, <=, ==, !=, >, >=), and returns a Python
42 object, which may be NotImplemented (in which case the tp_compare
43 slot function is used as a fallback, if defined).
44
45 Classes can overload individual comparison operators by defining one
46 or more of the methods__lt__, __le__, __eq__, __ne__, __gt__,
Guido van Rossuma88479f2001-01-18 14:28:08 +000047 __ge__. There are no explicit "reflected argument" versions of
48 these; instead, __lt__ and __gt__ are each other's reflection,
49 likewise for__le__ and __ge__; __eq__ and __ne__ are their own
50 reflection (similar at the C level). No other implications are
51 made; in particular, Python does not assume that == is the Boolean
52 inverse of !=, or that < is the Boolean inverse of >=. This makes
53 it possible to define types with partial orderings.
Guido van Rossumf98eda02001-01-17 15:54:45 +000054
55 Classes or types that want to implement (in)equality tests but not
56 the ordering operators (i.e. unordered types) should implement ==
57 and !=, and raise an error for the ordering operators.
58
Guido van Rossuma88479f2001-01-18 14:28:08 +000059 It is possible to define types whose rich comparison results are not
Guido van Rossumf98eda02001-01-17 15:54:45 +000060 Boolean; e.g. a matrix type might want to return a matrix of bits
61 for A < B, giving elementwise comparisons. Such types should ensure
62 that any interpretation of their value in a Boolean context raises
63 an exception, e.g. by defining __nonzero__ (or the tp_nonzero slot
64 at the C level) to always raise an exception.
65
Guido van Rossuma88479f2001-01-18 14:28:08 +000066- Complex numbers use rich comparisons to define == and != but raise
67 an exception for <, <=, > and >=. Unfortunately, this also means
68 that cmp() of two complex numbers raises an exception when the two
69 numbers differ. Since it is not mathematically meaningful to compare
70 complex numbers except for equality, I hope that this doesn't break
71 too much code.
72
Barry Warsaw573b5412001-01-15 20:43:18 +000073- Functions and methods now support getting and setting arbitrarily
74 named attributes (PEP 232). Functions have a new __dict__
75 (a.k.a. func_dict) which hold the function attributes. Methods get
76 and set attributes on their underlying im_func. It is a TypeError
77 to set an attribute on a bound method.
78
Guido van Rossum051e3352001-01-15 19:11:10 +000079- The xrange() object implementation has been improved so that
80 xrange(sys.maxint) can be used on 64-bit platforms. There's still a
81 limitation that in this case len(xrange(sys.maxint)) can't be
82 calculated, but the common idiom "for i in xrange(sys.maxint)" will
83 work fine as long as the index i doesn't actually reach 2**31.
84 (Python uses regular ints for sequence and string indices; fixing
85 that is much more work.)
86
Guido van Rossum1cc8f832001-01-12 16:25:08 +000087- Two changes to from...import:
88
89 1) "from M import X" now works even if M is not a real module; it's
90 basically a getattr() operation with AttributeError exceptions
91 changed into ImportError.
92
93 2) "from M import *" now looks for M.__all__ to decide which names to
94 import; if M.__all__ doesn't exist, it uses M.__dict__.keys() but
95 filters out names starting with '_' as before. Whether or not
96 __all__ exists, there's no restriction on the type of M.
97
Guido van Rossumf61f1662001-01-10 20:13:55 +000098- File objects have a new method, xreadlines(). This is the fastest
99 way to iterate over all lines in a file:
100
101 for line in file.xreadlines():
102 ...do something to line...
103
104 See the xreadlines module (mentioned below) for how to do this for
105 other file-like objects.
106
107- Even if you don't use file.xreadlines(), you may expect a speedup on
108 line-by-line input. The file.readline() method has been optimized
Tim Petersf29b64d2001-01-15 06:33:19 +0000109 quite a bit in platform-specific ways: on systems (like Linux) that
110 support flockfile(), getc_unlocked(), and funlockfile(), those are
111 used by default. On systems (like Windows) without getc_unlocked(),
112 a complicated (but still thread-safe) method using fgets() is used by
113 default.
114
Tim Petersd52269b2001-01-25 06:23:18 +0000115 You can force use of the fgets() method by #define'ing
116 USE_FGETS_IN_GETLINE at build time (it may be faster than
Tim Petersf29b64d2001-01-15 06:33:19 +0000117 getc_unlocked()).
118
Tim Petersd52269b2001-01-25 06:23:18 +0000119 You can force fgets() not to be used by #define'ing
120 DONT_USE_FGETS_IN_GETLINE (this is the first thing to try if std test
Tim Petersf29b64d2001-01-15 06:33:19 +0000121 test_bufio.py fails -- and let us know if it does!).
122
123- In addition, the fileinput module, while still slower than the other
124 methods on most platforms, has been sped up too, by using
125 file.readlines(sizehint).
Guido van Rossumf61f1662001-01-10 20:13:55 +0000126
127- Support for run-time warnings has been added, including a new
128 command line option (-W) to specify the disposition of warnings.
129 See the description of the warnings module below.
130
131- Extensive changes have been made to the coercion code. This mostly
132 affects extension modules (which can now implement mixed-type
133 numerical operators without having to use coercion), but
134 occasionally, in boundary cases the coercion semantics have changed
135 subtly. Since this was a terrible gray area of the language, this
Guido van Rossumae72d872001-01-11 15:00:14 +0000136 is considered an improvement. Also note that __rcmp__ is no longer
Guido van Rossumf61f1662001-01-10 20:13:55 +0000137 supported -- instead of calling __rcmp__, __cmp__ is called with
Guido van Rossuma88479f2001-01-18 14:28:08 +0000138 reflected arguments.
Guido van Rossumf61f1662001-01-10 20:13:55 +0000139
Guido van Rossumf98eda02001-01-17 15:54:45 +0000140- In connection with the coercion changes, a new built-in singleton
141 object, NotImplemented is defined. This can be returned for
142 operations that wish to indicate they are not implemented for a
143 particular combination of arguments. From C, this is
144 Py_NotImplemented.
145
Martin v. Löwisbe4c0f52001-01-04 20:30:56 +0000146- The interpreter accepts now bytecode files on the command line even
147 if they do not have a .pyc or .pyo extension. On Linux, after executing
148
149 echo ':pyc:M::\x87\xc6\x0d\x0a::/usr/local/bin/python:' > /proc/sys/fs/binfmt_misc/register
150
151 any byte code file can be used as an executable (i.e. as an argument
152 to execve(2)).
153
Tim Peters9940b802000-12-01 07:59:35 +0000154- %[xXo] formats of negative Python longs now produce a sign
Tim Petersa3a3a032000-11-30 05:22:44 +0000155 character. In 1.6 and earlier, they never produced a sign,
156 and raised an error if the value of the long was too large
157 to fit in a Python int. In 2.0, they produced a sign if and
158 only if too large to fit in an int. This was inconsistent
159 across platforms (because the size of an int varies across
160 platforms), and inconsistent with hex() and oct(). Example:
161
162 >>> "%x" % -0x42L
Tim Peters9940b802000-12-01 07:59:35 +0000163 '-42' # in 2.1
Tim Petersa3a3a032000-11-30 05:22:44 +0000164 'ffffffbe' # in 2.0 and before, on 32-bit machines
165 >>> hex(-0x42L)
166 '-0x42L' # in all versions of Python
167
Tim Peters9940b802000-12-01 07:59:35 +0000168 The behavior of %d formats for negative Python longs remains
169 the same as in 2.0 (although in 1.6 and before, they raised
170 an error if the long didn't fit in a Python int).
171
172 %u formats don't make sense for Python longs, but are allowed
173 and treated the same as %d in 2.1. In 2.0, a negative long
174 formatted via %u produced a sign if and only if too large to
175 fit in an int. In 1.6 and earlier, a negative long formatted
176 via %u raised an error if it was too big to fit in an int.
177
Guido van Rossum3661d392000-12-12 22:10:31 +0000178- Dictionary objects have an odd new method, popitem(). This removes
179 an arbitrary item from the dictionary and returns it (in the form of
180 a (key, value) pair). This can be useful for algorithms that use a
181 dictionary as a bag of "to do" items and repeatedly need to pick one
182 item. Such algorithms normally end up running in quadratic time;
183 using popitem() they can usually be made to run in linear time.
184
Tim Peters36cdad12000-12-29 02:06:45 +0000185Standard library
186
Thomas Woutersfe385252001-01-19 23:16:56 +0000187- In the time module, the time argument to the functions strftime,
188 localtime, gmtime, asctime and ctime is now optional, defaulting to
189 the current time (in the local timezone).
190
Guido van Rossumda91f222001-01-15 16:36:08 +0000191- The ftplib module now defaults to passive mode, which is deemed a
192 more useful default given that clients are often inside firewalls
193 these days. Note that this could break if ftplib is used to connect
194 to a *server* that is inside a firewall, from outside; this is
195 expected to be a very rare situation. To fix that, you can call
196 ftp.set_pasv(0).
197
Martin v. Löwis10a27872001-01-13 09:54:41 +0000198- The module site now treats .pth files not only for path configuration,
199 but also supports extensions to the initialization code: Lines starting
200 with import are executed.
201
Guido van Rossumf61f1662001-01-10 20:13:55 +0000202- There's a new module, warnings, which implements a mechanism for
203 issuing and filtering warnings. There are some new built-in
204 exceptions that serve as warning categories, and a new command line
205 option, -W, to control warnings (e.g. -Wi ignores all warnings, -We
206 turns warnings into errors). warnings.warn(message[, category])
207 issues a warning message; this can also be called from C as
208 PyErr_Warn(category, message).
209
210- A new module xreadlines was added. This exports a single factory
211 function, xreadlines(). The intention is that this code is the
212 absolutely fastest way to iterate over all lines in an open
213 file(-like) object:
214
215 import xreadlines
216 for line in xreadlines.xreadlines(file):
217 ...do something to line...
218
219 This is equivalent to the previous the speed record holder using
220 file.readlines(sizehint). Note that if file is a real file object
221 (as opposed to a file-like object), this is equivalent:
222
223 for line in file.xreadlines():
224 ...do something to line...
225
Tim Peters36cdad12000-12-29 02:06:45 +0000226- The bisect module has new functions bisect_left, insort_left,
227 bisect_right and insort_right. The old names bisect and insort
228 are now aliases for bisect_right and insort_right. XXX_right
229 and XXX_left methods differ in what happens when the new element
230 compares equal to one or more elements already in the list: the
231 XXX_left methods insert to the left, the XXX_right methods to the
Tim Peters742bb6f2001-01-05 08:05:32 +0000232 right. Code that doesn't care where equal elements end up should
233 continue to use the old, short names ("bisect" and "insort").
Tim Peters36cdad12000-12-29 02:06:45 +0000234
Andrew M. Kuchlingf6f3a892001-01-13 14:53:34 +0000235- The new curses.panel module wraps the panel library that forms part
236 of SYSV curses and ncurses. Contributed by Thomas Gellekum.
237
Guido van Rossumf61f1662001-01-10 20:13:55 +0000238- The SocketServer module now sets the allow_reuse_address flag by
239 default in the TCPServer class.
240
241- A new function, sys._getframe(), returns the stack frame pointer of
242 the caller. This is intended only as a building block for
243 higher-level mechanisms such as string interpolation.
244
245Build issues
246
Guido van Rossum1e33bdc2001-01-23 03:17:00 +0000247- For Unix (and Unix-compatible) builds, configuration and building of
248 extension modules is now greatly automated. Rather than having to
249 edit the Modules/Setup file to indicate which modules should be
250 built and where their include files and libraries are, a
251 distutils-based setup.py script now takes care of building most
252 extension modules. All extension modules built this way are built
253 as shared libraries. Only a few modules that must be linked
254 statically are still listed in the Setup file; you won't need to
255 edit their configuration.
256
257- Python should now build out of the box on Cygwin. If it doesn't,
258 mail to Jason Tishler (jlt63 at users.sourceforge.net).
Guido van Rossumf61f1662001-01-10 20:13:55 +0000259
260- Python now always uses its own (renamed) implementation of getopt()
261 -- there's too much variation among C library getopt()
262 implementations.
263
264- C++ compilers are better supported; the CXX macro is always set to a
265 C++ compiler if one is found.
Tim Peters36cdad12000-12-29 02:06:45 +0000266
Tim Petersd92dfe02000-12-12 01:18:41 +0000267Windows changes
268
269- select module: By default under Windows, a select() call
270 can specify no more than 64 sockets. Python now boosts
271 this Microsoft default to 512. If you need even more than
272 that, see the MS docs (you'll need to #define FD_SETSIZE
273 and recompile Python from source).
274
Guido van Rossumf61f1662001-01-10 20:13:55 +0000275- Support for Windows 3.1, DOS and OS/2 is gone. The Lib/dos-8x3
276 subdirectory is no more!
277
Tim Petersa3a3a032000-11-30 05:22:44 +0000278
Jeremy Hyltond6e20232000-10-16 20:08:38 +0000279What's New in Python 2.0?
Fred Drake1a640502000-10-16 20:27:25 +0000280=========================
Guido van Rossum61000331997-08-15 04:39:58 +0000281
Guido van Rossum8ed602b2000-09-01 22:34:33 +0000282Below is a list of all relevant changes since release 1.6. Older
Guido van Rossumf2ffce02000-09-05 04:38:34 +0000283changes are in the file HISTORY. If you are making the jump directly
284from Python 1.5.2 to 2.0, make sure to read the section for 1.6 in the
285HISTORY file! Many important changes listed there.
Guido van Rossum61000331997-08-15 04:39:58 +0000286
Guido van Rossumf2ffce02000-09-05 04:38:34 +0000287Alternatively, a good overview of the changes between 1.5.2 and 2.0 is
288the document "What's New in Python 2.0" by Kuchling and Moshe Zadka:
289http://starship.python.net/crew/amk/python/writing/new-python/.
Guido van Rossum1f83cce1997-10-06 21:04:35 +0000290
Guido van Rossumf2ffce02000-09-05 04:38:34 +0000291--Guido van Rossum (home page: http://www.pythonlabs.com/~guido/)
Guido van Rossum437cfe81999-04-08 20:17:57 +0000292
293======================================================================
294
Jeremy Hyltond6e20232000-10-16 20:08:38 +0000295What's new in 2.0 (since release candidate 1)?
296==============================================
297
298Standard library
299
300- The copy_reg module was modified to clarify its intended use: to
301 register pickle support for extension types, not for classes.
302 pickle() will raise a TypeError if it is passed a class.
303
304- Fixed a bug in gettext's "normalize and expand" code that prevented
305 it from finding an existing .mo file.
306
307- Restored support for HTTP/0.9 servers in httplib.
308
Tim Peters989b7b92000-10-16 20:24:53 +0000309- The math module was changed to stop raising OverflowError in case of
310 underflow, and return 0 instead in underflow cases. Whether Python
311 used to raise OverflowError in case of underflow was platform-
312 dependent (it did when the platform math library set errno to ERANGE
313 on underflow).
Jeremy Hyltond6e20232000-10-16 20:08:38 +0000314
315- Fixed a bug in StringIO that occurred when the file position was not
316 at the end of the file and write() was called with enough data to
317 extend past the end of the file.
318
319- Fixed a bug that caused Tkinter error messages to get lost on
320 Windows. The bug was fixed by replacing direct use of
321 interp->result with Tcl_GetStringResult(interp).
322
323- Fixed bug in urllib2 that caused it to fail when it received an HTTP
324 redirect response.
325
326- Several changes were made to distutils: Some debugging code was
327 removed from util. Fixed the installer used when an external zip
328 program (like WinZip) is not found; the source code for this
329 installer is in Misc/distutils. check_lib() was modified to behave
330 more like AC_CHECK_LIB by add other_libraries() as a parameter. The
331 test for whether installed modules are on sys.path was changed to
332 use both normcase() and normpath().
333
Jeremy Hyltond867a2c2000-10-16 20:41:38 +0000334- Several minor bugs were fixed in the xml package (the minidom,
335 pulldom, expatreader, and saxutils modules).
Jeremy Hyltond6e20232000-10-16 20:08:38 +0000336
337- The regression test driver (regrtest.py) behavior when invoked with
338 -l changed: It now reports a count of objects that are recognized as
339 garbage but not freed by the garbage collector.
340
Tim Peters989b7b92000-10-16 20:24:53 +0000341- The regression test for the math module was changed to test
342 exceptional behavior when the test is run in verbose mode. Python
343 cannot yet guarantee consistent exception behavior across platforms,
344 so the exception part of test_math is run only in verbose mode, and
345 may fail on your platform.
Jeremy Hyltond6e20232000-10-16 20:08:38 +0000346
347Internals
348
349- PyOS_CheckStack() has been disabled on Win64, where it caused
350 test_sre to fail.
351
352Build issues
353
354- Changed compiler flags, so that gcc is always invoked with -Wall and
355 -Wstrict-prototypes. Users compiling Python with GCC should see
356 exactly one warning, except if they have passed configure the
Tim Peters989b7b92000-10-16 20:24:53 +0000357 --with-pydebug flag. The expected warning is for getopt() in
Tim Petersadfb94f2000-10-16 20:51:33 +0000358 Modules/main.c. This warning will be fixed for Python 2.1.
Jeremy Hyltond6e20232000-10-16 20:08:38 +0000359
Tim Petersa3a3a032000-11-30 05:22:44 +0000360- Fixed configure to add -threads argument during linking on OSF1.
Jeremy Hyltond6e20232000-10-16 20:08:38 +0000361
362Tools and other miscellany
363
364- The compiler in Tools/compiler was updated to support the new
365 language features introduced in 2.0: extended print statement, list
366 comprehensions, and augmented assignments. The new compiler should
367 also be backwards compatible with Python 1.5.2; the compiler will
368 always generate code for the version of the interpreter it runs
Tim Petersa3a3a032000-11-30 05:22:44 +0000369 under.
Jeremy Hyltond6e20232000-10-16 20:08:38 +0000370
Jeremy Hyltoned9e6442000-10-09 18:26:42 +0000371What's new in 2.0 release candidate 1 (since beta 2)?
372=====================================================
373
Jeremy Hylton6040aaa2000-10-09 21:27:22 +0000374What is release candidate 1?
375
376We believe that release candidate 1 will fix all known bugs that we
377intend to fix for the 2.0 final release. This release should be a bit
378more stable than the previous betas. We would like to see even more
379widespread testing before the final release, so we are producing this
380release candidate. The final release will be exactly the same unless
381any show-stopping (or brown bag) bugs are found by testers of the
382release candidate.
383
Jeremy Hyltoned9e6442000-10-09 18:26:42 +0000384All the changes since the last beta release are bug fixes or changes
Jeremy Hyltond6e20232000-10-16 20:08:38 +0000385to support building Python for specific platforms.
Jeremy Hyltoned9e6442000-10-09 18:26:42 +0000386
387Core language, builtins, and interpreter
388
389- A bug that caused crashes when __coerce__ was used with augmented
390 assignment, e.g. +=, was fixed.
391
392- Raise ZeroDivisionError when raising zero to a negative number,
393 e.g. 0.0 ** -2.0. Note that math.pow is unrelated to the builtin
394 power operator and the result of math.pow(0.0, -2.0) will vary by
395 platform. On Linux, it raises a ValueError.
396
397- A bug in Unicode string interpolation was fixed that occasionally
398 caused errors with formats including "%%". For example, the
399 following expression "%% %s" % u"abc" no longer raises a TypeError.
400
401- Compilation of deeply nested expressions raises MemoryError instead
402 of SyntaxError, e.g. eval("[" * 50 + "]" * 50).
403
404- In 2.0b2 on Windows, the interpreter wrote .pyc files in text mode,
405 rendering them useless. They are now written in binary mode again.
406
407Standard library
408
409- Keyword arguments are now accepted for most pattern and match object
410 methods in SRE, the standard regular expression engine.
411
Jeremy Hyltond6e20232000-10-16 20:08:38 +0000412- In SRE, fixed error with negative lookahead and lookbehind that
Jeremy Hylton32e20ff2000-10-09 19:48:11 +0000413 manifested itself as a runtime error in patterns like "(?<!abc)(def)".
Jeremy Hyltoned9e6442000-10-09 18:26:42 +0000414
Jeremy Hyltond6e20232000-10-16 20:08:38 +0000415- Several bugs in the Unicode handling and error handling in _tkinter
416 were fixed.
Jeremy Hyltoned9e6442000-10-09 18:26:42 +0000417
418- Fix memory management errors in Merge() and Tkapp_Call() routines.
419
420- Several changes were made to cStringIO to make it compatible with
421 the file-like object interface and with StringIO. If operations are
422 performed on a closed object, an exception is raised. The truncate
423 method now accepts a position argument and readline accepts a size
Tim Petersa3a3a032000-11-30 05:22:44 +0000424 argument.
Jeremy Hyltoned9e6442000-10-09 18:26:42 +0000425
426- There were many changes made to the linuxaudiodev module and its
427 test suite; as a result, a short, unexpected audio sample should now
Tim Petersa3a3a032000-11-30 05:22:44 +0000428 play when the regression test is run.
Jeremy Hyltoned9e6442000-10-09 18:26:42 +0000429
430 Note that this module is named poorly, because it should work
431 correctly on any platform that supports the Open Sound System
Tim Petersa3a3a032000-11-30 05:22:44 +0000432 (OSS).
Jeremy Hyltoned9e6442000-10-09 18:26:42 +0000433
434 The module now raises exceptions when errors occur instead of
435 crashing. It also defines the AFMT_A_LAW format (logarithmic A-law
436 audio) and defines a getptr() method that calls the
437 SNDCTL_DSP_GETxPTR ioctl defined in the OSS Programmer's Guide.
438
439- The library_version attribute, introduced in an earlier beta, was
440 removed because it can not be supported with early versions of the C
441 readline library, which provides no way to determine the version at
442 compile-time.
443
444- The binascii module is now enabled on Win64.
445
Tim Peters46446d62000-10-09 21:19:31 +0000446- tokenize.py no longer suffers "recursion depth" errors when parsing
447 programs with very long string literals.
448
Jeremy Hyltoned9e6442000-10-09 18:26:42 +0000449Internals
450
Jeremy Hyltond6e20232000-10-16 20:08:38 +0000451- Fixed several buffer overflow vulnerabilities in calculate_path(),
Jeremy Hyltoned9e6442000-10-09 18:26:42 +0000452 which is called when the interpreter starts up to determine where
453 the standard library is installed. These vulnerabilities affect all
454 previous versions of Python and can be exploited by setting very
455 long values for PYTHONHOME or argv[0]. The risk is greatest for a
456 setuid Python script, although use of the wrapper in
457 Misc/setuid-prog.c will eliminate the vulnerability.
458
459- Fixed garbage collection bugs in instance creation that were
460 triggered when errors occurred during initialization. The solution,
461 applied in cPickle and in PyInstance_New(), is to call
462 PyObject_GC_Init() after the initialization of the object's
463 container attributes is complete.
464
465- pyexpat adds definitions of PyModule_AddStringConstant and
466 PyModule_AddObject if the Python version is less than 2.0, which
467 provides compatibility with PyXML on Python 1.5.2.
468
469- If the platform has a bogus definition for LONG_BIT (the number of
470 bits in a long), an error will be reported at compile time.
471
472- Fix bugs in _PyTuple_Resize() which caused hard-to-interpret garbage
473 collection crashes and possibly other, unreported crashes.
474
475- Fixed a memory leak in _PyUnicode_Fini().
476
477Build issues
478
479- configure now accepts a --with-suffix option that specifies the
Jeremy Hyltond6e20232000-10-16 20:08:38 +0000480 executable suffix. This is useful for builds on Cygwin and Mac OS
Tim Petersa3a3a032000-11-30 05:22:44 +0000481 X, for example.
Jeremy Hyltoned9e6442000-10-09 18:26:42 +0000482
483- The mmap.PAGESIZE constant is now initialized using sysconf when
484 possible, which eliminates a dependency on -lucb for Reliant UNIX.
485
486- The md5 file should now compile on all platforms.
487
488- The select module now compiles on platforms that do not define
489 POLLRDNORM and related constants.
490
491- Darwin (Mac OS X): Initial support for static builds on this
Tim Petersa3a3a032000-11-30 05:22:44 +0000492 platform.
Jeremy Hyltoned9e6442000-10-09 18:26:42 +0000493
Jeremy Hylton10921202000-10-09 18:34:12 +0000494- BeOS: A number of changes were made to the build and installation
495 process. ar-fake now operates on a directory of object files.
496 dl_export.h is gone, and its macros now appear on the mwcc command
497 line during build on PPC BeOS.
498
Jeremy Hyltond6e20232000-10-16 20:08:38 +0000499- Platform directory in lib/python2.0 is "plat-beos5" (or
Jeremy Hylton10921202000-10-09 18:34:12 +0000500 "plat-beos4", if building on BeOS 4.5), rather than "plat-beos".
Jeremy Hyltoned9e6442000-10-09 18:26:42 +0000501
502- Cygwin: Support for shared libraries, Tkinter, and sockets.
503
504- SunOS 4.1.4_JL: Fix test for directory existence in configure.
505
506Tools and other miscellany
507
508- Removed debugging prints from main used with freeze.
509
Tim Peters46446d62000-10-09 21:19:31 +0000510- IDLE auto-indent no longer crashes when it encounters Unicode
511 characters.
Jeremy Hylton1b618592000-09-26 05:32:36 +0000512
513What's new in 2.0 beta 2 (since beta 1)?
514========================================
515
516Core language, builtins, and interpreter
517
Tim Peters482c0212000-09-26 06:33:09 +0000518- Add support for unbounded ints in %d,i,u,x,X,o formats; for example
Guido van Rossumf62ed9c2000-09-26 11:16:10 +0000519 "%d" % 2L**64 == "18446744073709551616".
Jeremy Hylton1b618592000-09-26 05:32:36 +0000520
Guido van Rossumf62ed9c2000-09-26 11:16:10 +0000521- Add -h and -V command line options to print the usage message and
522 Python version number and exit immediately.
523
Jeremy Hyltonfa2e2c12000-09-26 16:31:30 +0000524- eval() and exec accept Unicode objects as code parameters.
525
526- getattr() and setattr() now also accept Unicode objects for the
527 attribute name, which are converted to strings using the default
528 encoding before lookup.
529
530- Multiplication on string and Unicode now does proper bounds
531 checking; e.g. 'a' * 65536 * 65536 will raise ValueError, "repeated
532 string is too long."
533
534- Better error message when continue is found in try statement in a
Tim Petersa3a3a032000-11-30 05:22:44 +0000535 loop.
Jeremy Hyltonfa2e2c12000-09-26 16:31:30 +0000536
Jeremy Hylton1b618592000-09-26 05:32:36 +0000537
538Standard library and extensions
539
Guido van Rossumf62ed9c2000-09-26 11:16:10 +0000540- array: reverse() method of array now works. buffer_info() now does
Jeremy Hylton1b618592000-09-26 05:32:36 +0000541 argument checking; it still takes no arguments.
542
Guido van Rossumf62ed9c2000-09-26 11:16:10 +0000543- asyncore/asynchat: Included most recent version from Sam Rushing.
Jeremy Hylton1b618592000-09-26 05:32:36 +0000544
Guido van Rossumf62ed9c2000-09-26 11:16:10 +0000545- cgi: Accept '&' or ';' as separator characters when parsing form data.
Jeremy Hylton1b618592000-09-26 05:32:36 +0000546
Guido van Rossumf62ed9c2000-09-26 11:16:10 +0000547- CGIHTTPServer: Now works on Windows (and perhaps even Mac).
Jeremy Hylton1b618592000-09-26 05:32:36 +0000548
549- ConfigParser: When reading the file, options spelled in upper case
Guido van Rossumf62ed9c2000-09-26 11:16:10 +0000550 letters are now correctly converted to lowercase.
Jeremy Hylton1b618592000-09-26 05:32:36 +0000551
552- copy: Copy Unicode objects atomically.
553
Guido van Rossumf62ed9c2000-09-26 11:16:10 +0000554- cPickle: Fail gracefully when copy_reg can't be imported.
Jeremy Hylton1b618592000-09-26 05:32:36 +0000555
Guido van Rossumf62ed9c2000-09-26 11:16:10 +0000556- cStringIO: Implemented readlines() method.
Jeremy Hylton1b618592000-09-26 05:32:36 +0000557
Fred Drake67233bc2000-09-26 16:40:27 +0000558- dbm: Add get() and setdefault() methods to dbm object. Add constant
559 `library' to module that names the library used. Added doc strings
560 and method names to error messages. Uses configure to determine
561 which ndbm.h file to include; Berkeley DB's nbdm and GDBM's ndbm is
562 now available options.
Jeremy Hylton1b618592000-09-26 05:32:36 +0000563
564- distutils: Update to version 0.9.3.
565
566- dl: Add several dl.RTLD_ constants.
567
568- fpectl: Now supported on FreeBSD.
569
570- gc: Add DEBUG_SAVEALL option. When enabled all garbage objects
571 found by the collector will be saved in gc.garbage. This is useful
572 for debugging a program that creates reference cycles.
573
Guido van Rossumf62ed9c2000-09-26 11:16:10 +0000574- httplib: Three changes: Restore support for set_debuglevel feature
Jeremy Hylton1b618592000-09-26 05:32:36 +0000575 of HTTP class. Do not close socket on zero-length response. Do not
576 crash when server sends invalid content-length header.
577
Guido van Rossumf62ed9c2000-09-26 11:16:10 +0000578- mailbox: Mailbox class conforms better to qmail specifications.
Jeremy Hylton1b618592000-09-26 05:32:36 +0000579
Jeremy Hyltonfa2e2c12000-09-26 16:31:30 +0000580- marshal: When reading a short, sign-extend on platforms where shorts
581 are bigger than 16 bits. When reading a long, repair the unportable
582 sign extension that was being done for 64-bit machines. (It assumed
583 that signed right shift sign-extends.)
584
Guido van Rossumf62ed9c2000-09-26 11:16:10 +0000585- operator: Add contains(), invert(), __invert__() as aliases for
586 __contains__(), inv(), and __inv__() respectively.
Jeremy Hylton1b618592000-09-26 05:32:36 +0000587
Guido van Rossumf62ed9c2000-09-26 11:16:10 +0000588- os: Add support for popen2() and popen3() on all platforms where
589 fork() exists. (popen4() is still in the works.)
Jeremy Hylton1b618592000-09-26 05:32:36 +0000590
Guido van Rossumf62ed9c2000-09-26 11:16:10 +0000591- os: (Windows only:) Add startfile() function that acts like double-
Tim Peters482c0212000-09-26 06:33:09 +0000592 clicking on a file in Explorer (or passing the file name to the
593 DOS "start" command).
Jeremy Hylton1b618592000-09-26 05:32:36 +0000594
Guido van Rossumf62ed9c2000-09-26 11:16:10 +0000595- os.path: (Windows, DOS:) Treat trailing colon correctly in
Tim Peters482c0212000-09-26 06:33:09 +0000596 os.path.join. os.path.join("a:", "b") yields "a:b".
Jeremy Hylton1b618592000-09-26 05:32:36 +0000597
598- pickle: Now raises ValueError when an invalid pickle that contains
599 a non-string repr where a string repr was expected. This behavior
600 matches cPickle.
601
Guido van Rossumf62ed9c2000-09-26 11:16:10 +0000602- posixfile: Remove broken __del__() method.
Jeremy Hylton1b618592000-09-26 05:32:36 +0000603
Guido van Rossumf62ed9c2000-09-26 11:16:10 +0000604- py_compile: support CR+LF line terminators in source file.
Jeremy Hylton1b618592000-09-26 05:32:36 +0000605
606- readline: Does not immediately exit when ^C is hit when readline and
Jeremy Hyltonfa2e2c12000-09-26 16:31:30 +0000607 threads are configured. Adds definition of rl_library_version. (The
Guido van Rossumf62ed9c2000-09-26 11:16:10 +0000608 latter addition requires GNU readline 2.2 or later.)
Jeremy Hylton1b618592000-09-26 05:32:36 +0000609
610- rfc822: Domain literals returned by AddrlistClass method
Guido van Rossumf62ed9c2000-09-26 11:16:10 +0000611 getdomainliteral() are now properly wrapped in brackets.
Jeremy Hylton1b618592000-09-26 05:32:36 +0000612
613- site: sys.setdefaultencoding() should only be called in case the
Tim Peters482c0212000-09-26 06:33:09 +0000614 standard default encoding ("ascii") is changed. This saves quite a
Jeremy Hylton1b618592000-09-26 05:32:36 +0000615 few cycles during startup since the first call to
616 setdefaultencoding() will initialize the codec registry and the
617 encodings package.
618
Guido van Rossumf62ed9c2000-09-26 11:16:10 +0000619- socket: Support for size hint in readlines() method of object returned
620 by makefile().
Jeremy Hylton1b618592000-09-26 05:32:36 +0000621
Guido van Rossumf62ed9c2000-09-26 11:16:10 +0000622- sre: Added experimental expand() method to match objects. Does not
Jeremy Hylton625915e2000-10-02 13:43:33 +0000623 use buffer interface on Unicode strings. Does not hang if group id
Jeremy Hylton1b618592000-09-26 05:32:36 +0000624 is followed by whitespace.
625
Tim Petersa3a3a032000-11-30 05:22:44 +0000626- StringIO: Size hint in readlines() is now supported as documented.
Jeremy Hylton1b618592000-09-26 05:32:36 +0000627
628- struct: Check ranges for bytes and shorts.
629
630- urllib: Improved handling of win32 proxy settings. Fixed quote and
Guido van Rossumf62ed9c2000-09-26 11:16:10 +0000631 quote_plus functions so that the always encode a comma.
Jeremy Hylton1b618592000-09-26 05:32:36 +0000632
633- Tkinter: Image objects are now guaranteed to have unique ids. Set
634 event.delta to zero if Tk version doesn't support mousewheel.
635 Removed some debugging prints.
636
Guido van Rossumf62ed9c2000-09-26 11:16:10 +0000637- UserList: now implements __contains__().
Jeremy Hylton1b618592000-09-26 05:32:36 +0000638
Fred Drake67233bc2000-09-26 16:40:27 +0000639- webbrowser: On Windows, use os.startfile() instead of os.popen(),
Guido van Rossumf62ed9c2000-09-26 11:16:10 +0000640 which works around a bug in Norton AntiVirus 2000 that leads directly
641 to a Blue Screen freeze.
Jeremy Hylton1b618592000-09-26 05:32:36 +0000642
643- xml: New version detection code allows PyXML to override standard
644 XML package if PyXML version is greater than 0.6.1.
645
Fred Drake64bb3802000-09-26 16:21:35 +0000646- xml.dom: DOM level 1 support for basic XML. Includes xml.dom.minidom
647 (conventional DOM), and xml.dom.pulldom, which allows building the DOM
648 tree only for nodes which are sufficiently interesting to a specific
649 application. Does not provide the HTML-specific extensions. Still
650 undocumented.
Jeremy Hylton1b618592000-09-26 05:32:36 +0000651
Fred Drake64bb3802000-09-26 16:21:35 +0000652- xml.sax: SAX 2 support for Python, including all the handler
653 interfaces needed to process XML 1.0 compliant XML. Some
654 documentation is already available.
Jeremy Hylton1b618592000-09-26 05:32:36 +0000655
Fred Drake64bb3802000-09-26 16:21:35 +0000656- pyexpat: Renamed to xml.parsers.expat since this is part of the new,
657 packagized XML support.
Jeremy Hylton1b618592000-09-26 05:32:36 +0000658
Guido van Rossumf62ed9c2000-09-26 11:16:10 +0000659
Jeremy Hylton1b618592000-09-26 05:32:36 +0000660C API
661
662- Add three new convenience functions for module initialization --
663 PyModule_AddObject(), PyModule_AddIntConstant(), and
664 PyModule_AddStringConstant().
665
Jeremy Hyltonfa2e2c12000-09-26 16:31:30 +0000666- Cleaned up definition of NULL in C source code; all definitions were
Jeremy Hylton1b618592000-09-26 05:32:36 +0000667 removed and add #error to Python.h if NULL isn't defined after
668 #include of stdio.h.
669
Guido van Rossumf62ed9c2000-09-26 11:16:10 +0000670- Py_PROTO() macros that were removed in 2.0b1 have been restored for
Jeremy Hylton1b618592000-09-26 05:32:36 +0000671 backwards compatibility (at the source level) with old extensions.
672
Guido van Rossumf62ed9c2000-09-26 11:16:10 +0000673- A wrapper API was added for signal() and sigaction(). Instead of
674 either function, always use PyOS_getsig() to get a signal handler
675 and PyOS_setsig() to set one. A new convenience typedef
676 PyOS_sighandler_t is defined for the type of signal handlers.
Jeremy Hylton1b618592000-09-26 05:32:36 +0000677
Guido van Rossumf62ed9c2000-09-26 11:16:10 +0000678- Add PyString_AsStringAndSize() function that provides access to the
Jeremy Hylton1b618592000-09-26 05:32:36 +0000679 internal data buffer and size of a string object -- or the default
680 encoded version of a Unicode object.
681
Jeremy Hyltonfa2e2c12000-09-26 16:31:30 +0000682- PyString_Size() and PyString_AsString() accept Unicode objects.
683
Guido van Rossumf62ed9c2000-09-26 11:16:10 +0000684- The standard header <limits.h> is now included by Python.h (if it
Fred Drake64bb3802000-09-26 16:21:35 +0000685 exists). INT_MAX and LONG_MAX will always be defined, even if
686 <limits.h> is not available.
Guido van Rossumf62ed9c2000-09-26 11:16:10 +0000687
Jeremy Hyltonfa2e2c12000-09-26 16:31:30 +0000688- PyFloat_FromString takes a second argument, pend, that was
689 effectively useless. It is now officially useless but preserved for
690 backwards compatibility. If the pend argument is not NULL, *pend is
691 set to NULL.
692
693- PyObject_GetAttr() and PyObject_SetAttr() now accept Unicode objects
694 for the attribute name. See note on getattr() above.
695
696- A few bug fixes to argument processing for Unicode.
697 PyArg_ParseTupleAndKeywords() now accepts "es#" and "es".
698 PyArg_Parse() special cases "s#" for Unicode objects; it returns a
699 pointer to the default encoded string data instead of to the raw
Tim Petersa3a3a032000-11-30 05:22:44 +0000700 UTF-16.
Jeremy Hyltonfa2e2c12000-09-26 16:31:30 +0000701
702- Py_BuildValue accepts B format (for bgen-generated code).
703
Guido van Rossumf62ed9c2000-09-26 11:16:10 +0000704
Jeremy Hylton1b618592000-09-26 05:32:36 +0000705Internals
706
707- On Unix, fix code for finding Python installation directory so that
708 it works when argv[0] is a relative path.
709
Andrew M. Kuchlinga1099be2000-12-15 01:16:43 +0000710- Added a true unicode_internal_encode() function and fixed the
Guido van Rossumf62ed9c2000-09-26 11:16:10 +0000711 unicode_internal_decode function() to support Unicode objects directly
Jeremy Hylton1b618592000-09-26 05:32:36 +0000712 rather than by generating a copy of the object.
713
Tim Peters482c0212000-09-26 06:33:09 +0000714- Several of the internal Unicode tables are much smaller now, and
715 the source code should be much friendlier to weaker compilers.
Jeremy Hylton1b618592000-09-26 05:32:36 +0000716
Jeremy Hylton97693b02000-09-26 17:42:51 +0000717- In the garbage collector: Fixed bug in collection of tuples. Fixed
718 bug that caused some instances to be removed from the container set
719 while they were still live. Fixed parsing in gc.set_debug() for
720 platforms where sizeof(long) > sizeof(int).
Jeremy Hyltonfa2e2c12000-09-26 16:31:30 +0000721
722- Fixed refcount problem in instance deallocation that only occurred
723 when Py_REF_DEBUG was defined and Py_TRACE_REFS was not.
724
Jeremy Hyltonfa2e2c12000-09-26 16:31:30 +0000725- On Windows, getpythonregpath is now protected against null data in
726 registry key.
727
728- On Unix, create .pyc/.pyo files with O_EXCL flag to avoid a race
Tim Petersa3a3a032000-11-30 05:22:44 +0000729 condition.
Jeremy Hyltonfa2e2c12000-09-26 16:31:30 +0000730
Guido van Rossumf62ed9c2000-09-26 11:16:10 +0000731
Jeremy Hylton1b618592000-09-26 05:32:36 +0000732Build and platform-specific issues
733
734- Better support of GNU Pth via --with-pth configure option.
735
Jeremy Hyltonfa2e2c12000-09-26 16:31:30 +0000736- Python/C API now properly exposed to dynamically-loaded extension
737 modules on Reliant UNIX.
Jeremy Hylton1b618592000-09-26 05:32:36 +0000738
739- Changes for the benefit of SunOS 4.1.4 (really!). mmapmodule.c:
740 Don't define MS_SYNC to be zero when it is undefined. Added missing
741 prototypes in posixmodule.c.
742
Jeremy Hyltonfa2e2c12000-09-26 16:31:30 +0000743- Improved support for HP-UX build. Threads should now be correctly
Guido van Rossumf62ed9c2000-09-26 11:16:10 +0000744 configured (on HP-UX 10.20 and 11.00).
Jeremy Hylton1b618592000-09-26 05:32:36 +0000745
Jeremy Hyltonfa2e2c12000-09-26 16:31:30 +0000746- Fix largefile support on older NetBSD systems and OpenBSD by adding
747 define for TELL64.
748
749
750Tools and other miscellany
751
752- ftpmirror: Call to main() is wrapped in if __name__ == "__main__".
753
754- freeze: The modulefinder now works with 2.0 opcodes.
755
Tim Petersa3a3a032000-11-30 05:22:44 +0000756- IDLE:
Jeremy Hyltonfa2e2c12000-09-26 16:31:30 +0000757 Move hackery of sys.argv until after the Tk instance has been
758 created, which allows the application-specific Tkinter
759 initialization to be executed if present; also pass an explicit
760 className parameter to the Tk() constructor.
Fred Drake64bb3802000-09-26 16:21:35 +0000761
Jeremy Hylton1b618592000-09-26 05:32:36 +0000762
763What's new in 2.0 beta 1?
764=========================
765
Guido van Rossumf2ffce02000-09-05 04:38:34 +0000766Source Incompatibilities
767------------------------
768
769None. Note that 1.6 introduced several incompatibilities with 1.5.2,
770such as single-argument append(), connect() and bind(), and changes to
771str(long) and repr(float).
772
773
774Binary Incompatibilities
775------------------------
776
777- Third party extensions built for Python 1.5.x or 1.6 cannot be used
778with Python 2.0; these extensions will have to be rebuilt for Python
7792.0.
780
781- On Windows, attempting to import a third party extension built for
782Python 1.5.x or 1.6 results in an immediate crash; there's not much we
783can do about this. Check your PYTHONPATH environment variable!
784
785- Python bytecode files (*.pyc and *.pyo) are not compatible between
786releases.
787
788
789Overview of Changes Since 1.6
790-----------------------------
791
792There are many new modules (including brand new XML support through
793the xml package, and i18n support through the gettext module); a list
794of all new modules is included below. Lots of bugs have been fixed.
795
Jeremy Hylton24c3d602000-09-05 19:36:26 +0000796The process for making major new changes to the language has changed
797since Python 1.6. Enhancements must now be documented by a Python
798Enhancement Proposal (PEP) before they can be accepted.
799
Guido van Rossumf2ffce02000-09-05 04:38:34 +0000800There are several important syntax enhancements, described in more
801detail below:
802
803 - Augmented assignment, e.g. x += 1
804
805 - List comprehensions, e.g. [x**2 for x in range(10)]
806
807 - Extended import statement, e.g. import Module as Name
808
809 - Extended print statement, e.g. print >> file, "Hello"
810
811Other important changes:
812
813 - Optional collection of cyclical garbage
814
Jeremy Hylton24c3d602000-09-05 19:36:26 +0000815Python Enhancement Proposal (PEP)
816---------------------------------
817
818PEP stands for Python Enhancement Proposal. A PEP is a design
819document providing information to the Python community, or describing
820a new feature for Python. The PEP should provide a concise technical
821specification of the feature and a rationale for the feature.
822
823We intend PEPs to be the primary mechanisms for proposing new
824features, for collecting community input on an issue, and for
825documenting the design decisions that have gone into Python. The PEP
826author is responsible for building consensus within the community and
827documenting dissenting opinions.
828
829The PEPs are available at http://python.sourceforge.net/peps/.
Guido van Rossumf2ffce02000-09-05 04:38:34 +0000830
831Augmented Assignment
832--------------------
833
834This must have been the most-requested feature of the past years!
835Eleven new assignment operators were added:
836
Guido van Rossume905e952000-09-05 12:42:46 +0000837 += -= *= /= %= **= <<= >>= &= ^= |=
Guido van Rossumf2ffce02000-09-05 04:38:34 +0000838
839For example,
840
841 A += B
842
843is similar to
844
845 A = A + B
846
847except that A is evaluated only once (relevant when A is something
848like dict[index].attr).
849
850However, if A is a mutable object, A may be modified in place. Thus,
851if A is a number or a string, A += B has the same effect as A = A+B
852(except A is only evaluated once); but if a is a list, A += B has the
853same effect as A.extend(B)!
854
855Classes and built-in object types can override the new operators in
856order to implement the in-place behavior; the not-in-place behavior is
857used automatically as a fallback when an object doesn't implement the
858in-place behavior. For classes, the method name is derived from the
859method name for the corresponding not-in-place operator by inserting
860an 'i' in front of the name, e.g. __iadd__ implements in-place
861__add__.
862
863Augmented assignment was implemented by Thomas Wouters.
864
865
866List Comprehensions
867-------------------
868
869This is a flexible new notation for lists whose elements are computed
870from another list (or lists). The simplest form is:
871
872 [<expression> for <variable> in <sequence>]
873
Guido van Rossum56db0952000-09-06 23:34:25 +0000874For example, [i**2 for i in range(4)] yields the list [0, 1, 4, 9].
Guido van Rossumf62ed9c2000-09-26 11:16:10 +0000875This is more efficient than a for loop with a list.append() call.
Guido van Rossumf2ffce02000-09-05 04:38:34 +0000876
877You can also add a condition:
878
879 [<expression> for <variable> in <sequence> if <condition>]
880
881For example, [w for w in words if w == w.lower()] would yield the list
882of words that contain no uppercase characters. This is more efficient
Guido van Rossumf62ed9c2000-09-26 11:16:10 +0000883than a for loop with an if statement and a list.append() call.
Guido van Rossumf2ffce02000-09-05 04:38:34 +0000884
885You can also have nested for loops and more than one 'if' clause. For
886example, here's a function that flattens a sequence of sequences::
887
888 def flatten(seq):
889 return [x for subseq in seq for x in subseq]
890
891 flatten([[0], [1,2,3], [4,5], [6,7,8,9], []])
892
893This prints
894
895 [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
896
897List comprehensions originated as a patch set from Greg Ewing; Skip
Jeremy Hylton24c3d602000-09-05 19:36:26 +0000898Montanaro and Thomas Wouters also contributed. Described by PEP 202.
Guido van Rossumf2ffce02000-09-05 04:38:34 +0000899
900
901Extended Import Statement
902-------------------------
903
904Many people have asked for a way to import a module under a different
905name. This can be accomplished like this:
906
907 import foo
908 bar = foo
909 del foo
910
911but this common idiom gets old quickly. A simple extension of the
912import statement now allows this to be written as follows:
913
914 import foo as bar
915
916There's also a variant for 'from ... import':
917
918 from foo import bar as spam
919
920This also works with packages; e.g. you can write this:
921
922 import test.regrtest as regrtest
923
924Note that 'as' is not a new keyword -- it is recognized only in this
925context (this is only possible because the syntax for the import
926statement doesn't involve expressions).
927
Jeremy Hylton24c3d602000-09-05 19:36:26 +0000928Implemented by Thomas Wouters. Described by PEP 221.
Guido van Rossumf2ffce02000-09-05 04:38:34 +0000929
930
931Extended Print Statement
932------------------------
933
934Easily the most controversial new feature, this extension to the print
935statement adds an option to make the output go to a different file
936than the default sys.stdout.
937
938For example, to write an error message to sys.stderr, you can now
939write:
940
941 print >> sys.stderr, "Error: bad dog!"
942
943As a special feature, if the expression used to indicate the file
Fred Drake45888ff2000-09-29 17:09:11 +0000944evaluates to None, the current value of sys.stdout is used. Thus:
Guido van Rossumf2ffce02000-09-05 04:38:34 +0000945
946 print >> None, "Hello world"
947
948is equivalent to
949
950 print "Hello world"
951
Jeremy Hylton24c3d602000-09-05 19:36:26 +0000952Design and implementation by Barry Warsaw. Described by PEP 214.
Guido van Rossumf2ffce02000-09-05 04:38:34 +0000953
954
955Optional Collection of Cyclical Garbage
956---------------------------------------
957
958Python is now equipped with a garbage collector that can hunt down
959cyclical references between Python objects. It's no replacement for
960reference counting; in fact, it depends on the reference counts being
961correct, and decides that a set of objects belong to a cycle if all
962their reference counts can be accounted for from their references to
963each other. This devious scheme was first proposed by Eric Tiedemann,
964and brought to implementation by Neil Schemenauer.
965
966There's a module "gc" that lets you control some parameters of the
967garbage collection. There's also an option to the configure script
968that lets you enable or disable the garbage collection. In 2.0b1,
969it's on by default, so that we (hopefully) can collect decent user
970experience with this new feature. There are some questions about its
Fred Drake9f11cf82000-09-29 17:54:40 +0000971performance. If it proves to be too much of a problem, we'll turn it
Guido van Rossumf2ffce02000-09-05 04:38:34 +0000972off by default in the final 2.0 release.
973
974
975Smaller Changes
976---------------
977
978A new function zip() was added. zip(seq1, seq2, ...) is equivalent to
979map(None, seq1, seq2, ...) when the sequences have the same length;
980i.e. zip([1,2,3], [10,20,30]) returns [(1,10), (2,20), (3,30)]. When
981the lists are not all the same length, the shortest list wins:
Jeremy Hylton24c3d602000-09-05 19:36:26 +0000982zip([1,2,3], [10,20]) returns [(1,10), (2,20)]. See PEP 201.
Guido van Rossumf2ffce02000-09-05 04:38:34 +0000983
984sys.version_info is a tuple (major, minor, micro, level, serial).
985
986Dictionaries have an odd new method, setdefault(key, default).
987dict.setdefault(key, default) returns dict[key] if it exists; if not,
988it sets dict[key] to default and returns that value. Thus:
989
990 dict.setdefault(key, []).append(item)
991
992does the same work as this common idiom:
993
994 if not dict.has_key(key):
995 dict[key] = []
996 dict[key].append(item)
997
Jeremy Hylton24c3d602000-09-05 19:36:26 +0000998There are two new variants of SyntaxError that are raised for
999indentation-related errors: IndentationError and TabError.
1000
1001Changed \x to consume exactly two hex digits; see PEP 223. Added \U
1002escape that consumes exactly eight hex digits.
Jeremy Hyltonbdebd542000-09-05 18:28:54 +00001003
1004The limits on the size of expressions and file in Python source code
1005have been raised from 2**16 to 2**32. Previous versions of Python
1006were limited because the maximum argument size the Python VM accepted
1007was 2**16. This limited the size of object constructor expressions,
1008e.g. [1,2,3] or {'a':1, 'b':2}, and the size of source files. This
1009limit was raised thanks to a patch by Charles Waldman that effectively
1010fixes the problem. It is now much more likely that you will be
1011limited by available memory than by an arbitrary limit in Python.
1012
1013The interpreter's maximum recursion depth can be modified by Python
1014programs using sys.getrecursionlimit and sys.setrecursionlimit. This
1015limit is the maximum number of recursive calls that can be made by
1016Python code. The limit exists to prevent infinite recursion from
1017overflowing the C stack and causing a core dump. The default value is
10181000. The maximum safe value for a particular platform can be found
1019by running Misc/find_recursionlimit.py.
Guido van Rossumf2ffce02000-09-05 04:38:34 +00001020
1021New Modules and Packages
1022------------------------
1023
1024atexit - for registering functions to be called when Python exits.
1025
1026imputil - Greg Stein's alternative API for writing custom import
1027hooks.
1028
1029pyexpat - an interface to the Expat XML parser, contributed by Paul
1030Prescod.
1031
1032xml - a new package with XML support code organized (so far) in three
1033subpackages: xml.dom, xml.sax, and xml.parsers. Describing these
1034would fill a volume. There's a special feature whereby a
1035user-installed package named _xmlplus overrides the standard
1036xmlpackage; this is intended to give the XML SIG a hook to distribute
1037backwards-compatible updates to the standard xml package.
1038
1039webbrowser - a platform-independent API to launch a web browser.
1040
1041
Guido van Rossume905e952000-09-05 12:42:46 +00001042Changed Modules
1043---------------
1044
Jeremy Hylton24c3d602000-09-05 19:36:26 +00001045array -- new methods for array objects: count, extend, index, pop, and
1046remove
1047
1048binascii -- new functions b2a_hex and a2b_hex that convert between
1049binary data and its hex representation
1050
Jeremy Hyltonbdebd542000-09-05 18:28:54 +00001051calendar -- Many new functions that support features including control
1052over which day of the week is the first day, returning strings instead
1053of printing them. Also new symbolic constants for days of week,
1054e.g. MONDAY, ..., SUNDAY.
1055
1056cgi -- FieldStorage objects have a getvalue method that works like a
1057dictionary's get method and returns the value attribute of the object.
1058
1059ConfigParser -- The parser object has new methods has_option,
1060remove_section, remove_option, set, and write. They allow the module
1061to be used for writing config files as well as reading them.
1062
1063ftplib -- ntransfercmd(), transfercmd(), and retrbinary() all now
Guido van Rossume905e952000-09-05 12:42:46 +00001064optionally support the RFC 959 REST command.
1065
Jeremy Hyltonbdebd542000-09-05 18:28:54 +00001066gzip -- readline and readlines now accept optional size arguments
Guido van Rossume905e952000-09-05 12:42:46 +00001067
Jeremy Hyltonbdebd542000-09-05 18:28:54 +00001068httplib -- New interfaces and support for HTTP/1.1 by Greg Stein. See
1069the module doc strings for details.
Guido van Rossum830ca2a2000-09-05 15:34:16 +00001070
Jeremy Hylton24c3d602000-09-05 19:36:26 +00001071locale -- implement getdefaultlocale for Win32 and Macintosh
1072
1073marshal -- no longer dumps core when marshaling deeply nested or
1074recursive data structures
1075
1076os -- new functions isatty, seteuid, setegid, setreuid, setregid
1077
Jeremy Hyltonbdebd542000-09-05 18:28:54 +00001078os/popen2 -- popen2/popen3/popen4 support under Windows. popen2/popen3
1079support under Unix.
1080
Jeremy Hylton24c3d602000-09-05 19:36:26 +00001081os/pty -- support for openpty and forkpty
Jeremy Hyltonbdebd542000-09-05 18:28:54 +00001082
1083os.path -- fix semantics of os.path.commonprefix
1084
1085smtplib -- support for sending very long messages
1086
1087socket -- new function getfqdn()
1088
1089readline -- new functions to read, write and truncate history files.
1090The readline section of the library reference manual contains an
1091example.
1092
Jeremy Hylton24c3d602000-09-05 19:36:26 +00001093select -- add interface to poll system call
1094
Jeremy Hyltonbdebd542000-09-05 18:28:54 +00001095shutil -- new copyfileobj function
1096
1097SimpleHTTPServer, CGIHTTPServer -- Fix problems with buffering in the
1098HTTP server.
1099
Jeremy Hylton24c3d602000-09-05 19:36:26 +00001100Tkinter -- optimization of function flatten
Jeremy Hyltonbdebd542000-09-05 18:28:54 +00001101
1102urllib -- scans environment variables for proxy configuration,
Tim Peters8b092332000-09-05 20:15:25 +00001103e.g. http_proxy.
Jeremy Hyltonbdebd542000-09-05 18:28:54 +00001104
1105whichdb -- recognizes dumbdbm format
Guido van Rossume905e952000-09-05 12:42:46 +00001106
1107
1108Obsolete Modules
1109----------------
1110
1111None. However note that 1.6 made a whole slew of modules obsolete:
1112stdwin, soundex, cml, cmpcache, dircache, dump, find, grep, packmail,
1113poly, zmod, strop, util, whatsound.
1114
1115
1116Changed, New, Obsolete Tools
1117----------------------------
1118
Tim Peters8b092332000-09-05 20:15:25 +00001119None.
Guido van Rossume905e952000-09-05 12:42:46 +00001120
1121
Guido van Rossumf2ffce02000-09-05 04:38:34 +00001122C-level Changes
1123---------------
1124
1125Several cleanup jobs were carried out throughout the source code.
1126
1127All C code was converted to ANSI C; we got rid of all uses of the
1128Py_PROTO() macro, which makes the header files a lot more readable.
1129
1130Most of the portability hacks were moved to a new header file,
1131pyport.h; several other new header files were added and some old
1132header files were removed, in an attempt to create a more rational set
1133of header files. (Few of these ever need to be included explicitly;
1134they are all included by Python.h.)
1135
Guido van Rossumf2ffce02000-09-05 04:38:34 +00001136Trent Mick ensured portability to 64-bit platforms, under both Linux
Jeremy Hylton24c3d602000-09-05 19:36:26 +00001137and Win64, especially for the new Intel Itanium processor. Mick also
1138added large file support for Linux64 and Win64.
Guido van Rossumf2ffce02000-09-05 04:38:34 +00001139
Jeremy Hyltonbdebd542000-09-05 18:28:54 +00001140The C APIs to return an object's size have been update to consistently
1141use the form PyXXX_Size, e.g. PySequence_Size and PyDict_Size. In
1142previous versions, the abstract interfaces used PyXXX_Length and the
1143concrete interfaces used PyXXX_Size. The old names,
1144e.g. PyObject_Length, are still available for backwards compatibility
1145at the API level, but are deprecated.
1146
Jeremy Hylton24c3d602000-09-05 19:36:26 +00001147The PyOS_CheckStack function has been implemented on Windows by
1148Fredrik Lundh. It prevents Python from failing with a stack overflow
1149on Windows.
Jeremy Hyltonbdebd542000-09-05 18:28:54 +00001150
1151The GC changes resulted in creation of two new slots on object,
1152tp_traverse and tp_clear. The augmented assignment changes result in
Guido van Rossum4338a282000-09-06 13:02:08 +00001153the creation of a new slot for each in-place operator.
Jeremy Hyltonbdebd542000-09-05 18:28:54 +00001154
1155The GC API creates new requirements for container types implemented in
Guido van Rossum4338a282000-09-06 13:02:08 +00001156C extension modules. See Include/objimpl.h for details.
Jeremy Hyltonbdebd542000-09-05 18:28:54 +00001157
Jeremy Hylton24c3d602000-09-05 19:36:26 +00001158PyErr_Format has been updated to automatically calculate the size of
1159the buffer needed to hold the formatted result string. This change
1160prevents crashes caused by programmer error.
Jeremy Hyltonbdebd542000-09-05 18:28:54 +00001161
Jeremy Hylton24c3d602000-09-05 19:36:26 +00001162New C API calls: PyObject_AsFileDescriptor, PyErr_WriteUnraisable.
Guido van Rossume905e952000-09-05 12:42:46 +00001163
Jeremy Hylton24c3d602000-09-05 19:36:26 +00001164PyRun_AnyFileEx, PyRun_SimpleFileEx, PyRun_FileEx -- New functions
1165that are the same as their non-Ex counterparts except they take an
1166extra flag argument that tells them to close the file when done.
1167
1168XXX There were other API changes that should be fleshed out here.
Guido van Rossumab9d6f01998-08-10 22:01:13 +00001169
Tim Peters8b092332000-09-05 20:15:25 +00001170
1171Windows Changes
1172---------------
1173
1174New popen2/popen3/peopen4 in os module (see Changed Modules above).
1175
1176os.popen is much more usable on Windows 95 and 98. See Microsoft
1177Knowledge Base article Q150956. The Win9x workaround described there
1178is implemented by the new w9xpopen.exe helper in the root of your
1179Python installation. Note that Python uses this internally; it is not
1180a standalone program.
1181
1182Administrator privileges are no longer required to install Python
1183on Windows NT or Windows 2000. If you have administrator privileges,
1184Python's registry info will be written under HKEY_LOCAL_MACHINE.
1185Otherwise the installer backs off to writing Python's registry info
Guido van Rossum4338a282000-09-06 13:02:08 +00001186under HKEY_CURRENT_USER. The latter is sufficient for all "normal"
Tim Peters8b092332000-09-05 20:15:25 +00001187uses of Python, but will prevent some advanced uses from working
1188(for example, running a Python script as an NT service, or possibly
1189from CGI).
1190
1191[This was new in 1.6] The installer no longer runs a separate Tcl/Tk
1192installer; instead, it installs the needed Tcl/Tk files directly in the
1193Python directory. If you already have a Tcl/Tk installation, this
1194wastes some disk space (about 4 Megs) but avoids problems with
1195conflicting Tcl/Tk installations, and makes it much easier for Python
1196to ensure that Tcl/Tk can find all its files.
1197
1198[This was new in 1.6] The Windows installer now installs by default in
1199\Python20\ on the default volume, instead of \Program Files\Python-2.0\.
1200
Guido van Rossumf62ed9c2000-09-26 11:16:10 +00001201
1202Updates to the changes between 1.5.2 and 1.6
1203--------------------------------------------
1204
1205The 1.6 NEWS file can't be changed after the release is done, so here
1206is some late-breaking news:
1207
1208New APIs in locale.py: normalize(), getdefaultlocale(), resetlocale(),
1209and changes to getlocale() and setlocale().
1210
1211The new module is now enabled per default.
1212
1213It is not true that the encodings codecs cannot be used for normal
1214strings: the string.encode() (which is also present on 8-bit strings
1215!) allows using them for 8-bit strings too, e.g. to convert files from
1216cp1252 (Windows) to latin-1 or vice-versa.
1217
1218Japanese codecs are available from Tamito KAJIYAMA:
1219http://pseudo.grad.sccs.chukyo-u.ac.jp/~kajiyama/python/
1220
1221
Guido van Rossumab9d6f01998-08-10 22:01:13 +00001222======================================================================