blob: 6d6c65928faaa1ce4ff36621f323d5ecc2296991 [file] [log] [blame]
Tim Petersabf925f2001-09-28 21:53:42 +00001What's New in Python 2.2b1?
2Release date: 28-Sep-2100
3===========================
4
5Type/class unification and new-style classes
6
Guido van Rossum687ae002001-10-15 22:03:32 +00007- New-style classes are now always dynamic (except for built-in and
Guido van Rossum3eea25c2001-10-16 00:46:57 +00008 extension types). There is no longer a performance penalty, and I
Guido van Rossum687ae002001-10-15 22:03:32 +00009 no longer see another reason to keep this baggage around. One relic
Guido van Rossum3eea25c2001-10-16 00:46:57 +000010 remains: the __dict__ of a new-style class is a read-only proxy; you
11 must set the class's attribute to modify it. As a consequence, the
Guido van Rossum687ae002001-10-15 22:03:32 +000012 __defined__ attribute of new-style types no longer exists, for lack
13 of need: there is once again only one __dict__ (although in the
Guido van Rossum3eea25c2001-10-16 00:46:57 +000014 future a __cache__ may be resurrected with a similar function, if I
15 can prove that it actually speeds things up).
Guido van Rossum50fda3b2001-10-04 19:46:06 +000016
Tim Peters1c9ca872001-10-04 06:43:12 +000017- C.__doc__ now works as expected for new-style classes (in 2.2a4 it
18 always returned None, even when there was a class docstring).
19
20- doctest now finds and runs docstrings attached to new-style classes,
21 class methods, static methods, and properties.
22
Guido van Rossum9074ef62001-10-16 21:34:49 +000023Core and builtins
Tim Petersabf925f2001-09-28 21:53:42 +000024
Guido van Rossuma8bcf802001-10-15 15:53:58 +000025- A very subtle syntactical pitfall in list comprehensions was fixed.
26 For example: [a+b for a in 'abc', for b in 'def']. The comma in
27 this example is a mistake. Previously, this would silently let 'a'
28 iterate over the singleton tuple ('abc',), yielding ['abcd', 'abce',
29 'abcf'] rather than the intended ['ad', 'ae', 'af', 'bd', 'be',
30 'bf', 'cd', 'ce', 'cf']. Now, this is flagged as a syntax error.
31 Note that [a for a in <singleton>] is a convoluted way to say
32 [<singleton>] anyway, so it's not like any expressiveness is lost.
33
Guido van Rossum9074ef62001-10-16 21:34:49 +000034- getattr(obj, name, default) now only catches AttributeError, as
35 documented, rather than returning the default value for all
36 exceptions (which could mask bugs in a __getattr__ hook, for
37 example).
38
Fred Drake934d2a42001-10-18 18:18:06 +000039- Weak reference objects are now part of the core and offers a C API.
40 A bug which could allow a core dump when binary operations involved
41 proxy reference has been fixed.
42
Guido van Rossum9074ef62001-10-16 21:34:49 +000043Extension modules
44
45- thread.start_new_thread() now returns the thread ID (previously None).
46
Martin v. Löwis16dc7f42001-09-30 20:32:11 +000047- binascii has now two quopri support functions, a2b_qp and b2a_qp.
48
Martin v. Löwis0daad592001-09-30 21:09:59 +000049- readline now supports setting the startup_hook and the pre_event_hook.
50
Martin v. Löwis61c5edf2001-10-18 04:06:00 +000051- posix supports chroot and setgroups where available.
Martin v. Löwis16628c92001-10-04 22:46:41 +000052
Guido van Rossum9074ef62001-10-16 21:34:49 +000053- Decompression objects in the zlib module now accept an optional
54 second parameter to decompress() that specifies the maximum amount
55 of memory to use for the uncompressed data.
Tim Petersabf925f2001-09-28 21:53:42 +000056
Guido van Rossum9074ef62001-10-16 21:34:49 +000057Library
Guido van Rossum3c288632001-10-16 21:13:49 +000058
Tim Peters7402f792001-10-02 03:53:41 +000059- doctest now excludes functions and classes not defined by the module
60 being tested, thanks to Tim Hochberg.
61
Guido van Rossumc4b09b42001-10-04 10:19:00 +000062- profile now produces correct output in situations where an exception
63 raised in Python is cleared by C code (e.g. hasattr()). This used
64 to cause wrong output, including spurious claims of recursive
65 functions and attribution of time spent to the wrong function.
66
Tim Peters0a1fc4e2001-10-07 03:12:08 +000067 The code and documentation for the derived OldProfile and HotProfile
68 profiling classes was removed. The code hasn't worked for years (if
69 you tried to use them, they raised exceptions). OldProfile
70 intended to reproduce the behavior of the profiler Python used more
71 than 7 years ago, and isn't interesting anymore. HotProfile intended
72 to provide a faster profiler (but producing less information), and
73 that's a worthy goal we intend to meet via a different approach (but
74 without losing information).
75
Tim Peterscce092d2001-10-09 05:31:56 +000076- Profile.calibrate() has a new implementation that should deliver
Tim Peters659a6032001-10-09 20:51:19 +000077 a much better system-specific calibration constant. The constant can
78 now be specified in an instance constructor, or as a Profile class or
79 instance variable, instead of by editing profile.py's source code.
80 Calibration must still be done manually (see the docs for the profile
81 module).
82
83 Note that Profile.calibrate() must be overriden by subclasses.
84 Improving the accuracy required exploiting detailed knowledge of
85 profiler internals; the earlier method abstracted away the details
86 and measured a simplified model instead, but consequently computed
87 a constant too small by a factor of 2 on some modern machines.
Tim Peterscce092d2001-10-09 05:31:56 +000088
Martin v. Löwis16dc7f42001-09-30 20:32:11 +000089- quopri's encode and decode methods take an optional header parameter,
Jeremy Hylton6f543b62001-10-16 20:42:52 +000090 which indicates whether output is intended for the header 'Q'
91 encoding.
92
Guido van Rossuma5343cc2001-10-18 18:02:07 +000093- The SocketServer.ThreadingMixIn class now closes the request after
94 finish_request() returns. (Not when it errors out though.)
95
Guido van Rossumed554f62001-10-02 23:15:37 +000096Tools/Demos
97
98- Demo/dns was removed. It no longer serves any purpose; a package
99 derived from it is now maintained by Anthony Baxter, see
100 http://PyDNS.SourceForge.net.
Tim Petersabf925f2001-09-28 21:53:42 +0000101
102Build
103
104C API
105
Guido van Rossum6c4bce32001-10-18 19:20:25 +0000106- The documentation for the tp_compare slot is updated to require that
107 the return value must be -1, 0, 1; an arbitrary number <0 or >0 is
108 not correct. This is not yet enforced but will be enforced in
109 Python 2.3; even later, we may use -2 to indicate errors and +2 for
110 "NotImplemented". Right now, -1 should be used for an error return.
111
Tim Petersd38b1c72001-09-30 05:09:37 +0000112- PyLong_AsLongLong() now accepts int (as well as long) arguments.
113 Consequently, PyArg_ParseTuple's 'L' code also accepts int (as well
114 as long) arguments.
115
Guido van Rossum3c288632001-10-16 21:13:49 +0000116- PyThread_start_new_thread() now returns a long int giving the thread
117 ID, if one can be calculated; it returns -1 for error, 0 if no
118 thread ID is calculated (this is an incompatible change, but only
119 the thread module used this API). This code has only really been
120 tested on Linux and Windows; other platforms please beware (and
121 report any bugs or strange behavior).
122
Tim Petersabf925f2001-09-28 21:53:42 +0000123New platforms
124
125Tests
126
127Windows
128
Tim Peters04cf1d32001-10-09 22:39:40 +0000129- Installer: If you install IDLE, and don't disable file-extension
130 registration, a new "Edit with IDLE" context (right-click) menu entry
131 is created for .py and .pyw files.
132
Tim Peters1ce3cf72001-10-01 17:58:40 +0000133- The signal module now supports SIGBREAK on Windows, thanks to Steven
134 Scott. Note that SIGBREAK is unique to Windows. The default SIGBREAK
135 action remains to call Win32 ExitProcess(). This can be changed via
136 signal.signal(). For example:
137
138 # Make Ctrl+Break raise KeyboardInterrupt, like Python's default Ctrl+C
139 # (SIGINT) behavior.
140 import signal
141 signal.signal(signal.SIGBREAK,
142 signal.default_int_handler)
143
144 try:
145 while 1:
146 pass
147 except KeyboardInterrupt:
148 # We get here on Ctrl+C or Ctrl+Break now; if we had not changed
149 # SIGBREAK, only on Ctrl+C (and Ctrl+Break would terminate the
150 # program without the possibility for any Python-level cleanup).
151 print "Clean exit"
152
Tim Petersabf925f2001-09-28 21:53:42 +0000153
Tim Petersb07352e2001-09-08 01:25:47 +0000154What's New in Python 2.2a4?
Barry Warsaw86fbaf82001-09-28 15:26:12 +0000155Release date: 28-Sep-2001
Tim Petersb07352e2001-09-08 01:25:47 +0000156===========================
157
Guido van Rossum808eea72001-09-25 04:15:41 +0000158Type/class unification and new-style classes
159
160- pydoc and inspect are now aware of new-style classes;
161 e.g. help(list) at the interactive prompt now shows proper
162 documentation for all operations on list objects.
163
164- Applications using Jim Fulton's ExtensionClass module can now safely
165 be used with Python 2.2. In particular, Zope 2.4.1 now works with
166 Python 2.2 (as well as with Python 2.1.1). The Demo/metaclass
167 examples also work again. It is hoped that Gtk and Boost also work
168 with 2.2a4 and beyond. (If you can confirm this, please write
169 webmaster@python.org; if there are still problems, please open a bug
170 report on SourceForge.)
Tim Petersb07352e2001-09-08 01:25:47 +0000171
Tim Peters66c1a522001-09-24 21:17:50 +0000172- property() now takes 4 keyword arguments: fget, fset, fdel and doc.
173 These map to readonly attributes 'fget', 'fset', 'fdel', and '__doc__'
174 in the constructed property object. fget, fset and fdel weren't
175 discoverable from Python in 2.2a3. __doc__ is new, and allows to
176 associate a docstring with a property.
177
Guido van Rossum808eea72001-09-25 04:15:41 +0000178- Comparison overloading is now more completely implemented. For
179 example, a str subclass instance can properly be compared to a str
180 instance, and it can properly overload comparison. Ditto for most
181 other built-in object types.
182
183- The repr() of new-style classes has changed; instead of <type
184 'M.Foo'> a new-style class is now rendered as <class 'M.Foo'>,
185 *except* for built-in types, which are still rendered as <type
186 'Foo'> (to avoid upsetting existing code that might parse or
187 otherwise rely on repr() of certain type objects).
188
189- The repr() of new-style objects is now always <Foo object at XXX>;
190 previously, it was sometimes <Foo instance at XXX>.
191
192- For new-style classes, what was previously called __getattr__ is now
193 called __getattribute__. This method, if defined, is called for
194 *every* attribute access. A new __getattr__ hook mor similar to the
195 one in classic classes is defined which is called only if regular
196 attribute access raises AttributeError; to catch *all* attribute
197 access, you can use __getattribute__ (for new-style classes). If
198 both are defined, __getattribute__ is called first, and if it raises
199 AttributeError, __getattr__ is called.
200
201- The __class__ attribute of new-style objects can be assigned to.
202 The new class must have the same C-level object layout as the old
203 class.
204
205- The builtin file type can be subclassed now. In the usual pattern,
206 "file" is the name of the builtin type, and file() is a new builtin
207 constructor, with the same signature as the builtin open() function.
208 file() is now the preferred way to open a file.
209
210- Previously, __new__ would only see sequential arguments passed to
211 the type in a constructor call; __init__ would see both sequential
212 and keyword arguments. This made no sense whatsoever any more, so
213 now both __new__ and __init__ see all arguments.
214
215- Previously, hash() applied to an instance of a subclass of str or
216 unicode always returned 0. This has been repaired.
217
218- Previously, an operation on an instance of a subclass of an
219 immutable type (int, long, float, complex, tuple, str, unicode),
220 where the subtype didn't override the operation (and so the
221 operation was handled by the builtin type), could return that
222 instance instead a value of the base type. For example, if s was of
223 a str sublass type, s[:] returned s as-is. Now it returns a str
224 with the same value as s.
225
Barry Warsaw86fbaf82001-09-28 15:26:12 +0000226- Provisional support for pickling new-style objects has been added.
227
Guido van Rossum808eea72001-09-25 04:15:41 +0000228Core
229
Tim Peters2c9aa5e2001-09-23 04:06:05 +0000230- file.writelines() now accepts any iterable object producing strings.
231
Marc-André Lemburgaefd7662001-09-20 12:59:37 +0000232- PyUnicode_FromEncodedObject() now works very much like
233 PyObject_Str(obj) in that it tries to use __str__/tp_str
234 on the object if the object is not a string or buffer. This
235 makes unicode() behave like str() when applied to non-string/buffer
236 objects.
237
Martin v. Löwis2777c022001-09-19 13:47:32 +0000238- PyFile_WriteObject now passes Unicode object to the file's write
239 method. As a result, all file-like object which may be the target
240 of a print statement must support Unicode objects, i.e. they must
241 at least convert them into ASCII strings.
242
Guido van Rossum624c8af2001-09-18 15:21:04 +0000243- Thread scheduling on Solaris should be improved; it is no longer
244 necessary to insert a small sleep at the start of a thread in order
245 to let other runnable threads be scheduled.
246
Tim Petersb07352e2001-09-08 01:25:47 +0000247Library
248
Marc-André Lemburgbf990172001-09-27 14:17:33 +0000249- StringIO.StringIO instances and cStringIO.StringIO instances support
250 read character buffer compatible objects for their .write() methods.
251 These objects are converted to strings and then handled as such
252 by the instances.
253
Barry Warsaw2f600732001-09-24 04:28:10 +0000254- The "email" package has been added. This is basically a port of the
255 mimelib package <http://sf.net/projects/mimelib> with API changes
256 and some implementations updated to use iterators and generators.
257
Tim Peters8a9c2842001-09-22 21:30:22 +0000258- difflib.ndiff() and difflib.Differ.compare() are generators now. This
259 restores the ability of Tools/scripts/ndiff.py to start producing output
260 before the entire comparison is complete.
261
Barry Warsaw58b072d2001-09-22 04:44:21 +0000262- StringIO.StringIO instances and cStringIO.StringIO instances support
263 iteration just like file objects (i.e. their .readline() method is
264 called for each iteration until it returns an empty string).
265
Marc-André Lemburg494f2ae2001-09-19 11:33:31 +0000266- The codecs module has grown four new helper APIs to access
267 builtin codecs: getencoder(), getdecoder(), getreader(),
268 getwriter().
269
Guido van Rossum624c8af2001-09-18 15:21:04 +0000270- SimpleXMLRPCServer: a new module (based upon SimpleHTMLServer)
271 simplifies writing XML RPC servers.
272
Barry Warsaw647d5e82001-09-28 17:01:02 +0000273- os.path.realpath(): a new function that returns the absolute pathname
Guido van Rossum624c8af2001-09-18 15:21:04 +0000274 after interpretation of symbolic links. On non-Unix systems, this
275 is an alias for os.path.abspath().
276
Tim Peters16a77ad2001-09-08 04:00:12 +0000277- operator.indexOf() (PySequence_Index() in the C API) now works with any
278 iterable object.
279
Guido van Rossum624c8af2001-09-18 15:21:04 +0000280- smtplib now supports various authentication and security features of
281 the SMTP protocol through the new login() and starttls() methods.
Guido van Rossumd8185ca2001-09-14 16:35:16 +0000282
Guido van Rossum624c8af2001-09-18 15:21:04 +0000283- hmac: a new module implementing keyed hashing for message
284 authentication.
285
286- mimetypes now recognizes more extensions and file types. At the
287 same time, some mappings not sanctioned by IANA were removed.
Guido van Rossumd8185ca2001-09-14 16:35:16 +0000288
Guido van Rossum624c8af2001-09-18 15:21:04 +0000289- The "compiler" package has been brought up to date to the state of
Guido van Rossumc9ed5dc2001-09-20 05:30:24 +0000290 Python 2.2 bytecode generation. It has also been promoted from a
291 Tool to a standard library package. (Tools/compiler still exists as
292 a sample driver.)
293
Guido van Rossumc9ed5dc2001-09-20 05:30:24 +0000294Tools
Guido van Rossum624c8af2001-09-18 15:21:04 +0000295
Tim Petersb07352e2001-09-08 01:25:47 +0000296Build
297
Guido van Rossum624c8af2001-09-18 15:21:04 +0000298- Large file support (LFS) is now automatic when the platform supports
299 it; no more manual configuration tweaks are needed. On Linux, at
300 least, it's possible to have a system whose C library supports large
301 files but whose kernel doesn't; in this case, large file support is
302 still enabled but doesn't do you any good unless you upgrade your
303 kernel or share your Python executable with another system whose
304 kernel has large file support.
305
306- The configure script now supplies plausible defaults in a
307 cross-compilation environment. This doesn't mean that the supplied
308 values are always correct, or that cross-compilation now works
309 flawlessly -- but it's a first step (and it shuts up most of
310 autoconf's warnings about AC_TRY_RUN).
311
312- The Unix build is now a bit less chatty, courtesy of the parser
313 generator. The build is completely silent (except for errors) when
314 using "make -s", thanks to a -q option to setup.py.
315
Tim Petersb07352e2001-09-08 01:25:47 +0000316C API
317
Guido van Rossum624c8af2001-09-18 15:21:04 +0000318- The "structmember" API now supports some new flag bits to deny read
319 and/or write access to attributes in restricted execution mode.
320
Tim Petersb07352e2001-09-08 01:25:47 +0000321New platforms
322
Guido van Rossum624c8af2001-09-18 15:21:04 +0000323- Compaq's iPAQ handheld, running the "familiar" Linux distribution
324 (http://familiar.handhelds.org).
325
Tim Petersb07352e2001-09-08 01:25:47 +0000326Tests
327
Tim Peters8a9c2842001-09-22 21:30:22 +0000328- The "classic" standard tests, which work by comparing stdout to
329 an expected-output file under Lib/test/output/, no longer stop at
330 the first mismatch. Instead the test is run to completion, and a
331 variant of ndiff-style comparison is used to report all differences.
332 This is much easier to understand than the previous style of reporting.
333
334- The unittest-based standard tests now use regrtest's test_main()
335 convention, instead of running as a side-effect of merely being
336 imported. This allows these tests to be run in more natural and
337 flexible ways as unittests, outside the regrtest framework.
338
339- regrtest.py is much better integrated with unittest and doctest now,
340 especially in regard to reporting errors.
341
Tim Petersb07352e2001-09-08 01:25:47 +0000342Windows
343
Guido van Rossum624c8af2001-09-18 15:21:04 +0000344- Large file support now also works for files > 4GB, on filesystems
Tim Peters8a9c2842001-09-22 21:30:22 +0000345 that support it (NTFS under Windows 2000). See "What's New in
346 Python 2.2a3" for more detail.
Guido van Rossum624c8af2001-09-18 15:21:04 +0000347
Tim Petersb07352e2001-09-08 01:25:47 +0000348
Tim Petersedc99312001-08-22 21:36:50 +0000349What's New in Python 2.2a3?
Barry Warsaw86fbaf82001-09-28 15:26:12 +0000350Release Date: 07-Sep-2001
Tim Petersedc99312001-08-22 21:36:50 +0000351===========================
352
353Core
354
Tim Peters9fffa3e2001-09-04 05:14:19 +0000355- Conversion of long to float now raises OverflowError if the long is too
356 big to represent as a C double.
357
Tim Peters32f453e2001-09-03 08:35:41 +0000358- The 3-argument builtin pow() no longer allows a third non-None argument
359 if either of the first two arguments is a float, or if both are of
360 integer types and the second argument is negative (in which latter case
361 the arguments are converted to float, so this is really the same
362 restriction).
363
Tim Peters5d2b77c2001-09-03 05:47:38 +0000364- The builtin dir() now returns more information, and sometimes much
365 more, generally naming all attributes of an object, and all attributes
366 reachable from the object via its class, and from its class's base
367 classes, and so on from them too. Example: in 2.2a2, dir([]) returned
368 an empty list. In 2.2a3,
369
370 >>> dir([])
371 ['__add__', '__class__', '__contains__', '__delattr__', '__delitem__',
372 '__eq__', '__ge__', '__getattr__', '__getitem__', '__getslice__',
373 '__gt__', '__hash__', '__iadd__', '__imul__', '__init__', '__le__',
374 '__len__', '__lt__', '__mul__', '__ne__', '__new__', '__repr__',
375 '__rmul__', '__setattr__', '__setitem__', '__setslice__', '__str__',
376 'append', 'count', 'extend', 'index', 'insert', 'pop', 'remove',
377 'reverse', 'sort']
378
379 dir(module) continues to return only the module's attributes, though.
380
Tim Petersbdee63f2001-09-02 03:40:59 +0000381- Overflowing operations on plain ints now return a long int rather
Guido van Rossumae457142001-08-31 18:31:35 +0000382 than raising OverflowError. This is a partial implementation of PEP
383 237. You can use -Wdefault::OverflowWarning to enable a warning for
384 this situation, and -Werror::OverflowWarning to revert to the old
385 OverflowError exception.
386
Guido van Rossum61c345f2001-09-04 03:26:15 +0000387- A new command line option, -Q<arg>, is added to control run-time
Guido van Rossumae457142001-08-31 18:31:35 +0000388 warnings for the use of classic division. (See PEP 238.) Possible
Barry Warsawd6c8ca62001-09-07 18:13:44 +0000389 values are -Qold, -Qwarn, -Qwarnall, and -Qnew. The default is
390 -Qold, meaning the / operator has its classic meaning and no
391 warnings are issued. Using -Qwarn issues a run-time warning about
392 all uses of classic division for int and long arguments; -Qwarnall
393 also warns about classic division for float and complex arguments
394 (for use with fixdiv.py). Using -Qnew is questionable; it turns on
395 new division by default, but only in the __main__ module. You can
396 usefully combine -Qwarn or -Qwarnall and -Qnew: this gives the
397 __main__ module new division, and warns about classic division
398 everywhere else.
Guido van Rossumae457142001-08-31 18:31:35 +0000399
Tim Petersbdee63f2001-09-02 03:40:59 +0000400- Many built-in types can now be subclassed. This applies to int,
Guido van Rossumae457142001-08-31 18:31:35 +0000401 long, float, str, unicode, and tuple. (The types complex, list and
402 dictionary can also be subclassed; this was introduced earlier.)
403 Note that restrictions apply when subclassing immutable built-in
404 types: you can only affect the value of the instance by overloading
405 __new__. You can add mutable attributes, and the subclass instances
406 will have a __dict__ attribute, but you cannot change the "value"
407 (as implemented by the base class) of an immutable subclass instance
408 once it is created.
409
Guido van Rossumaaf80c82001-09-02 13:44:35 +0000410- The dictionary constructor now takes an optional argument, a
411 mapping-like object, and initializes the dictionary from its
412 (key, value) pairs.
413
Tim Petersbdee63f2001-09-02 03:40:59 +0000414- A new built-in type, super, has been added. This facilitates making
Guido van Rossumae457142001-08-31 18:31:35 +0000415 "cooperative super calls" in a multiple inheritance setting. For an
416 explanation, see http://www.python.org/2.2/descrintro.html#cooperation
417
Guido van Rossum8d7234d2001-09-06 22:02:58 +0000418- A new built-in type, property, has been added. This enables the
419 creation of "properties". These are attributes implemented by
420 getter and setter functions (or only one of these for read-only or
421 write-only attributes), without the need to override __getattr__.
422 See http://www.python.org/2.2/descrintro.html#property
Guido van Rossumae457142001-08-31 18:31:35 +0000423
Tim Petersbdee63f2001-09-02 03:40:59 +0000424- The syntax of floating-point and imaginary literals has been
Tim Petersd507dab2001-08-30 20:51:59 +0000425 liberalized, to allow leading zeroes. Examples of literals now
426 legal that were SyntaxErrors before:
427
428 00.0 0e3 0100j 07.5 00000000000000000008.
429
Tim Petersbdee63f2001-09-02 03:40:59 +0000430- An old tokenizer bug allowed floating point literals with an incomplete
Tim Petersc6d95812001-08-28 20:56:27 +0000431 exponent, such as 1e and 3.1e-. Such literals now raise SyntaxError.
432
Tim Petersedc99312001-08-22 21:36:50 +0000433Library
434
Martin v. Löwiscb227c92001-09-06 08:54:16 +0000435- telnetlib includes symbolic names for the options, and support for
436 setting an option negotiation callback.
437
Tim Petersa40c7932001-09-05 22:36:56 +0000438- The new C standard no longer requires that math libraries set errno to
439 ERANGE on overflow. For platform libraries that exploit this new
440 freedom, Python's overflow-checking was wholly broken. A new overflow-
441 checking scheme attempts to repair that, but may not be reliable on all
442 platforms (C doesn't seem to provide anything both useful and portable
443 in this area anymore).
444
Martin v. Löwis44f86962001-09-05 13:44:54 +0000445- Asynchronous timeout actions are available through the new class
446 threading.Timer.
447
Tim Peters78526162001-09-05 00:53:45 +0000448- math.log and math.log10 now return sensible results for even huge
449 long arguments. For example, math.log10(10 ** 10000) ~= 10000.0.
450
Tim Petersbdee63f2001-09-02 03:40:59 +0000451- A new function, imp.lock_held(), returns 1 when the import lock is
Tim Peters69232342001-08-30 05:16:13 +0000452 currently held. See the docs for the imp module.
453
Tim Petersbdee63f2001-09-02 03:40:59 +0000454- pickle, cPickle and marshal on 32-bit platforms can now correctly read
Tim Peters82112372001-08-29 02:28:42 +0000455 dumps containing ints written on platforms where Python ints are 8 bytes.
456 When read on a box where Python ints are 4 bytes, such values are
457 converted to Python longs.
458
Tim Petersbdee63f2001-09-02 03:40:59 +0000459- In restricted execution mode (using the rexec module), unmarshalling
Guido van Rossumae457142001-08-31 18:31:35 +0000460 code objects is no longer allowed. This plugs a security hole.
461
Steve Purcell6091cd62001-09-06 16:05:17 +0000462- unittest.TestResult instances no longer store references to tracebacks
463 generated by test failures. This prevents unexpected dangling references
464 to objects that should be garbage collected between tests.
465
Tim Petersedc99312001-08-22 21:36:50 +0000466Tools
467
Barry Warsawd6c8ca62001-09-07 18:13:44 +0000468- Tools/scripts/fixdiv.py has been added which can be used to fix
469 division operators as per PEP 238.
470
Tim Petersedc99312001-08-22 21:36:50 +0000471Build
472
Barry Warsawd6c8ca62001-09-07 18:13:44 +0000473- If you are an adventurous person using Mac OS X you may want to look at
474 Mac/OSX. There is a Makefile there that will build Python as a real Mac
475 application, which can be used for experimenting with Carbon or Cocoa.
476 Discussion of this on pythonmac-sig, please.
477
Tim Peters7eea37e2001-09-04 22:08:56 +0000478C API
479
480- New function PyObject_Dir(obj), like Python __builtin__.dir(obj).
Tim Peters69232342001-08-30 05:16:13 +0000481
Tim Peters9fffa3e2001-09-04 05:14:19 +0000482- Note that PyLong_AsDouble can fail! This has always been true, but no
483 callers checked for it. It's more likely to fail now, because overflow
484 errors are properly detected now. The proper way to check:
485
486 double x = PyLong_AsDouble(some_long_object);
487 if (x == -1.0 && PyErr_Occurred()) {
488 /* The conversion failed. */
489 }
490
Tim Petersbdee63f2001-09-02 03:40:59 +0000491- The GC API has been changed. Extensions that use the old API will still
Neil Schemenauer4042c692001-08-30 15:38:01 +0000492 compile but will not participate in GC. To upgrade an extension
493 module:
494
495 - rename Py_TPFLAGS_GC to PyTPFLAGS_HAVE_GC
Tim Petersd507dab2001-08-30 20:51:59 +0000496
Neil Schemenauer4042c692001-08-30 15:38:01 +0000497 - use PyObject_GC_New or PyObject_GC_NewVar to allocate objects and
498 PyObject_GC_Del to deallocate them
Tim Petersd507dab2001-08-30 20:51:59 +0000499
Neil Schemenauer4042c692001-08-30 15:38:01 +0000500 - rename PyObject_GC_Init to PyObject_GC_Track and PyObject_GC_Fini
501 to PyObject_GC_UnTrack
Tim Petersd507dab2001-08-30 20:51:59 +0000502
Neil Schemenauer4042c692001-08-30 15:38:01 +0000503 - remove PyGC_HEAD_SIZE from object size calculations
504
505 - remove calls to PyObject_AS_GC and PyObject_FROM_GC
506
Tim Petersbdee63f2001-09-02 03:40:59 +0000507- Two new functions: PyString_FromFormat() and PyString_FromFormatV().
Guido van Rossumae457142001-08-31 18:31:35 +0000508 These can be used safely to construct string objects from a
509 sprintf-style format string (similar to the format string supported
510 by PyErr_Format()).
Tim Peters69232342001-08-30 05:16:13 +0000511
Tim Petersedc99312001-08-22 21:36:50 +0000512New platforms
513
Tim Petersb7da0902001-09-02 23:01:43 +0000514- Stephen Hansen contributed patches sufficient to get a clean compile
515 under Borland C (Windows), but he reports problems running it and ran
516 out of time to complete the port. Volunteers? Expect a MemoryError
517 when importing the types module; this is probably shallow, and
518 causing later failures too.
Tim Petersbdee63f2001-09-02 03:40:59 +0000519
Tim Petersedc99312001-08-22 21:36:50 +0000520Tests
521
522Windows
523
Tim Peters6e13a562001-09-06 00:32:15 +0000524- Large file support is now enabled on Win32 platforms as well as on
525 Win64. This means that, for example, you can use f.tell() and f.seek()
526 to manipulate files larger than 2 gigabytes (provided you have enough
527 disk space, and are using a Windows filesystem that supports large
Tim Peters9a9471c2001-09-11 23:18:51 +0000528 partitions). Windows filesystem limits: FAT has a 2GB (gigabyte)
529 filesize limit, and large file support makes no difference there.
530 FAT32's limit is 4GB, and files >= 2GB are easier to use from Python now.
531 NTFS has no practical limit on file size, and files of any size can be
532 used from Python now.
Tim Peters6e13a562001-09-06 00:32:15 +0000533
Tim Petersbdee63f2001-09-02 03:40:59 +0000534- The w9xpopen hack is now used on Windows NT and 2000 too when COMPSPEC
Tim Peters402d5982001-08-27 06:37:48 +0000535 points to command.com (patch from Brian Quinlan).
536
Tim Petersedc99312001-08-22 21:36:50 +0000537
Tim Peters20f51a72001-07-21 02:31:40 +0000538What's New in Python 2.2a2?
Barry Warsaw86fbaf82001-09-28 15:26:12 +0000539Release Date: 22-Aug-2001
Tim Peters20f51a72001-07-21 02:31:40 +0000540===========================
541
Martin v. Löwis339d0f72001-08-17 18:39:25 +0000542Build
543
Barry Warsaw18b2ecf2001-08-22 20:26:56 +0000544- Tim Peters developed a brand new Windows installer using Wise 8.1,
545 generously donated to us by Wise Solutions.
546
Martin v. Löwis339d0f72001-08-17 18:39:25 +0000547- configure supports a new option --enable-unicode, with the values
548 ucs2 and ucs4 (new in 2.2a1). With --disable-unicode, the Unicode
549 type and supporting code is completely removed from the interpreter.
Barry Warsaw6f3410d2001-08-22 04:08:41 +0000550
Jack Jansen32ce0cd2001-08-21 19:28:20 +0000551- A new configure option --enable-framework builds a Mac OS X framework,
552 which "make frameworkinstall" will install. This provides a starting
553 point for more mac-like functionality, join pythonmac-sig@python.org
554 if you are interested in helping.
Martin v. Löwis339d0f72001-08-17 18:39:25 +0000555
Barry Warsaw6f3410d2001-08-22 04:08:41 +0000556- The NeXT platform is no longer supported.
557
558- The `new' module is now statically linked.
559
Tim Peters0afb6092001-08-15 06:06:44 +0000560Tools
561
562- The new Tools/scripts/cleanfuture.py can be used to automatically
Andrew M. Kuchlingb0532092001-08-15 15:54:56 +0000563 edit out obsolete future statements from Python source code. See
Tim Peters0afb6092001-08-15 06:06:44 +0000564 the module docstring for details.
565
Tim Peters20f51a72001-07-21 02:31:40 +0000566Tests
567
Tim Peters5e824c32001-08-12 22:25:01 +0000568- regrtest.py now knows which tests are expected to be skipped on some
Barry Warsaw6f3410d2001-08-22 04:08:41 +0000569 platforms, allowing to give clearer test result output. regrtest
570 also has optional --use/-u switch to run normally disabled tests
571 which require network access or consume significant disk resources.
Tim Peters5e824c32001-08-12 22:25:01 +0000572
Tim Peters20f51a72001-07-21 02:31:40 +0000573- Several new tests in the standard test suite, with special thanks to
574 Nick Mathewson.
575
576Core
577
Barry Warsaw6f3410d2001-08-22 04:08:41 +0000578- The floor division operator // has been added as outlined in PEP
579 238. The / operator still provides classic division (and will until
580 Python 3.0) unless "from __future__ import division" is included, in
581 which case the / operator will provide true division. The operator
582 module provides truediv() and floordiv() functions. Augmented
583 assignment variants are included, as are the equivalent overloadable
584 methods and C API methods. See the PEP for a full discussion:
585 <http://python.sf.net/peps/pep-0238.html>
586
Tim Peters6cd6a822001-08-17 22:11:27 +0000587- Future statements are now effective in simulated interactive shells
588 (like IDLE). This should "just work" by magic, but read Michael
589 Hudson's "Future statements in simulated shells" PEP 264 for full
590 details: <http://python.sf.net/peps/pep-0264.html>.
591
Guido van Rossumf86ddd22001-08-17 21:21:04 +0000592- The type/class unification (PEP 252-253) was integrated into the
593 trunk and is not so tentative any more (the exact specification of
594 some features is still tentative). A lot of work has done on fixing
595 bugs and adding robustness and features (performance still has to
596 come a long way).
597
Marc-André Lemburg888fac02001-07-31 14:24:31 +0000598- Warnings about a mismatch in the Python API during extension import
599 now use the Python warning framework (which makes it possible to
600 write filters for these warnings).
601
Barry Warsaw9b3be7f2001-08-14 18:35:02 +0000602- A function's __dict__ (aka func_dict) will now always be a
603 dictionary. It used to be possible to delete it or set it to None,
604 but now both actions raise TypeErrors. It is still legal to set it
605 to a dictionary object. Getting func.__dict__ before any attributes
606 have been assigned now returns an empty dictionary instead of None.
607
Guido van Rossum32aa5d22001-09-05 18:43:35 +0000608- A new command line option, -E, was added which disables the use of
609 all environment variables, or at least those that are specifically
610 significant to Python. Usually those have a name starting with
611 "PYTHON". This was used to fix a problem where the tests fail if
612 the user happens to have PYTHONHOME or PYTHONPATH pointing to an
613 older distribution.
614
Marc-André Lemburgd6277912001-07-31 14:42:42 +0000615Library
616
Tim Peters5e824c32001-08-12 22:25:01 +0000617- New class Differ and new functions ndiff() and restore() in difflib.py.
618 These package the algorithms used by the popular Tools/scripts/ndiff.py,
Tim Peters0afb6092001-08-15 06:06:44 +0000619 for programmatic reuse.
Tim Peters5e824c32001-08-12 22:25:01 +0000620
Marc-André Lemburgd6277912001-07-31 14:42:42 +0000621- New function xml.sax.saxutils.quoteattr(): Quote an XML attribute
622 value using the minimal quoting required for the value; more
623 reliable than using xml.sax.saxutils.escape() for attribute values.
624
625- Readline completion support for cmd.Cmd was added.
626
Barry Warsaw6f3410d2001-08-22 04:08:41 +0000627- Calling os.tempnam() or os.tmpnam() generate RuntimeWarnings.
628
629- Added function threading.BoundedSemaphore()
630
631- Added Ka-Ping Yee's cgitb.py module.
632
633- The `new' module now exposes the CO_xxx flags.
634
Marc-André Lemburgd6277912001-07-31 14:42:42 +0000635New platforms
636
637C API
638
Marc-André Lemburg888fac02001-07-31 14:24:31 +0000639- Two new APIs PyOS_snprintf() and PyOS_vsnprintf() were added
640 which provide a cross-platform implementations for the
641 relatively new snprintf()/vsnprintf() C lib APIs. In contrast to
642 the standard sprintf() and vsprintf() C lib APIs, these versions
643 apply bounds checking on the used buffer which enhances protection
644 against buffer overruns.
645
Marc-André Lemburg48dbfe92001-07-31 14:37:40 +0000646- Unicode APIs now use name mangling to assure that mixing interpreters
Tim Petersc1731372001-08-04 08:12:36 +0000647 and extensions using different Unicode widths is rendered next to
648 impossible. Trying to import an incompatible Unicode-aware extension
Marc-André Lemburg48dbfe92001-07-31 14:37:40 +0000649 will result in an ImportError. Unicode extensions writers must make
650 sure to check the Unicode width compatibility in their extensions by
651 using at least one of the mangled Unicode APIs in the extension.
652
Martin v. Löwis339d0f72001-08-17 18:39:25 +0000653- Two new flags METH_NOARGS and METH_O are available in method definition
654 tables to simplify implementation of methods with no arguments and a
655 single untyped argument. Calling such methods is more efficient than
656 calling corresponding METH_VARARGS methods. METH_OLDARGS is now
657 deprecated.
658
Tim Petersc1731372001-08-04 08:12:36 +0000659Windows
660
661- "import module" now compiles module.pyw if it exists and nothing else
662 relevant is found.
663
Tim Peters20f51a72001-07-21 02:31:40 +0000664
Guido van Rossum55a78992001-07-17 17:22:32 +0000665What's New in Python 2.2a1?
Tim Petersf553f892001-05-01 20:45:31 +0000666===========================
667
668Core
Tim Petersa814db52001-05-14 07:05:58 +0000669
Tim Peters6d6c1a32001-08-02 04:15:00 +0000670- TENTATIVELY, a large amount of code implementing much of what's
671 described in PEP 252 (Making Types Look More Like Classes) and PEP
672 253 (Subtyping Built-in Types) was added. This will be released
673 with Python 2.2a1. Documentation will be provided separately
674 through http://www.python.org/2.2/. The purpose of releasing this
675 with Python 2.2a1 is to test backwards compatibility. It is
676 possible, though not likely, that a decision is made not to release
677 this code as part of 2.2 final, if any serious backwards
678 incompapatibilities are found during alpha testing that cannot be
679 repaired.
680
Guido van Rossum55a78992001-07-17 17:22:32 +0000681- Generators were added; this is a new way to create an iterator (see
Tim Peters11a0d102001-07-17 18:48:00 +0000682 below) using what looks like a simple function containing one or
Guido van Rossum55a78992001-07-17 17:22:32 +0000683 more 'yield' statements. See PEP 255. Since this adds a new
684 keyword to the language, this feature must be enabled by including a
685 future statement: "from __future__ import generators" (see PEP 236).
686 Generators will become a standard feature in a future release
687 (probably 2.3). Without this future statement, 'yield' remains an
688 ordinary identifier, but a warning is issued each time it is used.
689 (These warnings currently don't conform to the warnings framework of
690 PEP 230; we intend to fix this in 2.2a2.)
691
Marc-André Lemburg12e74b32001-05-22 08:58:23 +0000692- The UTF-16 codec was modified to be more RFC compliant. It will now
693 only remove BOM characters at the start of the string and then
694 only if running in native mode (UTF-16-LE and -BE won't remove a
695 leading BMO character).
696
Marc-André Lemburgfab96cc2001-05-15 18:38:45 +0000697- Strings now have a new method .decode() to complement the already
698 existing .encode() method. These two methods provide direct access
699 to the corresponding decoders and encoders of the registered codecs.
700
701 To enhance the usability of the .encode() method, the special
702 casing of Unicode object return values was dropped (Unicode objects
703 were auto-magically converted to string using the default encoding).
Tim Peterseb28ef22001-06-02 05:27:19 +0000704
Marc-André Lemburgfab96cc2001-05-15 18:38:45 +0000705 Both methods will now return whatever the codec in charge of the
706 requested encoding returns as object, e.g. Unicode codecs will
707 return Unicode objects when decoding is requested ("äöü".decode("latin-1")
708 will return u"äöü"). This enables codec writer to create codecs
709 for various simple to use conversions.
710
711 New codecs were added to demonstrate these new features (the .encode()
712 and .decode() columns indicate the type of the returned objects):
713
714 Name | .encode() | .decode() | Description
715 ----------------------------------------------------------------------
716 uu | string | string | UU codec (e.g. for email)
717 base64 | string | string | base64 codec
Guido van Rossumc3415802001-06-06 13:30:54 +0000718 quopri | string | string | quoted-printable codec
Marc-André Lemburgfab96cc2001-05-15 18:38:45 +0000719 zlib | string | string | zlib compression
720 hex | string | string | 2-byte hex codec
721 rot-13 | string | Unicode | ROT-13 Unicode charmap codec
722
Mark Hammond2a0af792001-05-14 03:09:36 +0000723- Some operating systems now support the concept of a default Unicode
724 encoding for file system operations. Notably, Windows supports 'mbcs'
725 as the default. The Macintosh will also adopt this concept in the medium
Guido van Rossum1bd797a2001-05-14 13:53:38 +0000726 term, although the default encoding for that platform will be other than
Mark Hammond2a0af792001-05-14 03:09:36 +0000727 'mbcs'.
Guido van Rossum1bd797a2001-05-14 13:53:38 +0000728
729 On operating system that support non-ASCII filenames, it is common for
Mark Hammond2a0af792001-05-14 03:09:36 +0000730 functions that return filenames (such as os.listdir()) to return Python
731 string objects pre-encoded using the default file system encoding for
732 the platform. As this encoding is likely to be different from Python's
733 default encoding, converting this name to a Unicode object before passing
734 it back to the Operating System would result in a Unicode error, as Python
Tim Petersa814db52001-05-14 07:05:58 +0000735 would attempt to use its default encoding (generally ASCII) rather than
736 the default encoding for the file system.
Guido van Rossum1bd797a2001-05-14 13:53:38 +0000737
Tim Petersa814db52001-05-14 07:05:58 +0000738 In general, this change simply removes surprises when working with
739 Unicode and the file system, making these operations work as you expect,
740 increasing the transparency of Unicode objects in this context.
Mark Hammond2a0af792001-05-14 03:09:36 +0000741 See [????] for more details, including examples.
Tim Petersf553f892001-05-01 20:45:31 +0000742
Tim Peters61dff2b2001-05-08 15:43:37 +0000743- Float (and complex) literals in source code were evaluated to full
744 precision only when running from a .py file; the same code loaded from a
745 .pyc (or .pyo) file could suffer numeric differences starting at about the
746 12th significant decimal digit. For example, on a machine with IEEE-754
747 floating arithmetic,
748
749 x = 9007199254740992.0
750 print long(x)
751
752 printed 9007199254740992 if run directly from .py, but 9007199254740000
753 if from a compiled (.pyc or .pyo) file. This was due to marshal using
754 str(float) instead of repr(float) when building code objects. marshal
755 now uses repr(float) instead, which should reproduce floats to full
756 machine precision (assuming the platform C float<->string I/O conversion
757 functions are of good quality).
758
759 This may cause floating-point results to change in some cases, and
760 usually for the better, but may also cause numerically unstable
761 algorithms to break.
762
Tim Peters2f228e72001-05-13 00:19:31 +0000763- The implementation of dicts suffers fewer collisions, which has speed
764 benefits. However, the order in which dict entries appear in dict.keys(),
765 dict.values() and dict.items() may differ from previous releases for a
766 given dict. Nothing is defined about this order, so no program should
767 rely on it. Nevertheless, it's easy to write test cases that rely on the
768 order by accident, typically because of printing the str() or repr() of a
769 dict to an "expected results" file. See Lib/test/test_support.py's new
770 sortdict(dict) function for a simple way to display a dict in sorted
771 order.
772
Tim Peters7a3bfc32001-06-12 01:22:22 +0000773- Many other small changes to dicts were made, resulting in faster
774 operation along the most common code paths.
775
Guido van Rossum10315822001-05-01 20:54:30 +0000776- Dictionary objects now support the "in" operator: "x in dict" means
777 the same as dict.has_key(x).
778
Barry Warsaw51acc8d2001-06-26 20:12:50 +0000779- The update() method of dictionaries now accepts generic mapping
780 objects. Specifically the argument object must support the .keys()
781 and __getitem__() methods. This allows you to say, for example,
782 {}.update(UserDict())
783
Guido van Rossum10315822001-05-01 20:54:30 +0000784- Iterators were added; this is a generalized way of providing values
785 to a for loop. See PEP 234. There's a new built-in function iter()
786 to return an iterator. There's a new protocol to get the next value
787 from an iterator using the next() method (in Python) or the
788 tp_iternext slot (in C). There's a new protocol to get iterators
789 using the __iter__() method (in Python) or the tp_iter slot (in C).
790 Iterating (i.e. a for loop) over a dictionary generates its keys.
791 Iterating over a file generates its lines.
792
Tim Petersf553f892001-05-01 20:45:31 +0000793- The following functions were generalized to work nicely with iterator
794 arguments:
Tim Peterse63415e2001-05-08 04:38:29 +0000795 map(), filter(), reduce(), zip()
Tim Peters8572b4f2001-05-06 01:05:02 +0000796 list(), tuple() (PySequence_Tuple() and PySequence_Fast() in C API)
797 max(), min()
Tim Peters1af03e92001-05-26 19:37:54 +0000798 join() method of strings
799 extend() method of lists
Tim Peters75f8e352001-05-05 11:33:43 +0000800 'x in y' and 'x not in y' (PySequence_Contains() in C API)
801 operator.countOf() (PySequence_Count() in C API)
Tim Petersd6d010b2001-06-21 02:49:55 +0000802 right-hand side of assignment statements with multiple targets, such as
803 x, y, z = some_iterable_object_returning_exactly_3_values
Tim Peters75f8e352001-05-05 11:33:43 +0000804
Tim Petersd85e1022001-05-11 21:51:48 +0000805- Accessing module attributes is significantly faster (for example,
806 random.random or os.path or yourPythonModule.yourAttribute).
807
Tim Peterse63415e2001-05-08 04:38:29 +0000808- Comparing dictionary objects via == and != is faster, and now works even
809 if the keys and values don't support comparisons other than ==.
810
Tim Peters95bf9392001-05-10 08:32:44 +0000811- Comparing dictionaries in ways other than == and != is slower: there were
812 insecurities in the dict comparison implementation that could cause Python
813 to crash if the element comparison routines for the dict keys and/or
814 values mutated the dicts. Making the code bulletproof slowed it down.
815
Tim Peterseb28ef22001-06-02 05:27:19 +0000816- Collisions in dicts are resolved via a new approach, which can help
817 dramatically in bad cases. For example, looking up every key in a dict
Tim Peters7a3bfc32001-06-12 01:22:22 +0000818 d with d.keys() == [i << 16 for i in range(20000)] is approximately 500x
Tim Peterseb28ef22001-06-02 05:27:19 +0000819 faster now. Thanks to Christian Tismer for pointing out the cause and
820 the nature of an effective cure (last December! better late than never).
Tim Peters15d49292001-05-27 07:39:22 +0000821
Tim Peters52e155e2001-06-16 05:42:57 +0000822- repr() is much faster for large containers (dict, list, tuple).
823
824
Tim Petersa814db52001-05-14 07:05:58 +0000825Library
826
Fred Drake960fdf92001-07-20 18:38:26 +0000827- The constants ascii_letters, ascii_lowercase. and ascii_uppercase
828 were added to the string module. These a locale-indenpendent
829 constants, unlike letters, lowercase, and uppercase. These are now
830 use in appropriate locations in the standard library.
831
Martin v. Löwisf0473d52001-07-18 16:17:16 +0000832- The flags used in dlopen calls can now be configured using
833 sys.setdlopenflags and queried using sys.getdlopenflags.
834
Guido van Rossumc7e4aca2001-07-12 11:54:37 +0000835- Fredrik Lundh's xmlrpclib is now a standard library module. This
836 provides full client-side XML-RPC support. In addition,
837 Demo/xmlrpc/ contains two server frameworks (one SocketServer-based,
838 one asyncore-based). Thanks to Eric Raymond for the documentation.
839
Guido van Rossum643d3912001-07-05 14:46:25 +0000840- The xrange() object is simplified: it no longer supports slicing,
841 repetition, comparisons, efficient 'in' checking, the tolist()
842 method, or the start, stop and step attributes. See PEP 260.
843
Martin v. Löwisebf94db2001-06-06 06:25:40 +0000844- A new function fnmatch.filter to filter lists of file names was added.
845
Barry Warsawffd674d2001-05-22 16:00:10 +0000846- calendar.py uses month and day names based on the current locale.
847
Guido van Rossum2e0a6542001-05-15 02:14:44 +0000848- strop is now *really* obsolete (this was announced before with 1.6),
849 and issues DeprecationWarning when used (except for the four items
850 that are still imported into string.py).
851
Tim Petersa814db52001-05-14 07:05:58 +0000852- Cookie.py now sorts key+value pairs by key in output strings.
853
854- pprint.isrecursive(object) didn't correctly identify recursive objects.
855 Now it does.
856
Tim Peters95b3f782001-05-14 18:39:41 +0000857- pprint functions now much faster for large containers (tuple, list, dict).
858
Tim Peters7b9542a2001-06-10 23:40:19 +0000859- New 'q' and 'Q' format codes in the struct module, corresponding to C
860 types "long long" and "unsigned long long" (on Windows, __int64). In
861 native mode, these can be used only when the platform C compiler supports
862 these types (when HAVE_LONG_LONG is #define'd by the Python config
863 process), and then they inherit the sizes and alignments of the C types.
Tim Peters7a3bfc32001-06-12 01:22:22 +0000864 In standard mode, 'q' and 'Q' are supported on all platforms, and are
865 8-byte integral types.
Tim Peters7b9542a2001-06-10 23:40:19 +0000866
Guido van Rossum83213cc2001-06-12 16:48:52 +0000867- The site module installs a new built-in function 'help' that invokes
868 pydoc.help. It must be invoked as 'help()'; when invoked as 'help',
869 it displays a message reminding the user to use 'help()' or
870 'help(object)'.
871
Tim Petersa814db52001-05-14 07:05:58 +0000872Tests
873
874- New test_mutants.py runs dict comparisons where the key and value
875 comparison operators mutute the dicts randomly during comparison. This
876 rapidly causes Python to crash under earlier releases (not for the faint
877 of heart: it can also cause Win9x to freeze or reboot!).
878
879- New test_pprint.py verfies that pprint.isrecursive() and
Tim Peters95b3f782001-05-14 18:39:41 +0000880 pprint.isreadable() return sensible results. Also verifies that simple
881 cases produce correct output.
Tim Petersa814db52001-05-14 07:05:58 +0000882
Tim Peters4324aa32001-05-28 22:30:08 +0000883C API
884
885- Removed the unused last_is_sticky argument from the internal
886 _PyTuple_Resize(). If this affects you, you were cheating.
887
888
Guido van Rossum55a78992001-07-17 17:22:32 +0000889======================================================================
890
891
Guido van Rossumffe13be2001-04-16 18:46:45 +0000892What's New in Python 2.1 (final)?
893=================================
894
895We only changed a few things since the last release candidate, all in
896Python library code:
897
898- A bug in the locale module was fixed that affected locales which
899 define no grouping for numeric formatting.
900
901- A few bugs in the weakref module's implementations of weak
902 dictionaries (WeakValueDictionary and WeakKeyDictionary) were fixed,
903 and the test suite was updated to check for these bugs.
904
905- An old bug in the os.path.walk() function (introduced in Python
906 2.0!) was fixed: a non-existent file would cause an exception
907 instead of being ignored.
908
909- Fixed a few bugs in the new symtable module found by Neil Norwitz's
910 PyChecker.
911
912
Guido van Rossum5b08f132001-04-16 02:05:23 +0000913What's New in Python 2.1c2?
914===========================
Barry Warsaw11e89c72001-04-11 20:37:57 +0000915
Guido van Rossum5b08f132001-04-16 02:05:23 +0000916A flurry of small changes, and one showstopper fixed in the nick of
917time made it necessary to release another release candidate. The list
918here is the *complete* list of patches (except version updates):
Guido van Rossum4fb60362001-04-13 00:46:14 +0000919
Guido van Rossum5b08f132001-04-16 02:05:23 +0000920Core
Guido van Rossum4fb60362001-04-13 00:46:14 +0000921
Guido van Rossum5b08f132001-04-16 02:05:23 +0000922- Tim discovered a nasty bug in the dictionary code, caused by
923 PyDict_Next() calling dict_resize(), and the GC code's use of
924 PyDict_Next() violating an assumption in dict_items(). This was
925 fixed with considerable amounts of band-aid, but the net effect is a
926 saner and more robust implementation.
927
928- Made a bunch of symbols static that were accidentally global.
929
930Build and Ports
931
932- The setup.py script didn't check for a new enough version of zlib
933 (1.1.3 is needed). Now it does.
934
935- Changed "make clean" target to also remove shared libraries.
936
937- Added a more general warning about the SGI Irix optimizer to README.
938
939Library
940
941- Fix a bug in urllib.basejoin("http://host", "../file.html") which
942 omitted the slash between host and file.html.
943
944- The mailbox module's _Mailbox class contained a completely broken
945 and undocumented seek() method. Ripped it out.
946
947- Fixed a bunch of typos in various library modules (urllib2, smtpd,
948 sgmllib, netrc, chunk) found by Neil Norwitz's PyChecker.
949
950- Fixed a few last-minute bugs in unittest.
951
952Extensions
953
954- Reverted the patch to the OpenSSL code in socketmodule.c to support
955 RAND_status() and the EGD, and the subsequent patch that tried to
956 fix it for pre-0.9.5 versions; the problem with the patch is that on
957 some systems it issues a warning whenever socket is imported, and
958 that's unacceptable.
959
960Tests
961
962- Fixed the pickle tests to work with "import test.test_pickle".
963
964- Tweaked test_locale.py to actually run the test Windows.
965
966- In distutils/archive_util.py, call zipfile.ZipFile() with mode "w",
967 not "wb" (which is not a valid mode at all).
968
969- Fix pstats browser crashes. Import readline if it exists to make
970 the user interface nicer.
971
972- Add "import thread" to the top of test modules that import the
973 threading module (test_asynchat and test_threadedtempfile). This
974 prevents test failures caused by a broken threading module resulting
975 from a previously caught failed import.
976
977- Changed test_asynchat.py to set the SO_REUSEADDR option; this was
978 needed on some platforms (e.g. Solaris 8) when the tests are run
979 twice in succession.
980
981- Skip rather than fail test_sunaudiodev if no audio device is found.
982
983
984What's New in Python 2.1c1?
985===========================
986
987This list was significantly updated when 2.1c2 was released; the 2.1c1
988release didn't mention most changes that were actually part of 2.1c1:
989
990Legal
991
992- Copyright was assigned to the Python Software Foundation (PSF) and a
993 PSF license (very similar to the CNRI license) was added.
994
995- The CNRI copyright notice was updated to include 2001.
996
997Core
Barry Warsaw11e89c72001-04-11 20:37:57 +0000998
Guido van Rossumc9932722001-04-12 02:31:27 +0000999- After a public outcry, assignment to __debug__ is no longer illegal;
1000 instead, a warning is issued. It will become illegal in 2.2.
1001
Guido van Rossum5b08f132001-04-16 02:05:23 +00001002- Fixed a core dump with "%#x" % 0, and changed the semantics so that
1003 "%#x" now always prepends "0x", even if the value is zero.
1004
1005- Fixed some nits in the bytecode compiler.
1006
1007- Fixed core dumps when calling certain kinds of non-functions.
1008
1009- Fixed various core dumps caused by reference count bugs.
1010
1011Build and Ports
1012
1013- Use INSTALL_SCRIPT to install script files.
1014
Guido van Rossum34d37dc2001-04-11 21:03:32 +00001015- New port: SCO Unixware 7, by Billy G. Allie.
1016
Guido van Rossum5b08f132001-04-16 02:05:23 +00001017- Updated RISCOS port.
1018
1019- Updated BeOS port and notes.
1020
1021- Various other porting problems resolved.
1022
1023Library
1024
1025- The TERMIOS and SOCKET modules are now truly obsolete and
1026 unnecessary. Their symbols are incorporated in the termios and
1027 socket modules.
1028
1029- Fixed some 64-bit bugs in pickle, cPickle, and struct, and added
1030 better tests for pickling.
1031
1032- threading: make Condition.wait() robust against KeyboardInterrupt.
1033
1034- zipfile: add support to zipfile to support opening an archive
1035 represented by an open file rather than a file name. Fix bug where
1036 the archive was not properly closed. Fixed a bug in this bugfix
1037 where flush() was called for a read-only file.
1038
1039- imputil: added an uninstall() method to the ImportManager.
1040
1041- Canvas: fixed bugs in lower() and tkraise() methods.
1042
1043- SocketServer: API change (added overridable close_request() method)
1044 so that the TCP server can explicitly close the request.
1045
1046- pstats: Eric Raymond added a simple interactive statistics browser,
1047 invoked when the module is run as a script.
1048
1049- locale: fixed a problem in format().
1050
1051- webbrowser: made it work when the BROWSER environment variable has a
1052 value like "/usr/bin/netscape". Made it auto-detect Konqueror for
1053 KDE 2. Fixed some other nits.
1054
1055- unittest: changes to allow using a different exception than
1056 AssertionError, and added a few more function aliases. Some other
1057 small changes.
1058
1059- urllib, urllib2: fixed redirect problems and a coupleof other nits.
1060
1061- asynchat: fixed a critical bug in asynchat that slipped through the
1062 2.1b2 release. Fixed another rare bug.
1063
1064- Fix some unqualified except: clauses (always a bad code example).
1065
1066XML
1067
1068- pyexpat: new API get_version_string().
1069
1070- Fixed some minidom bugs.
1071
1072Extensions
1073
1074- Fixed a core dump in _weakref. Removed the weakref.mapping()
1075 function (it adds nothing to the API).
1076
1077- Rationalized the use of header files in the readline module, to make
1078 it compile (albeit with some warnings) with the very recent readline
1079 4.2, without breaking for earlier versions.
1080
1081- Hopefully fixed a buffering problem in linuxaudiodev.
1082
1083- Attempted a fix to make the OpenSSL support in the socket module
1084 work again with pre-0.9.5 versions of OpenSSL.
1085
1086Tests
1087
1088- Added a test case for asynchat and asyncore.
1089
1090- Removed coupling between tests where one test failing could break
1091 another.
1092
1093Tools
1094
1095- Ping added an interactive help browser to pydoc, fixed some nits
1096 in the rest of the pydoc code, and added some features to his
1097 inspect module.
1098
1099- An updated python-mode.el version 4.1 which integrates Ken
1100 Manheimer's pdbtrack.el. This makes debugging Python code via pdb
1101 much nicer in XEmacs and Emacs. When stepping through your program
1102 with pdb, in either the shell window or the *Python* window, the
1103 source file and line will be tracked by an arrow. Very cool!
1104
1105- IDLE: syntax warnings in interactive mode are changed into errors.
1106
1107- Some improvements to Tools/webchecker (ignore some more URL types,
Tim Peters0e57abf2001-05-02 07:39:38 +00001108 follow some more links).
Guido van Rossum5b08f132001-04-16 02:05:23 +00001109
1110- Brought the Tools/compiler package up to date.
Guido van Rossum34d37dc2001-04-11 21:03:32 +00001111
Barry Warsaw11e89c72001-04-11 20:37:57 +00001112
Martin v. Löwis0411f6f2001-03-21 08:01:39 +00001113What's New in Python 2.1 beta 2?
1114================================
1115
Guido van Rossum053ae352001-03-22 14:17:21 +00001116(Unlisted are many fixed bugs, more documentation, etc.)
1117
Martin v. Löwis0411f6f2001-03-21 08:01:39 +00001118Core language, builtins, and interpreter
1119
Guido van Rossum053ae352001-03-22 14:17:21 +00001120- The nested scopes work (enabled by "from __future__ import
1121 nested_scopes") is completed; in particular, the future now extends
1122 into code executed through exec, eval() and execfile(), and into the
1123 interactive interpreter.
1124
1125- When calling a base class method (e.g. BaseClass.__init__(self)),
1126 this is now allowed even if self is not strictly spoken a class
1127 instance (e.g. when using metaclasses or the Don Beaudry hook).
1128
1129- Slice objects are now comparable but not hashable; this prevents
1130 dict[:] from being accepted but meaningless.
1131
1132- Complex division is now calculated using less braindead algorithms.
1133 This doesn't change semantics except it's more likely to give useful
1134 results in extreme cases. Complex repr() now uses full precision
1135 like float repr().
1136
1137- sgmllib.py now calls handle_decl() for simple <!...> declarations.
1138
Jeremy Hyltonf626db72001-03-23 14:18:27 +00001139- It is illegal to assign to the name __debug__, which is set when the
1140 interpreter starts. It is effectively a compile-time constant.
1141
1142- A warning will be issued if a global statement for a variable
1143 follows a use or assignment of that variable.
1144
Martin v. Löwis0411f6f2001-03-21 08:01:39 +00001145Standard library
1146
Guido van Rossum053ae352001-03-22 14:17:21 +00001147- unittest.py, a unit testing framework by Steve Purcell (PyUNIT,
1148 inspired by JUnit), is now part of the standard library. You now
1149 have a choice of two testing frameworks: unittest requires you to
1150 write testcases as separate code, doctest gathers them from
1151 docstrings. Both approaches have their advantages and
1152 disadvantages.
1153
1154- A new module Tix was added, which wraps the Tix extension library
1155 for Tk. With that module, it is not necessary to statically link
1156 Tix with _tkinter, since Tix will be loaded with Tcl's "package
1157 require" command. See Demo/tix/.
1158
1159- tzparse.py is now obsolete.
1160
1161- In gzip.py, the seek() and tell() methods are removed -- they were
1162 non-functional anyway, and it's better if callers can test for their
1163 existence with hasattr().
1164
1165Python/C API
1166
1167- PyDict_Next(): it is now safe to call PyDict_SetItem() with a key
1168 that's already in the dictionary during a PyDict_Next() iteration.
1169 This used to fail occasionally when a dictionary resize operation
1170 could be triggered that would rehash all the keys. All other
1171 modifications to the dictionary are still off-limits during a
1172 PyDict_Next() iteration!
1173
1174- New extended APIs related to passing compiler variables around.
1175
1176- New abstract APIs PyObject_IsInstance(), PyObject_IsSubclass()
1177 implement isinstance() and issubclass().
1178
1179- Py_BuildValue() now has a "D" conversion to create a Python complex
1180 number from a Py_complex C value.
Martin v. Löwis0411f6f2001-03-21 08:01:39 +00001181
Fred Drake4e262a92001-03-22 18:26:47 +00001182- Extensions types which support weak references must now set the
1183 field allocated for the weak reference machinery to NULL themselves;
1184 this is done to avoid the cost of checking each object for having a
1185 weakly referencable type in PyObject_INIT(), since most types are
1186 not weakly referencable.
1187
Jeremy Hyltonf626db72001-03-23 14:18:27 +00001188- PyFrame_FastToLocals() and PyFrame_LocalsToFast() copy bindings for
1189 free variables and cell variables to and from the frame's f_locals.
1190
1191- Variants of several functions defined in pythonrun.h have been added
1192 to support the nested_scopes future statement. The variants all end
1193 in Flags and take an extra argument, a PyCompilerFlags *; examples:
1194 PyRun_AnyFileExFlags(), PyRun_InteractiveLoopFlags(). These
1195 variants may be removed in Python 2.2, when nested scopes are
Tim Peters0e57abf2001-05-02 07:39:38 +00001196 mandatory.
Jeremy Hyltonf626db72001-03-23 14:18:27 +00001197
Andrew M. Kuchling8e9972c2001-03-22 15:42:08 +00001198Distutils
1199
1200- the sdist command now writes a PKG-INFO file, as described in PEP 241,
1201 into the release tree.
1202
Tim Peters0e57abf2001-05-02 07:39:38 +00001203- several enhancements to the bdist_wininst command from Thomas Heller
Andrew M. Kuchling8e9972c2001-03-22 15:42:08 +00001204 (an uninstaller, more customization of the installer's display)
1205
1206- from Jack Jansen: added Mac-specific code to generate a dialog for
1207 users to specify the command-line (because providing a command-line with
Tim Peters0e57abf2001-05-02 07:39:38 +00001208 MacPython is awkward). Jack also made various fixes for the Mac
Andrew M. Kuchling8e9972c2001-03-22 15:42:08 +00001209 and the Metrowerks compiler.
Tim Peters0e57abf2001-05-02 07:39:38 +00001210
1211- added 'platforms' and 'keywords' to the set of metadata that can be
1212 specified for a distribution.
Andrew M. Kuchling8e9972c2001-03-22 15:42:08 +00001213
1214- applied patches from Jason Tishler to make the compiler class work with
1215 Cygwin.
1216
1217
Tim Peters2fe289a2001-03-01 22:19:38 +00001218What's New in Python 2.1 beta 1?
1219================================
Tim Petersd66595f2001-02-04 03:09:53 +00001220
1221Core language, builtins, and interpreter
1222
Guido van Rossum9d0fbde2001-03-02 14:00:32 +00001223- Following an outcry from the community about the amount of code
1224 broken by the nested scopes feature introduced in 2.1a2, we decided
1225 to make this feature optional, and to wait until Python 2.2 (or at
1226 least 6 months) to make it standard. The option can be enabled on a
1227 per-module basis by adding "from __future__ import nested_scopes" at
1228 the beginning of a module (before any other statements, but after
1229 comments and an optional docstring). See PEP 236 (Back to the
1230 __future__) for a description of the __future__ statement. PEP 227
1231 (Statically Nested Scopes) has been updated to reflect this change,
1232 and to clarify the semantics in a number of endcases.
1233
1234- The nested scopes code, when enabled, has been hardened, and most
1235 bugs and memory leaks in it have been fixed.
1236
1237- Compile-time warnings are now generated for a number of conditions
1238 that will break or change in meaning when nested scopes are enabled:
1239
1240 - Using "from...import *" or "exec" without in-clause in a function
1241 scope that also defines a lambda or nested function with one or
1242 more free (non-local) variables. The presence of the import* or
1243 bare exec makes it impossible for the compiler to determine the
1244 exact set of local variables in the outer scope, which makes it
1245 impossible to determine the bindings for free variables in the
1246 inner scope. To avoid the warning about import *, change it into
1247 an import of explicitly name object, or move the import* statement
1248 to the global scope; to avoid the warning about bare exec, use
1249 exec...in... (a good idea anyway -- there's a possibility that
1250 bare exec will be deprecated in the future).
1251
1252 - Use of a global variable in a nested scope with the same name as a
1253 local variable in a surrounding scope. This will change in
1254 meaning with nested scopes: the name in the inner scope will
1255 reference the variable in the outer scope rather than the global
1256 of the same name. To avoid the warning, either rename the outer
1257 variable, or use a global statement in the inner function.
1258
Neil Schemenauera35c6882001-02-27 04:45:05 +00001259- An optional object allocator has been included. This allocator is
1260 optimized for Python objects and should be faster and use less memory
1261 than the standard system allocator. It is not enabled by default
1262 because of possible thread safety problems. The allocator is only
1263 protected by the Python interpreter lock and it is possible that some
1264 extension modules require a thread safe allocator. The object
1265 allocator can be enabled by providing the "--with-pymalloc" option to
1266 configure.
1267
Tim Petersd66595f2001-02-04 03:09:53 +00001268Standard library
1269
Martin v. Löwis2a5130e2001-02-27 04:21:58 +00001270- pyexpat now detects the expat version if expat.h defines it. A
1271 number of additional handlers are provided, which are only available
1272 since expat 1.95. In addition, the methods SetParamEntityParsing and
1273 GetInputContext of Parser objects are available with 1.95.x
1274 only. Parser objects now provide the ordered_attributes and
1275 specified_attributes attributes. A new module expat.model was added,
1276 which offers a number of additional constants if 1.95.x is used.
1277
1278- xml.dom offers the new functions registerDOMImplementation and
1279 getDOMImplementation.
1280
1281- xml.dom.minidom offers a toprettyxml method. A number of DOM
1282 conformance issues have been resolved. In particular, Element now
1283 has an hasAttributes method, and the handling of namespaces was
1284 improved.
1285
Andrew M. Kuchlingd6a1d792001-02-28 21:05:42 +00001286- Ka-Ping Yee contributed two new modules: inspect.py, a module for
1287 getting information about live Python code, and pydoc.py, a module
1288 for interactively converting docstrings to HTML or text.
1289 Tools/scripts/pydoc, which is now automatically installed into
Tim Peters1eff7962001-03-01 02:31:33 +00001290 <prefix>/bin, uses pydoc.py to display documentation; try running
Guido van Rossume3955a82001-03-02 14:05:59 +00001291 "pydoc -h" for instructions. "pydoc -g" pops up a small GUI that
1292 lets you browse the module docstrings using a web browser.
Andrew M. Kuchlingd6a1d792001-02-28 21:05:42 +00001293
Tim Peters1eff7962001-03-01 02:31:33 +00001294- New library module difflib.py, primarily packaging the SequenceMatcher
1295 class at the heart of the popular ndiff.py file-comparison tool.
1296
1297- doctest.py (a framework for verifying Python code examples in docstrings)
1298 is now part of the std library.
1299
Tim Petersd66595f2001-02-04 03:09:53 +00001300Windows changes
1301
Guido van Rossume3955a82001-03-02 14:05:59 +00001302- A new entry in the Start menu, "Module Docs", runs "pydoc -g" -- a
1303 small GUI that lets you browse the module docstrings using your
1304 default web browser.
1305
Tim Peters1eff7962001-03-01 02:31:33 +00001306- Import is now case-sensitive. PEP 235 (Import on Case-Insensitive
1307 Platforms) is implemented. See
1308
1309 http://python.sourceforge.net/peps/pep-0235.html
1310
1311 for full details, especially the "Current Lower-Left Semantics" section.
1312 The new Windows import rules are simpler than before:
1313
1314 A. If the PYTHONCASEOK environment variable exists, same as
1315 before: silently accept the first case-insensitive match of any
1316 kind; raise ImportError if none found.
1317
1318 B. Else search sys.path for the first case-sensitive match; raise
1319 ImportError if none found.
1320
1321 The same rules have been implented on other platforms with case-
1322 insensitive but case-preserving filesystems too (including Cygwin, and
1323 several flavors of Macintosh operating systems).
Tim Petersd66595f2001-02-04 03:09:53 +00001324
Tim Peters25a9ce32001-02-19 07:06:36 +00001325- winsound module: Under Win9x, winsound.Beep() now attempts to simulate
1326 what it's supposed to do (and does do under NT and 2000) via direct
1327 port manipulation. It's unknown whether this will work on all systems,
Tim Peters1eff7962001-03-01 02:31:33 +00001328 but it does work on my Win98SE systems now and was known to be useless on
Tim Peters25a9ce32001-02-19 07:06:36 +00001329 all Win9x systems before.
1330
Tim Peters1eff7962001-03-01 02:31:33 +00001331- Build: Subproject _test (effectively) renamed to _testcapi.
1332
Tim Peters2fe289a2001-03-01 22:19:38 +00001333New platforms
1334
1335- 2.1 should compile and run out of the box under MacOS X, even using HFS+.
1336 Thanks to Steven Majewski!
1337
1338- 2.1 should compile and run out of the box on Cygwin. Thanks to Jason
1339 Tishler!
1340
Guido van Rossum9089b272001-03-02 06:49:50 +00001341- 2.1 contains new files and patches for RISCOS, thanks to Dietmar
1342 Schwertberger! See RISCOS/README for more information -- it seems
1343 that because of the bizarre filename conventions on RISCOS, no port
1344 to that platform is easy. Note that the new variable os.endsep is
1345 silently supported in order to make life easier on this platform,
1346 but we don't advertise it because it's not worth for most folks to
1347 care about RISCOS portability.
1348
Tim Peters25a9ce32001-02-19 07:06:36 +00001349
Tim Petersd7b5e882001-01-25 03:36:26 +00001350What's New in Python 2.1 alpha 2?
1351=================================
Tim Peters40ead762001-01-27 05:35:26 +00001352
Tim Petersd7b5e882001-01-25 03:36:26 +00001353Core language, builtins, and interpreter
1354
Jeremy Hylton4589bd82001-02-01 20:38:45 +00001355- Scopes nest. If a name is used in a function or class, but is not
1356 local, the definition in the nearest enclosing function scope will
1357 be used. One consequence of this change is that lambda statements
1358 could reference variables in the namespaces where the lambda is
1359 defined. In some unusual cases, this change will break code.
1360
1361 In all previous version of Python, names were resolved in exactly
1362 three namespaces -- the local namespace, the global namespace, and
Jeremy Hyltond6b1cf92001-02-02 20:06:28 +00001363 the builtin namespace. According to this old definition, if a
Jeremy Hylton4589bd82001-02-01 20:38:45 +00001364 function A is defined within a function B, the names bound in B are
1365 not visible in A. The new rules make names bound in B visible in A,
1366 unless A contains a name binding that hides the binding in B.
1367
1368 Section 4.1 of the reference manual describes the new scoping rules
1369 in detail. The test script in Lib/test/test_scope.py demonstrates
1370 some of the effects of the change.
1371
1372 The new rules will cause existing code to break if it defines nested
1373 functions where an outer function has local variables with the same
1374 name as globals or builtins used by the inner function. Example:
1375
1376 def munge(str):
1377 def helper(x):
1378 return str(x)
1379 if type(str) != type(''):
1380 str = helper(str)
1381 return str.strip()
1382
1383 Under the old rules, the name str in helper() is bound to the
1384 builtin function str(). Under the new rules, it will be bound to
1385 the argument named str and an error will occur when helper() is
1386 called.
1387
Jeremy Hyltond6b1cf92001-02-02 20:06:28 +00001388- The compiler will report a SyntaxError if "from ... import *" occurs
1389 in a function or class scope. The language reference has documented
1390 that this case is illegal, but the compiler never checked for it.
1391 The recent introduction of nested scope makes the meaning of this
1392 form of name binding ambiguous. In a future release, the compiler
1393 may allow this form when there is no possibility of ambiguity.
1394
Tim Peters40ead762001-01-27 05:35:26 +00001395- repr(string) is easier to read, now using hex escapes instead of octal,
1396 and using \t, \n and \r instead of \011, \012 and \015 (respectively):
1397
1398 >>> "\texample \r\n" + chr(0) + chr(255)
1399 '\texample \r\n\x00\xff' # in 2.1
1400 '\011example \015\012\000\377' # in 2.0
1401
Moshe Zadka6af0ce02001-01-29 06:41:00 +00001402- Functions are now compared and hashed by identity, not by value, since
1403 the func_code attribute is writable.
1404
Fred Drakefb9d7122001-02-01 20:00:40 +00001405- Weak references (PEP 205) have been added. This involves a few
1406 changes in the core, an extension module (_weakref), and a Python
1407 module (weakref). The weakref module is the public interface. It
1408 includes support for "explicit" weak references, proxy objects, and
1409 mappings with weakly held values.
1410
Jeremy Hylton0072d5a2001-02-01 22:53:15 +00001411- A 'continue' statement can now appear in a try block within the body
1412 of a loop. It is still not possible to use continue in a finally
Tim Peters9ea17ac2001-02-02 05:57:15 +00001413 clause.
Jeremy Hylton0072d5a2001-02-01 22:53:15 +00001414
Tim Petersd7b5e882001-01-25 03:36:26 +00001415Standard library
1416
Barry Warsaw30dbd142001-01-31 22:14:01 +00001417- mailbox.py now has a new class, PortableUnixMailbox which is
1418 identical to UnixMailbox but uses a more portable scheme for
1419 determining From_ separators. Also, the constructors for all the
1420 classes in this module have a new optional `factory' argument, which
1421 is a callable used when new message classes must be instantiated by
1422 the next() method.
1423
Tim Petersd7b5e882001-01-25 03:36:26 +00001424- random.py is now self-contained, and offers all the functionality of
1425 the now-deprecated whrandom.py. See the docs for details. random.py
1426 also supports new functions getstate() and setstate(), for saving
Tim Petersd52269b2001-01-25 06:23:18 +00001427 and restoring the internal state of the generator; and jumpahead(n),
1428 for quickly forcing the internal state to be the same as if n calls to
1429 random() had been made. The latter is particularly useful for multi-
1430 threaded programs, creating one instance of the random.Random() class for
1431 each thread, then using .jumpahead() to force each instance to use a
1432 non-overlapping segment of the full period.
Tim Petersd7b5e882001-01-25 03:36:26 +00001433
Tim Peters0de88fc2001-02-01 04:59:18 +00001434- random.py's seed() function is new. For bit-for-bit compatibility with
1435 prior releases, use the whseed function instead. The new seed function
1436 addresses two problems: (1) The old function couldn't produce more than
1437 about 2**24 distinct internal states; the new one about 2**45 (the best
1438 that can be done in the Wichmann-Hill generator). (2) The old function
1439 sometimes produced identical internal states when passed distinct
1440 integers, and there was no simple way to predict when that would happen;
1441 the new one guarantees to produce distinct internal states for all
1442 arguments in [0, 27814431486576L).
1443
Jeremy Hylton4c4fda02001-02-02 03:29:24 +00001444- The socket module now supports raw packets on Linux. The socket
1445 family is AF_PACKET.
1446
Tim Peters9ea17ac2001-02-02 05:57:15 +00001447- test_capi.py is a start at running tests of the Python C API. The tests
1448 are implemented by the new Modules/_testmodule.c.
1449
Jeremy Hyltond6b1cf92001-02-02 20:06:28 +00001450- A new extension module, _symtable, provides provisional access to the
1451 internal symbol table used by the Python compiler. A higher-level
1452 interface will be added on top of _symtable in a future release.
1453
Andrew M. Kuchlingdebc3522001-02-22 15:53:21 +00001454- Removed the obsolete soundex module.
1455
Martin v. Löwis2a5130e2001-02-27 04:21:58 +00001456- xml.dom.minidom now uses the standard DOM exceptions. Node supports
1457 the isSameNode method; NamedNodeMap the get method.
1458
1459- xml.sax.expatreader supports the lexical handler property; it
1460 generates comment, startCDATA, and endCDATA events.
1461
Tim Petersee826f82001-01-31 19:39:44 +00001462Windows changes
1463
1464- Build procedure: the zlib project is built in a different way that
1465 ensures the zlib header files used can no longer get out of synch with
Tim Peters9ea17ac2001-02-02 05:57:15 +00001466 the zlib binary used. See PCbuild\readme.txt for details. Your old
1467 zlib-related directories can be deleted; you'll need to download fresh
1468 source for zlib and unpack it into a new directory.
Tim Petersee826f82001-01-31 19:39:44 +00001469
Tim Peters9ea17ac2001-02-02 05:57:15 +00001470- Build: New subproject _test for the benefit of test_capi.py (see above).
1471
Tim Petersb16c56f2001-02-02 21:24:51 +00001472- Build: New subproject _symtable, for new DLL _symtable.pyd (a nascent
1473 interface to some Python compiler internals).
1474
1475- Build: Subproject ucnhash is gone, since the code was folded into the
Tim Peters9ea17ac2001-02-02 05:57:15 +00001476 unicodedata subproject.
Tim Petersd7b5e882001-01-25 03:36:26 +00001477
Tim Petersa3a3a032000-11-30 05:22:44 +00001478What's New in Python 2.1 alpha 1?
1479=================================
1480
1481Core language, builtins, and interpreter
1482
Marc-André Lemburgebb195b2001-01-20 10:34:52 +00001483- There is a new Unicode companion to the PyObject_Str() API
1484 called PyObject_Unicode(). It behaves in the same way as the
1485 former, but assures that the returned value is an Unicode object
1486 (applying the usual coercion if necessary).
Marc-André Lemburgad7c98e2001-01-17 17:09:53 +00001487
Guido van Rossumf98eda02001-01-17 15:54:45 +00001488- The comparison operators support "rich comparison overloading" (PEP
1489 207). C extension types can provide a rich comparison function in
1490 the new tp_richcompare slot in the type object. The cmp() function
1491 and the C function PyObject_Compare() first try the new rich
1492 comparison operators before trying the old 3-way comparison. There
1493 is also a new C API PyObject_RichCompare() (which also falls back on
1494 the old 3-way comparison, but does not constrain the outcome of the
1495 rich comparison to a Boolean result).
1496
1497 The rich comparison function takes two objects (at least one of
1498 which is guaranteed to have the type that provided the function) and
1499 an integer indicating the opcode, which can be Py_LT, Py_LE, Py_EQ,
1500 Py_NE, Py_GT, Py_GE (for <, <=, ==, !=, >, >=), and returns a Python
1501 object, which may be NotImplemented (in which case the tp_compare
1502 slot function is used as a fallback, if defined).
1503
1504 Classes can overload individual comparison operators by defining one
1505 or more of the methods__lt__, __le__, __eq__, __ne__, __gt__,
Guido van Rossuma88479f2001-01-18 14:28:08 +00001506 __ge__. There are no explicit "reflected argument" versions of
1507 these; instead, __lt__ and __gt__ are each other's reflection,
1508 likewise for__le__ and __ge__; __eq__ and __ne__ are their own
1509 reflection (similar at the C level). No other implications are
1510 made; in particular, Python does not assume that == is the Boolean
1511 inverse of !=, or that < is the Boolean inverse of >=. This makes
1512 it possible to define types with partial orderings.
Guido van Rossumf98eda02001-01-17 15:54:45 +00001513
1514 Classes or types that want to implement (in)equality tests but not
1515 the ordering operators (i.e. unordered types) should implement ==
1516 and !=, and raise an error for the ordering operators.
1517
Guido van Rossuma88479f2001-01-18 14:28:08 +00001518 It is possible to define types whose rich comparison results are not
Guido van Rossumf98eda02001-01-17 15:54:45 +00001519 Boolean; e.g. a matrix type might want to return a matrix of bits
1520 for A < B, giving elementwise comparisons. Such types should ensure
1521 that any interpretation of their value in a Boolean context raises
1522 an exception, e.g. by defining __nonzero__ (or the tp_nonzero slot
1523 at the C level) to always raise an exception.
1524
Guido van Rossuma88479f2001-01-18 14:28:08 +00001525- Complex numbers use rich comparisons to define == and != but raise
1526 an exception for <, <=, > and >=. Unfortunately, this also means
1527 that cmp() of two complex numbers raises an exception when the two
1528 numbers differ. Since it is not mathematically meaningful to compare
1529 complex numbers except for equality, I hope that this doesn't break
1530 too much code.
1531
Tim Peters3389f192001-02-18 08:48:49 +00001532- The outcome of comparing non-numeric objects of different types is
Tim Peters14495852001-02-18 08:28:33 +00001533 not defined by the language, other than that it's arbitrary but
1534 consistent (see the Reference Manual). An implementation detail changed
1535 in 2.1a1 such that None now compares less than any other object. Code
1536 relying on this new behavior (like code that relied on the previous
1537 behavior) does so at its own risk.
1538
Barry Warsaw573b5412001-01-15 20:43:18 +00001539- Functions and methods now support getting and setting arbitrarily
1540 named attributes (PEP 232). Functions have a new __dict__
1541 (a.k.a. func_dict) which hold the function attributes. Methods get
1542 and set attributes on their underlying im_func. It is a TypeError
1543 to set an attribute on a bound method.
1544
Guido van Rossum051e3352001-01-15 19:11:10 +00001545- The xrange() object implementation has been improved so that
1546 xrange(sys.maxint) can be used on 64-bit platforms. There's still a
1547 limitation that in this case len(xrange(sys.maxint)) can't be
1548 calculated, but the common idiom "for i in xrange(sys.maxint)" will
1549 work fine as long as the index i doesn't actually reach 2**31.
1550 (Python uses regular ints for sequence and string indices; fixing
1551 that is much more work.)
1552
Guido van Rossum1cc8f832001-01-12 16:25:08 +00001553- Two changes to from...import:
1554
Guido van Rossumba381232001-02-03 15:06:40 +00001555 1) "from M import X" now works even if (after loading module M)
1556 sys.modules['M'] is not a real module; it's basically a getattr()
1557 operation with AttributeError exceptions changed into ImportError.
Guido van Rossum1cc8f832001-01-12 16:25:08 +00001558
1559 2) "from M import *" now looks for M.__all__ to decide which names to
1560 import; if M.__all__ doesn't exist, it uses M.__dict__.keys() but
1561 filters out names starting with '_' as before. Whether or not
1562 __all__ exists, there's no restriction on the type of M.
1563
Guido van Rossumf61f1662001-01-10 20:13:55 +00001564- File objects have a new method, xreadlines(). This is the fastest
1565 way to iterate over all lines in a file:
1566
1567 for line in file.xreadlines():
1568 ...do something to line...
1569
1570 See the xreadlines module (mentioned below) for how to do this for
1571 other file-like objects.
1572
1573- Even if you don't use file.xreadlines(), you may expect a speedup on
1574 line-by-line input. The file.readline() method has been optimized
Tim Petersf29b64d2001-01-15 06:33:19 +00001575 quite a bit in platform-specific ways: on systems (like Linux) that
1576 support flockfile(), getc_unlocked(), and funlockfile(), those are
1577 used by default. On systems (like Windows) without getc_unlocked(),
1578 a complicated (but still thread-safe) method using fgets() is used by
1579 default.
1580
Tim Petersd52269b2001-01-25 06:23:18 +00001581 You can force use of the fgets() method by #define'ing
1582 USE_FGETS_IN_GETLINE at build time (it may be faster than
Tim Petersf29b64d2001-01-15 06:33:19 +00001583 getc_unlocked()).
1584
Tim Petersd52269b2001-01-25 06:23:18 +00001585 You can force fgets() not to be used by #define'ing
1586 DONT_USE_FGETS_IN_GETLINE (this is the first thing to try if std test
Tim Petersf29b64d2001-01-15 06:33:19 +00001587 test_bufio.py fails -- and let us know if it does!).
1588
1589- In addition, the fileinput module, while still slower than the other
1590 methods on most platforms, has been sped up too, by using
1591 file.readlines(sizehint).
Guido van Rossumf61f1662001-01-10 20:13:55 +00001592
1593- Support for run-time warnings has been added, including a new
1594 command line option (-W) to specify the disposition of warnings.
1595 See the description of the warnings module below.
1596
1597- Extensive changes have been made to the coercion code. This mostly
1598 affects extension modules (which can now implement mixed-type
1599 numerical operators without having to use coercion), but
1600 occasionally, in boundary cases the coercion semantics have changed
1601 subtly. Since this was a terrible gray area of the language, this
Guido van Rossumae72d872001-01-11 15:00:14 +00001602 is considered an improvement. Also note that __rcmp__ is no longer
Guido van Rossumf61f1662001-01-10 20:13:55 +00001603 supported -- instead of calling __rcmp__, __cmp__ is called with
Guido van Rossuma88479f2001-01-18 14:28:08 +00001604 reflected arguments.
Guido van Rossumf61f1662001-01-10 20:13:55 +00001605
Guido van Rossumf98eda02001-01-17 15:54:45 +00001606- In connection with the coercion changes, a new built-in singleton
1607 object, NotImplemented is defined. This can be returned for
1608 operations that wish to indicate they are not implemented for a
1609 particular combination of arguments. From C, this is
1610 Py_NotImplemented.
1611
Martin v. Löwisbe4c0f52001-01-04 20:30:56 +00001612- The interpreter accepts now bytecode files on the command line even
1613 if they do not have a .pyc or .pyo extension. On Linux, after executing
1614
Martin v. Löwise214baa2001-02-04 22:37:56 +00001615import imp,sys,string
1616magic = string.join(["\\x%.2x" % ord(c) for c in imp.get_magic()],"")
1617reg = ':pyc:M::%s::%s:' % (magic, sys.executable)
1618open("/proc/sys/fs/binfmt_misc/register","wb").write(reg)
Martin v. Löwisbe4c0f52001-01-04 20:30:56 +00001619
1620 any byte code file can be used as an executable (i.e. as an argument
1621 to execve(2)).
1622
Tim Peters9940b802000-12-01 07:59:35 +00001623- %[xXo] formats of negative Python longs now produce a sign
Tim Petersa3a3a032000-11-30 05:22:44 +00001624 character. In 1.6 and earlier, they never produced a sign,
1625 and raised an error if the value of the long was too large
1626 to fit in a Python int. In 2.0, they produced a sign if and
1627 only if too large to fit in an int. This was inconsistent
1628 across platforms (because the size of an int varies across
1629 platforms), and inconsistent with hex() and oct(). Example:
1630
1631 >>> "%x" % -0x42L
Tim Peters9940b802000-12-01 07:59:35 +00001632 '-42' # in 2.1
Tim Petersa3a3a032000-11-30 05:22:44 +00001633 'ffffffbe' # in 2.0 and before, on 32-bit machines
1634 >>> hex(-0x42L)
1635 '-0x42L' # in all versions of Python
1636
Tim Peters9940b802000-12-01 07:59:35 +00001637 The behavior of %d formats for negative Python longs remains
1638 the same as in 2.0 (although in 1.6 and before, they raised
1639 an error if the long didn't fit in a Python int).
1640
1641 %u formats don't make sense for Python longs, but are allowed
1642 and treated the same as %d in 2.1. In 2.0, a negative long
1643 formatted via %u produced a sign if and only if too large to
1644 fit in an int. In 1.6 and earlier, a negative long formatted
1645 via %u raised an error if it was too big to fit in an int.
1646
Guido van Rossum3661d392000-12-12 22:10:31 +00001647- Dictionary objects have an odd new method, popitem(). This removes
1648 an arbitrary item from the dictionary and returns it (in the form of
1649 a (key, value) pair). This can be useful for algorithms that use a
1650 dictionary as a bag of "to do" items and repeatedly need to pick one
1651 item. Such algorithms normally end up running in quadratic time;
1652 using popitem() they can usually be made to run in linear time.
1653
Tim Peters36cdad12000-12-29 02:06:45 +00001654Standard library
1655
Thomas Woutersfe385252001-01-19 23:16:56 +00001656- In the time module, the time argument to the functions strftime,
1657 localtime, gmtime, asctime and ctime is now optional, defaulting to
1658 the current time (in the local timezone).
1659
Guido van Rossumda91f222001-01-15 16:36:08 +00001660- The ftplib module now defaults to passive mode, which is deemed a
1661 more useful default given that clients are often inside firewalls
1662 these days. Note that this could break if ftplib is used to connect
1663 to a *server* that is inside a firewall, from outside; this is
1664 expected to be a very rare situation. To fix that, you can call
1665 ftp.set_pasv(0).
1666
Martin v. Löwis10a27872001-01-13 09:54:41 +00001667- The module site now treats .pth files not only for path configuration,
1668 but also supports extensions to the initialization code: Lines starting
1669 with import are executed.
1670
Guido van Rossumf61f1662001-01-10 20:13:55 +00001671- There's a new module, warnings, which implements a mechanism for
1672 issuing and filtering warnings. There are some new built-in
1673 exceptions that serve as warning categories, and a new command line
1674 option, -W, to control warnings (e.g. -Wi ignores all warnings, -We
1675 turns warnings into errors). warnings.warn(message[, category])
1676 issues a warning message; this can also be called from C as
1677 PyErr_Warn(category, message).
1678
1679- A new module xreadlines was added. This exports a single factory
1680 function, xreadlines(). The intention is that this code is the
1681 absolutely fastest way to iterate over all lines in an open
1682 file(-like) object:
1683
1684 import xreadlines
1685 for line in xreadlines.xreadlines(file):
1686 ...do something to line...
1687
1688 This is equivalent to the previous the speed record holder using
1689 file.readlines(sizehint). Note that if file is a real file object
1690 (as opposed to a file-like object), this is equivalent:
1691
1692 for line in file.xreadlines():
1693 ...do something to line...
1694
Tim Peters36cdad12000-12-29 02:06:45 +00001695- The bisect module has new functions bisect_left, insort_left,
1696 bisect_right and insort_right. The old names bisect and insort
1697 are now aliases for bisect_right and insort_right. XXX_right
1698 and XXX_left methods differ in what happens when the new element
1699 compares equal to one or more elements already in the list: the
1700 XXX_left methods insert to the left, the XXX_right methods to the
Tim Peters742bb6f2001-01-05 08:05:32 +00001701 right. Code that doesn't care where equal elements end up should
1702 continue to use the old, short names ("bisect" and "insort").
Tim Peters36cdad12000-12-29 02:06:45 +00001703
Andrew M. Kuchlingf6f3a892001-01-13 14:53:34 +00001704- The new curses.panel module wraps the panel library that forms part
1705 of SYSV curses and ncurses. Contributed by Thomas Gellekum.
1706
Guido van Rossumf61f1662001-01-10 20:13:55 +00001707- The SocketServer module now sets the allow_reuse_address flag by
1708 default in the TCPServer class.
1709
1710- A new function, sys._getframe(), returns the stack frame pointer of
1711 the caller. This is intended only as a building block for
1712 higher-level mechanisms such as string interpolation.
1713
Martin v. Löwis2a5130e2001-02-27 04:21:58 +00001714- The pyexpat module supports a number of new handlers, which are
1715 available only in expat 1.2. If invocation of a callback fails, it
1716 will report an additional frame in the traceback. Parser objects
1717 participate now in garbage collection. If expat reports an unknown
1718 encoding, pyexpat will try to use a Python codec; that works only
1719 for single-byte charsets. The parser type objects is exposed as
1720 XMLParserObject.
1721
1722- xml.dom now offers standard definitions for symbolic node type and
1723 exception code constants, and a hierarchy of DOM exceptions. minidom
1724 was adjusted to use them.
1725
1726- The conformance of xml.dom.minidom to the DOM specification was
1727 improved. It detects a number of additional error cases; the
1728 previous/next relationship works even when the tree is modified;
1729 Node supports the normalize() method; NamedNodeMap, DocumentType and
1730 DOMImplementation classes were added; Element supports the
1731 hasAttribute and hasAttributeNS methods; and Text supports the splitText
1732 method.
1733
Guido van Rossumf61f1662001-01-10 20:13:55 +00001734Build issues
1735
Guido van Rossum1e33bdc2001-01-23 03:17:00 +00001736- For Unix (and Unix-compatible) builds, configuration and building of
1737 extension modules is now greatly automated. Rather than having to
1738 edit the Modules/Setup file to indicate which modules should be
1739 built and where their include files and libraries are, a
1740 distutils-based setup.py script now takes care of building most
1741 extension modules. All extension modules built this way are built
1742 as shared libraries. Only a few modules that must be linked
1743 statically are still listed in the Setup file; you won't need to
1744 edit their configuration.
1745
1746- Python should now build out of the box on Cygwin. If it doesn't,
1747 mail to Jason Tishler (jlt63 at users.sourceforge.net).
Guido van Rossumf61f1662001-01-10 20:13:55 +00001748
1749- Python now always uses its own (renamed) implementation of getopt()
1750 -- there's too much variation among C library getopt()
1751 implementations.
1752
1753- C++ compilers are better supported; the CXX macro is always set to a
1754 C++ compiler if one is found.
Tim Peters36cdad12000-12-29 02:06:45 +00001755
Tim Petersd92dfe02000-12-12 01:18:41 +00001756Windows changes
1757
1758- select module: By default under Windows, a select() call
1759 can specify no more than 64 sockets. Python now boosts
1760 this Microsoft default to 512. If you need even more than
1761 that, see the MS docs (you'll need to #define FD_SETSIZE
1762 and recompile Python from source).
1763
Guido van Rossumf61f1662001-01-10 20:13:55 +00001764- Support for Windows 3.1, DOS and OS/2 is gone. The Lib/dos-8x3
1765 subdirectory is no more!
1766
Tim Petersa3a3a032000-11-30 05:22:44 +00001767
Jeremy Hyltond6e20232000-10-16 20:08:38 +00001768What's New in Python 2.0?
Fred Drake1a640502000-10-16 20:27:25 +00001769=========================
Guido van Rossum61000331997-08-15 04:39:58 +00001770
Guido van Rossum8ed602b2000-09-01 22:34:33 +00001771Below is a list of all relevant changes since release 1.6. Older
Guido van Rossumf2ffce02000-09-05 04:38:34 +00001772changes are in the file HISTORY. If you are making the jump directly
1773from Python 1.5.2 to 2.0, make sure to read the section for 1.6 in the
1774HISTORY file! Many important changes listed there.
Guido van Rossum61000331997-08-15 04:39:58 +00001775
Guido van Rossumf2ffce02000-09-05 04:38:34 +00001776Alternatively, a good overview of the changes between 1.5.2 and 2.0 is
1777the document "What's New in Python 2.0" by Kuchling and Moshe Zadka:
1778http://starship.python.net/crew/amk/python/writing/new-python/.
Guido van Rossum1f83cce1997-10-06 21:04:35 +00001779
Guido van Rossumf2ffce02000-09-05 04:38:34 +00001780--Guido van Rossum (home page: http://www.pythonlabs.com/~guido/)
Guido van Rossum437cfe81999-04-08 20:17:57 +00001781
1782======================================================================
1783
Jeremy Hyltond6e20232000-10-16 20:08:38 +00001784What's new in 2.0 (since release candidate 1)?
1785==============================================
1786
1787Standard library
1788
1789- The copy_reg module was modified to clarify its intended use: to
1790 register pickle support for extension types, not for classes.
1791 pickle() will raise a TypeError if it is passed a class.
1792
1793- Fixed a bug in gettext's "normalize and expand" code that prevented
1794 it from finding an existing .mo file.
1795
1796- Restored support for HTTP/0.9 servers in httplib.
1797
Tim Peters989b7b92000-10-16 20:24:53 +00001798- The math module was changed to stop raising OverflowError in case of
1799 underflow, and return 0 instead in underflow cases. Whether Python
1800 used to raise OverflowError in case of underflow was platform-
1801 dependent (it did when the platform math library set errno to ERANGE
1802 on underflow).
Jeremy Hyltond6e20232000-10-16 20:08:38 +00001803
1804- Fixed a bug in StringIO that occurred when the file position was not
1805 at the end of the file and write() was called with enough data to
1806 extend past the end of the file.
1807
1808- Fixed a bug that caused Tkinter error messages to get lost on
1809 Windows. The bug was fixed by replacing direct use of
1810 interp->result with Tcl_GetStringResult(interp).
1811
1812- Fixed bug in urllib2 that caused it to fail when it received an HTTP
1813 redirect response.
1814
1815- Several changes were made to distutils: Some debugging code was
1816 removed from util. Fixed the installer used when an external zip
1817 program (like WinZip) is not found; the source code for this
1818 installer is in Misc/distutils. check_lib() was modified to behave
1819 more like AC_CHECK_LIB by add other_libraries() as a parameter. The
1820 test for whether installed modules are on sys.path was changed to
1821 use both normcase() and normpath().
1822
Jeremy Hyltond867a2c2000-10-16 20:41:38 +00001823- Several minor bugs were fixed in the xml package (the minidom,
1824 pulldom, expatreader, and saxutils modules).
Jeremy Hyltond6e20232000-10-16 20:08:38 +00001825
1826- The regression test driver (regrtest.py) behavior when invoked with
1827 -l changed: It now reports a count of objects that are recognized as
1828 garbage but not freed by the garbage collector.
1829
Tim Peters989b7b92000-10-16 20:24:53 +00001830- The regression test for the math module was changed to test
1831 exceptional behavior when the test is run in verbose mode. Python
1832 cannot yet guarantee consistent exception behavior across platforms,
1833 so the exception part of test_math is run only in verbose mode, and
1834 may fail on your platform.
Jeremy Hyltond6e20232000-10-16 20:08:38 +00001835
1836Internals
1837
1838- PyOS_CheckStack() has been disabled on Win64, where it caused
1839 test_sre to fail.
1840
1841Build issues
1842
1843- Changed compiler flags, so that gcc is always invoked with -Wall and
1844 -Wstrict-prototypes. Users compiling Python with GCC should see
1845 exactly one warning, except if they have passed configure the
Tim Peters989b7b92000-10-16 20:24:53 +00001846 --with-pydebug flag. The expected warning is for getopt() in
Tim Petersadfb94f2000-10-16 20:51:33 +00001847 Modules/main.c. This warning will be fixed for Python 2.1.
Jeremy Hyltond6e20232000-10-16 20:08:38 +00001848
Tim Petersa3a3a032000-11-30 05:22:44 +00001849- Fixed configure to add -threads argument during linking on OSF1.
Jeremy Hyltond6e20232000-10-16 20:08:38 +00001850
1851Tools and other miscellany
1852
1853- The compiler in Tools/compiler was updated to support the new
1854 language features introduced in 2.0: extended print statement, list
1855 comprehensions, and augmented assignments. The new compiler should
1856 also be backwards compatible with Python 1.5.2; the compiler will
1857 always generate code for the version of the interpreter it runs
Tim Petersa3a3a032000-11-30 05:22:44 +00001858 under.
Jeremy Hyltond6e20232000-10-16 20:08:38 +00001859
Jeremy Hyltoned9e6442000-10-09 18:26:42 +00001860What's new in 2.0 release candidate 1 (since beta 2)?
1861=====================================================
1862
Jeremy Hylton6040aaa2000-10-09 21:27:22 +00001863What is release candidate 1?
1864
1865We believe that release candidate 1 will fix all known bugs that we
1866intend to fix for the 2.0 final release. This release should be a bit
1867more stable than the previous betas. We would like to see even more
1868widespread testing before the final release, so we are producing this
1869release candidate. The final release will be exactly the same unless
1870any show-stopping (or brown bag) bugs are found by testers of the
1871release candidate.
1872
Jeremy Hyltoned9e6442000-10-09 18:26:42 +00001873All the changes since the last beta release are bug fixes or changes
Jeremy Hyltond6e20232000-10-16 20:08:38 +00001874to support building Python for specific platforms.
Jeremy Hyltoned9e6442000-10-09 18:26:42 +00001875
1876Core language, builtins, and interpreter
1877
1878- A bug that caused crashes when __coerce__ was used with augmented
1879 assignment, e.g. +=, was fixed.
1880
1881- Raise ZeroDivisionError when raising zero to a negative number,
1882 e.g. 0.0 ** -2.0. Note that math.pow is unrelated to the builtin
1883 power operator and the result of math.pow(0.0, -2.0) will vary by
1884 platform. On Linux, it raises a ValueError.
1885
1886- A bug in Unicode string interpolation was fixed that occasionally
1887 caused errors with formats including "%%". For example, the
1888 following expression "%% %s" % u"abc" no longer raises a TypeError.
1889
1890- Compilation of deeply nested expressions raises MemoryError instead
1891 of SyntaxError, e.g. eval("[" * 50 + "]" * 50).
1892
1893- In 2.0b2 on Windows, the interpreter wrote .pyc files in text mode,
1894 rendering them useless. They are now written in binary mode again.
1895
1896Standard library
1897
1898- Keyword arguments are now accepted for most pattern and match object
1899 methods in SRE, the standard regular expression engine.
1900
Jeremy Hyltond6e20232000-10-16 20:08:38 +00001901- In SRE, fixed error with negative lookahead and lookbehind that
Jeremy Hylton32e20ff2000-10-09 19:48:11 +00001902 manifested itself as a runtime error in patterns like "(?<!abc)(def)".
Jeremy Hyltoned9e6442000-10-09 18:26:42 +00001903
Jeremy Hyltond6e20232000-10-16 20:08:38 +00001904- Several bugs in the Unicode handling and error handling in _tkinter
1905 were fixed.
Jeremy Hyltoned9e6442000-10-09 18:26:42 +00001906
1907- Fix memory management errors in Merge() and Tkapp_Call() routines.
1908
1909- Several changes were made to cStringIO to make it compatible with
1910 the file-like object interface and with StringIO. If operations are
1911 performed on a closed object, an exception is raised. The truncate
1912 method now accepts a position argument and readline accepts a size
Tim Petersa3a3a032000-11-30 05:22:44 +00001913 argument.
Jeremy Hyltoned9e6442000-10-09 18:26:42 +00001914
1915- There were many changes made to the linuxaudiodev module and its
1916 test suite; as a result, a short, unexpected audio sample should now
Tim Petersa3a3a032000-11-30 05:22:44 +00001917 play when the regression test is run.
Jeremy Hyltoned9e6442000-10-09 18:26:42 +00001918
1919 Note that this module is named poorly, because it should work
1920 correctly on any platform that supports the Open Sound System
Tim Petersa3a3a032000-11-30 05:22:44 +00001921 (OSS).
Jeremy Hyltoned9e6442000-10-09 18:26:42 +00001922
1923 The module now raises exceptions when errors occur instead of
1924 crashing. It also defines the AFMT_A_LAW format (logarithmic A-law
1925 audio) and defines a getptr() method that calls the
1926 SNDCTL_DSP_GETxPTR ioctl defined in the OSS Programmer's Guide.
1927
1928- The library_version attribute, introduced in an earlier beta, was
1929 removed because it can not be supported with early versions of the C
1930 readline library, which provides no way to determine the version at
1931 compile-time.
1932
1933- The binascii module is now enabled on Win64.
1934
Tim Peters46446d62000-10-09 21:19:31 +00001935- tokenize.py no longer suffers "recursion depth" errors when parsing
1936 programs with very long string literals.
1937
Jeremy Hyltoned9e6442000-10-09 18:26:42 +00001938Internals
1939
Jeremy Hyltond6e20232000-10-16 20:08:38 +00001940- Fixed several buffer overflow vulnerabilities in calculate_path(),
Jeremy Hyltoned9e6442000-10-09 18:26:42 +00001941 which is called when the interpreter starts up to determine where
1942 the standard library is installed. These vulnerabilities affect all
1943 previous versions of Python and can be exploited by setting very
1944 long values for PYTHONHOME or argv[0]. The risk is greatest for a
1945 setuid Python script, although use of the wrapper in
1946 Misc/setuid-prog.c will eliminate the vulnerability.
1947
1948- Fixed garbage collection bugs in instance creation that were
1949 triggered when errors occurred during initialization. The solution,
1950 applied in cPickle and in PyInstance_New(), is to call
1951 PyObject_GC_Init() after the initialization of the object's
1952 container attributes is complete.
1953
1954- pyexpat adds definitions of PyModule_AddStringConstant and
1955 PyModule_AddObject if the Python version is less than 2.0, which
1956 provides compatibility with PyXML on Python 1.5.2.
1957
1958- If the platform has a bogus definition for LONG_BIT (the number of
1959 bits in a long), an error will be reported at compile time.
1960
1961- Fix bugs in _PyTuple_Resize() which caused hard-to-interpret garbage
1962 collection crashes and possibly other, unreported crashes.
1963
1964- Fixed a memory leak in _PyUnicode_Fini().
1965
1966Build issues
1967
1968- configure now accepts a --with-suffix option that specifies the
Jeremy Hyltond6e20232000-10-16 20:08:38 +00001969 executable suffix. This is useful for builds on Cygwin and Mac OS
Tim Petersa3a3a032000-11-30 05:22:44 +00001970 X, for example.
Jeremy Hyltoned9e6442000-10-09 18:26:42 +00001971
1972- The mmap.PAGESIZE constant is now initialized using sysconf when
1973 possible, which eliminates a dependency on -lucb for Reliant UNIX.
1974
1975- The md5 file should now compile on all platforms.
1976
1977- The select module now compiles on platforms that do not define
1978 POLLRDNORM and related constants.
1979
1980- Darwin (Mac OS X): Initial support for static builds on this
Tim Petersa3a3a032000-11-30 05:22:44 +00001981 platform.
Jeremy Hyltoned9e6442000-10-09 18:26:42 +00001982
Jeremy Hylton10921202000-10-09 18:34:12 +00001983- BeOS: A number of changes were made to the build and installation
1984 process. ar-fake now operates on a directory of object files.
1985 dl_export.h is gone, and its macros now appear on the mwcc command
1986 line during build on PPC BeOS.
1987
Jeremy Hyltond6e20232000-10-16 20:08:38 +00001988- Platform directory in lib/python2.0 is "plat-beos5" (or
Jeremy Hylton10921202000-10-09 18:34:12 +00001989 "plat-beos4", if building on BeOS 4.5), rather than "plat-beos".
Jeremy Hyltoned9e6442000-10-09 18:26:42 +00001990
1991- Cygwin: Support for shared libraries, Tkinter, and sockets.
1992
1993- SunOS 4.1.4_JL: Fix test for directory existence in configure.
1994
1995Tools and other miscellany
1996
1997- Removed debugging prints from main used with freeze.
1998
Tim Peters46446d62000-10-09 21:19:31 +00001999- IDLE auto-indent no longer crashes when it encounters Unicode
2000 characters.
Jeremy Hylton1b618592000-09-26 05:32:36 +00002001
2002What's new in 2.0 beta 2 (since beta 1)?
2003========================================
2004
2005Core language, builtins, and interpreter
2006
Tim Peters482c0212000-09-26 06:33:09 +00002007- Add support for unbounded ints in %d,i,u,x,X,o formats; for example
Guido van Rossumf62ed9c2000-09-26 11:16:10 +00002008 "%d" % 2L**64 == "18446744073709551616".
Jeremy Hylton1b618592000-09-26 05:32:36 +00002009
Guido van Rossumf62ed9c2000-09-26 11:16:10 +00002010- Add -h and -V command line options to print the usage message and
2011 Python version number and exit immediately.
2012
Jeremy Hyltonfa2e2c12000-09-26 16:31:30 +00002013- eval() and exec accept Unicode objects as code parameters.
2014
2015- getattr() and setattr() now also accept Unicode objects for the
2016 attribute name, which are converted to strings using the default
2017 encoding before lookup.
2018
2019- Multiplication on string and Unicode now does proper bounds
2020 checking; e.g. 'a' * 65536 * 65536 will raise ValueError, "repeated
2021 string is too long."
2022
2023- Better error message when continue is found in try statement in a
Tim Petersa3a3a032000-11-30 05:22:44 +00002024 loop.
Jeremy Hyltonfa2e2c12000-09-26 16:31:30 +00002025
Jeremy Hylton1b618592000-09-26 05:32:36 +00002026
2027Standard library and extensions
2028
Guido van Rossum5b08f132001-04-16 02:05:23 +00002029- socket module: the OpenSSL code now adds support for RAND_status()
2030 and EGD (Entropy Gathering Device).
2031
Guido van Rossumf62ed9c2000-09-26 11:16:10 +00002032- array: reverse() method of array now works. buffer_info() now does
Jeremy Hylton1b618592000-09-26 05:32:36 +00002033 argument checking; it still takes no arguments.
2034
Guido van Rossumf62ed9c2000-09-26 11:16:10 +00002035- asyncore/asynchat: Included most recent version from Sam Rushing.
Jeremy Hylton1b618592000-09-26 05:32:36 +00002036
Guido van Rossumf62ed9c2000-09-26 11:16:10 +00002037- cgi: Accept '&' or ';' as separator characters when parsing form data.
Jeremy Hylton1b618592000-09-26 05:32:36 +00002038
Guido van Rossumf62ed9c2000-09-26 11:16:10 +00002039- CGIHTTPServer: Now works on Windows (and perhaps even Mac).
Jeremy Hylton1b618592000-09-26 05:32:36 +00002040
2041- ConfigParser: When reading the file, options spelled in upper case
Guido van Rossumf62ed9c2000-09-26 11:16:10 +00002042 letters are now correctly converted to lowercase.
Jeremy Hylton1b618592000-09-26 05:32:36 +00002043
2044- copy: Copy Unicode objects atomically.
2045
Guido van Rossumf62ed9c2000-09-26 11:16:10 +00002046- cPickle: Fail gracefully when copy_reg can't be imported.
Jeremy Hylton1b618592000-09-26 05:32:36 +00002047
Guido van Rossumf62ed9c2000-09-26 11:16:10 +00002048- cStringIO: Implemented readlines() method.
Jeremy Hylton1b618592000-09-26 05:32:36 +00002049
Fred Drake67233bc2000-09-26 16:40:27 +00002050- dbm: Add get() and setdefault() methods to dbm object. Add constant
2051 `library' to module that names the library used. Added doc strings
2052 and method names to error messages. Uses configure to determine
2053 which ndbm.h file to include; Berkeley DB's nbdm and GDBM's ndbm is
2054 now available options.
Jeremy Hylton1b618592000-09-26 05:32:36 +00002055
2056- distutils: Update to version 0.9.3.
2057
2058- dl: Add several dl.RTLD_ constants.
2059
2060- fpectl: Now supported on FreeBSD.
2061
2062- gc: Add DEBUG_SAVEALL option. When enabled all garbage objects
2063 found by the collector will be saved in gc.garbage. This is useful
2064 for debugging a program that creates reference cycles.
2065
Guido van Rossumf62ed9c2000-09-26 11:16:10 +00002066- httplib: Three changes: Restore support for set_debuglevel feature
Jeremy Hylton1b618592000-09-26 05:32:36 +00002067 of HTTP class. Do not close socket on zero-length response. Do not
2068 crash when server sends invalid content-length header.
2069
Guido van Rossumf62ed9c2000-09-26 11:16:10 +00002070- mailbox: Mailbox class conforms better to qmail specifications.
Jeremy Hylton1b618592000-09-26 05:32:36 +00002071
Jeremy Hyltonfa2e2c12000-09-26 16:31:30 +00002072- marshal: When reading a short, sign-extend on platforms where shorts
2073 are bigger than 16 bits. When reading a long, repair the unportable
2074 sign extension that was being done for 64-bit machines. (It assumed
2075 that signed right shift sign-extends.)
2076
Guido van Rossumf62ed9c2000-09-26 11:16:10 +00002077- operator: Add contains(), invert(), __invert__() as aliases for
2078 __contains__(), inv(), and __inv__() respectively.
Jeremy Hylton1b618592000-09-26 05:32:36 +00002079
Guido van Rossumf62ed9c2000-09-26 11:16:10 +00002080- os: Add support for popen2() and popen3() on all platforms where
2081 fork() exists. (popen4() is still in the works.)
Jeremy Hylton1b618592000-09-26 05:32:36 +00002082
Guido van Rossumf62ed9c2000-09-26 11:16:10 +00002083- os: (Windows only:) Add startfile() function that acts like double-
Tim Peters482c0212000-09-26 06:33:09 +00002084 clicking on a file in Explorer (or passing the file name to the
2085 DOS "start" command).
Jeremy Hylton1b618592000-09-26 05:32:36 +00002086
Guido van Rossumf62ed9c2000-09-26 11:16:10 +00002087- os.path: (Windows, DOS:) Treat trailing colon correctly in
Tim Peters482c0212000-09-26 06:33:09 +00002088 os.path.join. os.path.join("a:", "b") yields "a:b".
Jeremy Hylton1b618592000-09-26 05:32:36 +00002089
2090- pickle: Now raises ValueError when an invalid pickle that contains
2091 a non-string repr where a string repr was expected. This behavior
2092 matches cPickle.
2093
Guido van Rossumf62ed9c2000-09-26 11:16:10 +00002094- posixfile: Remove broken __del__() method.
Jeremy Hylton1b618592000-09-26 05:32:36 +00002095
Guido van Rossumf62ed9c2000-09-26 11:16:10 +00002096- py_compile: support CR+LF line terminators in source file.
Jeremy Hylton1b618592000-09-26 05:32:36 +00002097
2098- readline: Does not immediately exit when ^C is hit when readline and
Jeremy Hyltonfa2e2c12000-09-26 16:31:30 +00002099 threads are configured. Adds definition of rl_library_version. (The
Guido van Rossumf62ed9c2000-09-26 11:16:10 +00002100 latter addition requires GNU readline 2.2 or later.)
Jeremy Hylton1b618592000-09-26 05:32:36 +00002101
2102- rfc822: Domain literals returned by AddrlistClass method
Guido van Rossumf62ed9c2000-09-26 11:16:10 +00002103 getdomainliteral() are now properly wrapped in brackets.
Jeremy Hylton1b618592000-09-26 05:32:36 +00002104
2105- site: sys.setdefaultencoding() should only be called in case the
Tim Peters482c0212000-09-26 06:33:09 +00002106 standard default encoding ("ascii") is changed. This saves quite a
Jeremy Hylton1b618592000-09-26 05:32:36 +00002107 few cycles during startup since the first call to
2108 setdefaultencoding() will initialize the codec registry and the
2109 encodings package.
2110
Guido van Rossumf62ed9c2000-09-26 11:16:10 +00002111- socket: Support for size hint in readlines() method of object returned
2112 by makefile().
Jeremy Hylton1b618592000-09-26 05:32:36 +00002113
Guido van Rossumf62ed9c2000-09-26 11:16:10 +00002114- sre: Added experimental expand() method to match objects. Does not
Jeremy Hylton625915e2000-10-02 13:43:33 +00002115 use buffer interface on Unicode strings. Does not hang if group id
Jeremy Hylton1b618592000-09-26 05:32:36 +00002116 is followed by whitespace.
2117
Tim Petersa3a3a032000-11-30 05:22:44 +00002118- StringIO: Size hint in readlines() is now supported as documented.
Jeremy Hylton1b618592000-09-26 05:32:36 +00002119
2120- struct: Check ranges for bytes and shorts.
2121
2122- urllib: Improved handling of win32 proxy settings. Fixed quote and
Guido van Rossumf62ed9c2000-09-26 11:16:10 +00002123 quote_plus functions so that the always encode a comma.
Jeremy Hylton1b618592000-09-26 05:32:36 +00002124
2125- Tkinter: Image objects are now guaranteed to have unique ids. Set
2126 event.delta to zero if Tk version doesn't support mousewheel.
2127 Removed some debugging prints.
2128
Guido van Rossumf62ed9c2000-09-26 11:16:10 +00002129- UserList: now implements __contains__().
Jeremy Hylton1b618592000-09-26 05:32:36 +00002130
Fred Drake67233bc2000-09-26 16:40:27 +00002131- webbrowser: On Windows, use os.startfile() instead of os.popen(),
Guido van Rossumf62ed9c2000-09-26 11:16:10 +00002132 which works around a bug in Norton AntiVirus 2000 that leads directly
2133 to a Blue Screen freeze.
Jeremy Hylton1b618592000-09-26 05:32:36 +00002134
2135- xml: New version detection code allows PyXML to override standard
2136 XML package if PyXML version is greater than 0.6.1.
2137
Fred Drake64bb3802000-09-26 16:21:35 +00002138- xml.dom: DOM level 1 support for basic XML. Includes xml.dom.minidom
2139 (conventional DOM), and xml.dom.pulldom, which allows building the DOM
2140 tree only for nodes which are sufficiently interesting to a specific
2141 application. Does not provide the HTML-specific extensions. Still
2142 undocumented.
Jeremy Hylton1b618592000-09-26 05:32:36 +00002143
Fred Drake64bb3802000-09-26 16:21:35 +00002144- xml.sax: SAX 2 support for Python, including all the handler
2145 interfaces needed to process XML 1.0 compliant XML. Some
2146 documentation is already available.
Jeremy Hylton1b618592000-09-26 05:32:36 +00002147
Fred Drake64bb3802000-09-26 16:21:35 +00002148- pyexpat: Renamed to xml.parsers.expat since this is part of the new,
2149 packagized XML support.
Jeremy Hylton1b618592000-09-26 05:32:36 +00002150
Guido van Rossumf62ed9c2000-09-26 11:16:10 +00002151
Jeremy Hylton1b618592000-09-26 05:32:36 +00002152C API
2153
2154- Add three new convenience functions for module initialization --
2155 PyModule_AddObject(), PyModule_AddIntConstant(), and
2156 PyModule_AddStringConstant().
2157
Jeremy Hyltonfa2e2c12000-09-26 16:31:30 +00002158- Cleaned up definition of NULL in C source code; all definitions were
Jeremy Hylton1b618592000-09-26 05:32:36 +00002159 removed and add #error to Python.h if NULL isn't defined after
2160 #include of stdio.h.
2161
Guido van Rossumf62ed9c2000-09-26 11:16:10 +00002162- Py_PROTO() macros that were removed in 2.0b1 have been restored for
Jeremy Hylton1b618592000-09-26 05:32:36 +00002163 backwards compatibility (at the source level) with old extensions.
2164
Guido van Rossumf62ed9c2000-09-26 11:16:10 +00002165- A wrapper API was added for signal() and sigaction(). Instead of
2166 either function, always use PyOS_getsig() to get a signal handler
2167 and PyOS_setsig() to set one. A new convenience typedef
2168 PyOS_sighandler_t is defined for the type of signal handlers.
Jeremy Hylton1b618592000-09-26 05:32:36 +00002169
Guido van Rossumf62ed9c2000-09-26 11:16:10 +00002170- Add PyString_AsStringAndSize() function that provides access to the
Jeremy Hylton1b618592000-09-26 05:32:36 +00002171 internal data buffer and size of a string object -- or the default
2172 encoded version of a Unicode object.
2173
Jeremy Hyltonfa2e2c12000-09-26 16:31:30 +00002174- PyString_Size() and PyString_AsString() accept Unicode objects.
2175
Guido van Rossumf62ed9c2000-09-26 11:16:10 +00002176- The standard header <limits.h> is now included by Python.h (if it
Fred Drake64bb3802000-09-26 16:21:35 +00002177 exists). INT_MAX and LONG_MAX will always be defined, even if
2178 <limits.h> is not available.
Guido van Rossumf62ed9c2000-09-26 11:16:10 +00002179
Jeremy Hyltonfa2e2c12000-09-26 16:31:30 +00002180- PyFloat_FromString takes a second argument, pend, that was
2181 effectively useless. It is now officially useless but preserved for
2182 backwards compatibility. If the pend argument is not NULL, *pend is
2183 set to NULL.
2184
2185- PyObject_GetAttr() and PyObject_SetAttr() now accept Unicode objects
2186 for the attribute name. See note on getattr() above.
2187
2188- A few bug fixes to argument processing for Unicode.
2189 PyArg_ParseTupleAndKeywords() now accepts "es#" and "es".
2190 PyArg_Parse() special cases "s#" for Unicode objects; it returns a
2191 pointer to the default encoded string data instead of to the raw
Tim Petersa3a3a032000-11-30 05:22:44 +00002192 UTF-16.
Jeremy Hyltonfa2e2c12000-09-26 16:31:30 +00002193
2194- Py_BuildValue accepts B format (for bgen-generated code).
2195
Guido van Rossumf62ed9c2000-09-26 11:16:10 +00002196
Jeremy Hylton1b618592000-09-26 05:32:36 +00002197Internals
2198
2199- On Unix, fix code for finding Python installation directory so that
2200 it works when argv[0] is a relative path.
2201
Andrew M. Kuchlinga1099be2000-12-15 01:16:43 +00002202- Added a true unicode_internal_encode() function and fixed the
Guido van Rossumf62ed9c2000-09-26 11:16:10 +00002203 unicode_internal_decode function() to support Unicode objects directly
Jeremy Hylton1b618592000-09-26 05:32:36 +00002204 rather than by generating a copy of the object.
2205
Tim Peters482c0212000-09-26 06:33:09 +00002206- Several of the internal Unicode tables are much smaller now, and
2207 the source code should be much friendlier to weaker compilers.
Jeremy Hylton1b618592000-09-26 05:32:36 +00002208
Jeremy Hylton97693b02000-09-26 17:42:51 +00002209- In the garbage collector: Fixed bug in collection of tuples. Fixed
2210 bug that caused some instances to be removed from the container set
2211 while they were still live. Fixed parsing in gc.set_debug() for
2212 platforms where sizeof(long) > sizeof(int).
Jeremy Hyltonfa2e2c12000-09-26 16:31:30 +00002213
2214- Fixed refcount problem in instance deallocation that only occurred
2215 when Py_REF_DEBUG was defined and Py_TRACE_REFS was not.
2216
Jeremy Hyltonfa2e2c12000-09-26 16:31:30 +00002217- On Windows, getpythonregpath is now protected against null data in
2218 registry key.
2219
2220- On Unix, create .pyc/.pyo files with O_EXCL flag to avoid a race
Tim Petersa3a3a032000-11-30 05:22:44 +00002221 condition.
Jeremy Hyltonfa2e2c12000-09-26 16:31:30 +00002222
Guido van Rossumf62ed9c2000-09-26 11:16:10 +00002223
Jeremy Hylton1b618592000-09-26 05:32:36 +00002224Build and platform-specific issues
2225
2226- Better support of GNU Pth via --with-pth configure option.
2227
Jeremy Hyltonfa2e2c12000-09-26 16:31:30 +00002228- Python/C API now properly exposed to dynamically-loaded extension
2229 modules on Reliant UNIX.
Jeremy Hylton1b618592000-09-26 05:32:36 +00002230
2231- Changes for the benefit of SunOS 4.1.4 (really!). mmapmodule.c:
2232 Don't define MS_SYNC to be zero when it is undefined. Added missing
2233 prototypes in posixmodule.c.
2234
Jeremy Hyltonfa2e2c12000-09-26 16:31:30 +00002235- Improved support for HP-UX build. Threads should now be correctly
Guido van Rossumf62ed9c2000-09-26 11:16:10 +00002236 configured (on HP-UX 10.20 and 11.00).
Jeremy Hylton1b618592000-09-26 05:32:36 +00002237
Jeremy Hyltonfa2e2c12000-09-26 16:31:30 +00002238- Fix largefile support on older NetBSD systems and OpenBSD by adding
2239 define for TELL64.
2240
2241
2242Tools and other miscellany
2243
2244- ftpmirror: Call to main() is wrapped in if __name__ == "__main__".
2245
2246- freeze: The modulefinder now works with 2.0 opcodes.
2247
Tim Petersa3a3a032000-11-30 05:22:44 +00002248- IDLE:
Jeremy Hyltonfa2e2c12000-09-26 16:31:30 +00002249 Move hackery of sys.argv until after the Tk instance has been
2250 created, which allows the application-specific Tkinter
2251 initialization to be executed if present; also pass an explicit
2252 className parameter to the Tk() constructor.
Fred Drake64bb3802000-09-26 16:21:35 +00002253
Jeremy Hylton1b618592000-09-26 05:32:36 +00002254
2255What's new in 2.0 beta 1?
2256=========================
2257
Guido van Rossumf2ffce02000-09-05 04:38:34 +00002258Source Incompatibilities
2259------------------------
2260
2261None. Note that 1.6 introduced several incompatibilities with 1.5.2,
2262such as single-argument append(), connect() and bind(), and changes to
2263str(long) and repr(float).
2264
2265
2266Binary Incompatibilities
2267------------------------
2268
2269- Third party extensions built for Python 1.5.x or 1.6 cannot be used
2270with Python 2.0; these extensions will have to be rebuilt for Python
22712.0.
2272
2273- On Windows, attempting to import a third party extension built for
2274Python 1.5.x or 1.6 results in an immediate crash; there's not much we
2275can do about this. Check your PYTHONPATH environment variable!
2276
2277- Python bytecode files (*.pyc and *.pyo) are not compatible between
2278releases.
2279
2280
2281Overview of Changes Since 1.6
2282-----------------------------
2283
2284There are many new modules (including brand new XML support through
2285the xml package, and i18n support through the gettext module); a list
2286of all new modules is included below. Lots of bugs have been fixed.
2287
Jeremy Hylton24c3d602000-09-05 19:36:26 +00002288The process for making major new changes to the language has changed
2289since Python 1.6. Enhancements must now be documented by a Python
2290Enhancement Proposal (PEP) before they can be accepted.
2291
Guido van Rossumf2ffce02000-09-05 04:38:34 +00002292There are several important syntax enhancements, described in more
2293detail below:
2294
2295 - Augmented assignment, e.g. x += 1
2296
2297 - List comprehensions, e.g. [x**2 for x in range(10)]
2298
2299 - Extended import statement, e.g. import Module as Name
2300
2301 - Extended print statement, e.g. print >> file, "Hello"
2302
2303Other important changes:
2304
2305 - Optional collection of cyclical garbage
2306
Jeremy Hylton24c3d602000-09-05 19:36:26 +00002307Python Enhancement Proposal (PEP)
2308---------------------------------
2309
2310PEP stands for Python Enhancement Proposal. A PEP is a design
2311document providing information to the Python community, or describing
2312a new feature for Python. The PEP should provide a concise technical
2313specification of the feature and a rationale for the feature.
2314
2315We intend PEPs to be the primary mechanisms for proposing new
2316features, for collecting community input on an issue, and for
2317documenting the design decisions that have gone into Python. The PEP
2318author is responsible for building consensus within the community and
2319documenting dissenting opinions.
2320
2321The PEPs are available at http://python.sourceforge.net/peps/.
Guido van Rossumf2ffce02000-09-05 04:38:34 +00002322
2323Augmented Assignment
2324--------------------
2325
2326This must have been the most-requested feature of the past years!
2327Eleven new assignment operators were added:
2328
Guido van Rossume905e952000-09-05 12:42:46 +00002329 += -= *= /= %= **= <<= >>= &= ^= |=
Guido van Rossumf2ffce02000-09-05 04:38:34 +00002330
2331For example,
2332
2333 A += B
2334
2335is similar to
2336
2337 A = A + B
2338
2339except that A is evaluated only once (relevant when A is something
2340like dict[index].attr).
2341
2342However, if A is a mutable object, A may be modified in place. Thus,
2343if A is a number or a string, A += B has the same effect as A = A+B
2344(except A is only evaluated once); but if a is a list, A += B has the
2345same effect as A.extend(B)!
2346
2347Classes and built-in object types can override the new operators in
2348order to implement the in-place behavior; the not-in-place behavior is
2349used automatically as a fallback when an object doesn't implement the
2350in-place behavior. For classes, the method name is derived from the
2351method name for the corresponding not-in-place operator by inserting
2352an 'i' in front of the name, e.g. __iadd__ implements in-place
2353__add__.
2354
2355Augmented assignment was implemented by Thomas Wouters.
2356
2357
2358List Comprehensions
2359-------------------
2360
2361This is a flexible new notation for lists whose elements are computed
2362from another list (or lists). The simplest form is:
2363
2364 [<expression> for <variable> in <sequence>]
2365
Guido van Rossum56db0952000-09-06 23:34:25 +00002366For example, [i**2 for i in range(4)] yields the list [0, 1, 4, 9].
Guido van Rossumf62ed9c2000-09-26 11:16:10 +00002367This is more efficient than a for loop with a list.append() call.
Guido van Rossumf2ffce02000-09-05 04:38:34 +00002368
2369You can also add a condition:
2370
2371 [<expression> for <variable> in <sequence> if <condition>]
2372
2373For example, [w for w in words if w == w.lower()] would yield the list
2374of words that contain no uppercase characters. This is more efficient
Guido van Rossumf62ed9c2000-09-26 11:16:10 +00002375than a for loop with an if statement and a list.append() call.
Guido van Rossumf2ffce02000-09-05 04:38:34 +00002376
2377You can also have nested for loops and more than one 'if' clause. For
2378example, here's a function that flattens a sequence of sequences::
2379
2380 def flatten(seq):
2381 return [x for subseq in seq for x in subseq]
2382
2383 flatten([[0], [1,2,3], [4,5], [6,7,8,9], []])
2384
2385This prints
2386
2387 [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
2388
2389List comprehensions originated as a patch set from Greg Ewing; Skip
Jeremy Hylton24c3d602000-09-05 19:36:26 +00002390Montanaro and Thomas Wouters also contributed. Described by PEP 202.
Guido van Rossumf2ffce02000-09-05 04:38:34 +00002391
2392
2393Extended Import Statement
2394-------------------------
2395
2396Many people have asked for a way to import a module under a different
2397name. This can be accomplished like this:
2398
2399 import foo
2400 bar = foo
2401 del foo
2402
2403but this common idiom gets old quickly. A simple extension of the
2404import statement now allows this to be written as follows:
2405
2406 import foo as bar
2407
2408There's also a variant for 'from ... import':
2409
2410 from foo import bar as spam
2411
2412This also works with packages; e.g. you can write this:
2413
2414 import test.regrtest as regrtest
2415
2416Note that 'as' is not a new keyword -- it is recognized only in this
2417context (this is only possible because the syntax for the import
2418statement doesn't involve expressions).
2419
Jeremy Hylton24c3d602000-09-05 19:36:26 +00002420Implemented by Thomas Wouters. Described by PEP 221.
Guido van Rossumf2ffce02000-09-05 04:38:34 +00002421
2422
2423Extended Print Statement
2424------------------------
2425
2426Easily the most controversial new feature, this extension to the print
2427statement adds an option to make the output go to a different file
2428than the default sys.stdout.
2429
2430For example, to write an error message to sys.stderr, you can now
2431write:
2432
2433 print >> sys.stderr, "Error: bad dog!"
2434
2435As a special feature, if the expression used to indicate the file
Fred Drake45888ff2000-09-29 17:09:11 +00002436evaluates to None, the current value of sys.stdout is used. Thus:
Guido van Rossumf2ffce02000-09-05 04:38:34 +00002437
2438 print >> None, "Hello world"
2439
2440is equivalent to
2441
2442 print "Hello world"
2443
Jeremy Hylton24c3d602000-09-05 19:36:26 +00002444Design and implementation by Barry Warsaw. Described by PEP 214.
Guido van Rossumf2ffce02000-09-05 04:38:34 +00002445
2446
2447Optional Collection of Cyclical Garbage
2448---------------------------------------
2449
2450Python is now equipped with a garbage collector that can hunt down
2451cyclical references between Python objects. It's no replacement for
2452reference counting; in fact, it depends on the reference counts being
2453correct, and decides that a set of objects belong to a cycle if all
2454their reference counts can be accounted for from their references to
2455each other. This devious scheme was first proposed by Eric Tiedemann,
2456and brought to implementation by Neil Schemenauer.
2457
2458There's a module "gc" that lets you control some parameters of the
2459garbage collection. There's also an option to the configure script
2460that lets you enable or disable the garbage collection. In 2.0b1,
2461it's on by default, so that we (hopefully) can collect decent user
2462experience with this new feature. There are some questions about its
Fred Drake9f11cf82000-09-29 17:54:40 +00002463performance. If it proves to be too much of a problem, we'll turn it
Guido van Rossumf2ffce02000-09-05 04:38:34 +00002464off by default in the final 2.0 release.
2465
2466
2467Smaller Changes
2468---------------
2469
2470A new function zip() was added. zip(seq1, seq2, ...) is equivalent to
2471map(None, seq1, seq2, ...) when the sequences have the same length;
2472i.e. zip([1,2,3], [10,20,30]) returns [(1,10), (2,20), (3,30)]. When
2473the lists are not all the same length, the shortest list wins:
Jeremy Hylton24c3d602000-09-05 19:36:26 +00002474zip([1,2,3], [10,20]) returns [(1,10), (2,20)]. See PEP 201.
Guido van Rossumf2ffce02000-09-05 04:38:34 +00002475
2476sys.version_info is a tuple (major, minor, micro, level, serial).
2477
2478Dictionaries have an odd new method, setdefault(key, default).
2479dict.setdefault(key, default) returns dict[key] if it exists; if not,
2480it sets dict[key] to default and returns that value. Thus:
2481
2482 dict.setdefault(key, []).append(item)
2483
2484does the same work as this common idiom:
2485
2486 if not dict.has_key(key):
2487 dict[key] = []
2488 dict[key].append(item)
2489
Jeremy Hylton24c3d602000-09-05 19:36:26 +00002490There are two new variants of SyntaxError that are raised for
2491indentation-related errors: IndentationError and TabError.
2492
2493Changed \x to consume exactly two hex digits; see PEP 223. Added \U
2494escape that consumes exactly eight hex digits.
Jeremy Hyltonbdebd542000-09-05 18:28:54 +00002495
2496The limits on the size of expressions and file in Python source code
2497have been raised from 2**16 to 2**32. Previous versions of Python
2498were limited because the maximum argument size the Python VM accepted
2499was 2**16. This limited the size of object constructor expressions,
2500e.g. [1,2,3] or {'a':1, 'b':2}, and the size of source files. This
2501limit was raised thanks to a patch by Charles Waldman that effectively
2502fixes the problem. It is now much more likely that you will be
2503limited by available memory than by an arbitrary limit in Python.
2504
2505The interpreter's maximum recursion depth can be modified by Python
2506programs using sys.getrecursionlimit and sys.setrecursionlimit. This
2507limit is the maximum number of recursive calls that can be made by
2508Python code. The limit exists to prevent infinite recursion from
2509overflowing the C stack and causing a core dump. The default value is
25101000. The maximum safe value for a particular platform can be found
2511by running Misc/find_recursionlimit.py.
Guido van Rossumf2ffce02000-09-05 04:38:34 +00002512
2513New Modules and Packages
2514------------------------
2515
2516atexit - for registering functions to be called when Python exits.
2517
2518imputil - Greg Stein's alternative API for writing custom import
2519hooks.
2520
2521pyexpat - an interface to the Expat XML parser, contributed by Paul
2522Prescod.
2523
2524xml - a new package with XML support code organized (so far) in three
2525subpackages: xml.dom, xml.sax, and xml.parsers. Describing these
2526would fill a volume. There's a special feature whereby a
2527user-installed package named _xmlplus overrides the standard
2528xmlpackage; this is intended to give the XML SIG a hook to distribute
2529backwards-compatible updates to the standard xml package.
2530
2531webbrowser - a platform-independent API to launch a web browser.
2532
2533
Guido van Rossume905e952000-09-05 12:42:46 +00002534Changed Modules
2535---------------
2536
Jeremy Hylton24c3d602000-09-05 19:36:26 +00002537array -- new methods for array objects: count, extend, index, pop, and
2538remove
2539
2540binascii -- new functions b2a_hex and a2b_hex that convert between
2541binary data and its hex representation
2542
Jeremy Hyltonbdebd542000-09-05 18:28:54 +00002543calendar -- Many new functions that support features including control
2544over which day of the week is the first day, returning strings instead
2545of printing them. Also new symbolic constants for days of week,
2546e.g. MONDAY, ..., SUNDAY.
2547
2548cgi -- FieldStorage objects have a getvalue method that works like a
2549dictionary's get method and returns the value attribute of the object.
2550
2551ConfigParser -- The parser object has new methods has_option,
2552remove_section, remove_option, set, and write. They allow the module
2553to be used for writing config files as well as reading them.
2554
2555ftplib -- ntransfercmd(), transfercmd(), and retrbinary() all now
Guido van Rossume905e952000-09-05 12:42:46 +00002556optionally support the RFC 959 REST command.
2557
Jeremy Hyltonbdebd542000-09-05 18:28:54 +00002558gzip -- readline and readlines now accept optional size arguments
Guido van Rossume905e952000-09-05 12:42:46 +00002559
Jeremy Hyltonbdebd542000-09-05 18:28:54 +00002560httplib -- New interfaces and support for HTTP/1.1 by Greg Stein. See
2561the module doc strings for details.
Guido van Rossum830ca2a2000-09-05 15:34:16 +00002562
Jeremy Hylton24c3d602000-09-05 19:36:26 +00002563locale -- implement getdefaultlocale for Win32 and Macintosh
2564
2565marshal -- no longer dumps core when marshaling deeply nested or
2566recursive data structures
2567
2568os -- new functions isatty, seteuid, setegid, setreuid, setregid
2569
Jeremy Hyltonbdebd542000-09-05 18:28:54 +00002570os/popen2 -- popen2/popen3/popen4 support under Windows. popen2/popen3
2571support under Unix.
2572
Jeremy Hylton24c3d602000-09-05 19:36:26 +00002573os/pty -- support for openpty and forkpty
Jeremy Hyltonbdebd542000-09-05 18:28:54 +00002574
2575os.path -- fix semantics of os.path.commonprefix
2576
2577smtplib -- support for sending very long messages
2578
2579socket -- new function getfqdn()
2580
2581readline -- new functions to read, write and truncate history files.
2582The readline section of the library reference manual contains an
2583example.
2584
Jeremy Hylton24c3d602000-09-05 19:36:26 +00002585select -- add interface to poll system call
2586
Jeremy Hyltonbdebd542000-09-05 18:28:54 +00002587shutil -- new copyfileobj function
2588
2589SimpleHTTPServer, CGIHTTPServer -- Fix problems with buffering in the
2590HTTP server.
2591
Jeremy Hylton24c3d602000-09-05 19:36:26 +00002592Tkinter -- optimization of function flatten
Jeremy Hyltonbdebd542000-09-05 18:28:54 +00002593
2594urllib -- scans environment variables for proxy configuration,
Tim Peters8b092332000-09-05 20:15:25 +00002595e.g. http_proxy.
Jeremy Hyltonbdebd542000-09-05 18:28:54 +00002596
2597whichdb -- recognizes dumbdbm format
Guido van Rossume905e952000-09-05 12:42:46 +00002598
2599
2600Obsolete Modules
2601----------------
2602
2603None. However note that 1.6 made a whole slew of modules obsolete:
2604stdwin, soundex, cml, cmpcache, dircache, dump, find, grep, packmail,
2605poly, zmod, strop, util, whatsound.
2606
2607
2608Changed, New, Obsolete Tools
2609----------------------------
2610
Tim Peters8b092332000-09-05 20:15:25 +00002611None.
Guido van Rossume905e952000-09-05 12:42:46 +00002612
2613
Guido van Rossumf2ffce02000-09-05 04:38:34 +00002614C-level Changes
2615---------------
2616
2617Several cleanup jobs were carried out throughout the source code.
2618
2619All C code was converted to ANSI C; we got rid of all uses of the
2620Py_PROTO() macro, which makes the header files a lot more readable.
2621
2622Most of the portability hacks were moved to a new header file,
2623pyport.h; several other new header files were added and some old
2624header files were removed, in an attempt to create a more rational set
2625of header files. (Few of these ever need to be included explicitly;
2626they are all included by Python.h.)
2627
Guido van Rossumf2ffce02000-09-05 04:38:34 +00002628Trent Mick ensured portability to 64-bit platforms, under both Linux
Jeremy Hylton24c3d602000-09-05 19:36:26 +00002629and Win64, especially for the new Intel Itanium processor. Mick also
2630added large file support for Linux64 and Win64.
Guido van Rossumf2ffce02000-09-05 04:38:34 +00002631
Jeremy Hyltonbdebd542000-09-05 18:28:54 +00002632The C APIs to return an object's size have been update to consistently
2633use the form PyXXX_Size, e.g. PySequence_Size and PyDict_Size. In
2634previous versions, the abstract interfaces used PyXXX_Length and the
2635concrete interfaces used PyXXX_Size. The old names,
2636e.g. PyObject_Length, are still available for backwards compatibility
2637at the API level, but are deprecated.
2638
Jeremy Hylton24c3d602000-09-05 19:36:26 +00002639The PyOS_CheckStack function has been implemented on Windows by
2640Fredrik Lundh. It prevents Python from failing with a stack overflow
2641on Windows.
Jeremy Hyltonbdebd542000-09-05 18:28:54 +00002642
2643The GC changes resulted in creation of two new slots on object,
2644tp_traverse and tp_clear. The augmented assignment changes result in
Guido van Rossum4338a282000-09-06 13:02:08 +00002645the creation of a new slot for each in-place operator.
Jeremy Hyltonbdebd542000-09-05 18:28:54 +00002646
2647The GC API creates new requirements for container types implemented in
Guido van Rossum4338a282000-09-06 13:02:08 +00002648C extension modules. See Include/objimpl.h for details.
Jeremy Hyltonbdebd542000-09-05 18:28:54 +00002649
Jeremy Hylton24c3d602000-09-05 19:36:26 +00002650PyErr_Format has been updated to automatically calculate the size of
2651the buffer needed to hold the formatted result string. This change
2652prevents crashes caused by programmer error.
Jeremy Hyltonbdebd542000-09-05 18:28:54 +00002653
Jeremy Hylton24c3d602000-09-05 19:36:26 +00002654New C API calls: PyObject_AsFileDescriptor, PyErr_WriteUnraisable.
Guido van Rossume905e952000-09-05 12:42:46 +00002655
Jeremy Hylton24c3d602000-09-05 19:36:26 +00002656PyRun_AnyFileEx, PyRun_SimpleFileEx, PyRun_FileEx -- New functions
2657that are the same as their non-Ex counterparts except they take an
2658extra flag argument that tells them to close the file when done.
2659
2660XXX There were other API changes that should be fleshed out here.
Guido van Rossumab9d6f01998-08-10 22:01:13 +00002661
Tim Peters8b092332000-09-05 20:15:25 +00002662
2663Windows Changes
2664---------------
2665
2666New popen2/popen3/peopen4 in os module (see Changed Modules above).
2667
2668os.popen is much more usable on Windows 95 and 98. See Microsoft
2669Knowledge Base article Q150956. The Win9x workaround described there
2670is implemented by the new w9xpopen.exe helper in the root of your
2671Python installation. Note that Python uses this internally; it is not
2672a standalone program.
2673
2674Administrator privileges are no longer required to install Python
2675on Windows NT or Windows 2000. If you have administrator privileges,
2676Python's registry info will be written under HKEY_LOCAL_MACHINE.
2677Otherwise the installer backs off to writing Python's registry info
Guido van Rossum4338a282000-09-06 13:02:08 +00002678under HKEY_CURRENT_USER. The latter is sufficient for all "normal"
Tim Peters8b092332000-09-05 20:15:25 +00002679uses of Python, but will prevent some advanced uses from working
2680(for example, running a Python script as an NT service, or possibly
2681from CGI).
2682
2683[This was new in 1.6] The installer no longer runs a separate Tcl/Tk
2684installer; instead, it installs the needed Tcl/Tk files directly in the
2685Python directory. If you already have a Tcl/Tk installation, this
2686wastes some disk space (about 4 Megs) but avoids problems with
2687conflicting Tcl/Tk installations, and makes it much easier for Python
2688to ensure that Tcl/Tk can find all its files.
2689
2690[This was new in 1.6] The Windows installer now installs by default in
2691\Python20\ on the default volume, instead of \Program Files\Python-2.0\.
2692
Guido van Rossumf62ed9c2000-09-26 11:16:10 +00002693
2694Updates to the changes between 1.5.2 and 1.6
2695--------------------------------------------
2696
2697The 1.6 NEWS file can't be changed after the release is done, so here
2698is some late-breaking news:
2699
2700New APIs in locale.py: normalize(), getdefaultlocale(), resetlocale(),
2701and changes to getlocale() and setlocale().
2702
2703The new module is now enabled per default.
2704
2705It is not true that the encodings codecs cannot be used for normal
2706strings: the string.encode() (which is also present on 8-bit strings
2707!) allows using them for 8-bit strings too, e.g. to convert files from
2708cp1252 (Windows) to latin-1 or vice-versa.
2709
2710Japanese codecs are available from Tamito KAJIYAMA:
2711http://pseudo.grad.sccs.chukyo-u.ac.jp/~kajiyama/python/
2712
2713
Guido van Rossumab9d6f01998-08-10 22:01:13 +00002714======================================================================