summaryrefslogtreecommitdiffstats
path: root/Misc/NEWS
blob: 7da148aedd6b9a2a76419e03fd8319a647a1b6c3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
What's New in Python 2.0b2?
===========================

Below is a list of all relevant changes since release 1.6.  Older
changes are in the file HISTORY.  If you are making the jump directly
from Python 1.5.2 to 2.0, make sure to read the section for 1.6 in the
HISTORY file!  Many important changes listed there.

Alternatively, a good overview of the changes between 1.5.2 and 2.0 is
the document "What's New in Python 2.0" by Kuchling and Moshe Zadka:
http://starship.python.net/crew/amk/python/writing/new-python/.

--Guido van Rossum (home page: http://www.pythonlabs.com/~guido/)

======================================================================


What's new in 2.0 beta 2 (since beta 1)?
========================================

Core language, builtins, and interpreter

- Add support for unbounded ints in %d,i,y,x,X,o formats for string
  inter

- Add -h and -V flags to print the usage message and Python version
  number and exit immediately.polation.  

Standard library and extensions

- array: reverse method of array now works.  buffer_info now does
  argument checking; it still takes no arguments.

- asyncore/asynchat: included most recent version from Sam Rushing

- cgi: accept & or ; as separate characters when parsing form data

- CGIHTTPServer: now works on Windows (and perhaps even Mac).

- ConfigParser: When reading the file, options spelled in upper case
  letters are now accessible.

- copy: Copy Unicode objects atomically.

- cPickle: fails gracefully when copy_reg can't be imported

- cStringIO: implemented readlines method.

- dbm: Add set and setdefault methods to dbm object.  Add constant
  library to module that names the library used.  Better doc strings
  and argument checking.  Uses configure to determine which ndbm.h
  file to include; Berkeley DB's nbdm is now an option.

- distutils: Update to version 0.9.3.

- dl: Add several dl.RTLD_ constants.

- fpectl: Now supported on FreeBSD.

- gc: Add DEBUG_SAVEALL option.  When enabled all garbage objects
  found by the collector will be saved in gc.garbage.  This is useful
  for debugging a program that creates reference cycles.

- httplib: Three changes.  Restore support for set_debuglevel feature
  of HTTP class.  Do not close socket on zero-length response.  Do not
  crash when server sends invalid content-length header.

- mailbox: XXX conformance to maildir specification ???

- operator: Add contains, invert, __invert__ as aliases for
  __contains__, inv, and __inv__ respectively.

- os: Add support for popen2 and popen3 on all platforms where fork
  exists.  

- os: (Windows only) Add startfile function athat exposes part of
  Win32 ShellExecute functionality.

- os.path: (NT, DOS) Treat trailing colon correctly in os.path.join.
  os.path.join("a:", "b") yields "a:b".

- pickle: Now raises ValueError when an invalid pickle that contains
  a non-string repr where a string repr was expected.  This behavior
  matches cPickle.

- posixfile: XXX remove __del__ method ???

- py_compile: support \r in source file

- readline: Does not immediately exit when ^C is hit when readline and
  threads are configured.  Adds defintion of rl_library_version.

- rfc822: Domain literals returned by AddrlistClass method
  getdomainliteral are now properly wrapped in brackets.

- site: sys.setdefaultencoding() should only be called in case the
  standard default encoding ("ascii") is changed. This safes quite a
  few cycles during startup since the first call to
  setdefaultencoding() will initialize the codec registry and the
  encodings package.

- socket: Support for size hint in readlines method of object returned
  by makefile.

- sre: Added experimental expand method to match objects.  Does not
  user buffer interface on Unicode strings.  Does not hang if group id
  is followed by whitespace.

- StringIO: size hint in readlines is now supported as documented. 

- struct: Check ranges for bytes and shorts.

- urllib: Improved handling of win32 proxy settings. Fixed quote and
  quote_plus functions so that the always encode a comma ','.

- Tkinter: Image objects are now guaranteed to have unique ids.  Set
  event.delta to zero if Tk version doesn't support mousewheel.
  Removed some debugging prints.

- UserList: now implements __contains__.

- webbrower: On Windows, use os.startfile instead of os.popen, which
  works around a bug in certain versions of Norton AntiVirus that
  leads directly to a Blue Screen.

- xml: New version detection code allows PyXML to override standard
  XML package if PyXML version is greater than 0.6.1.

- xml.dom: XXX

- xml.sax: XXX

- XXX pyexpat: XXX

C API

- Add three new convenience functions for module initialization --
  PyModule_AddObject(), PyModule_AddIntConstant(), and
  PyModule_AddStringConstant().

- Cleaned up definition of NULL in C source code; all defintions were
  removed and add #error to Python.h if NULL isn't defined after
  #include of stdio.h.

- Py_PROTO macros that were removed in 2.0b1 have been restored for
  backwards compatibility (at the source level) with old extensions.

- XXX PyOS_sighandler_t, PyOS_getsig, PyOS_setsig

- Add PyString_AsStringAndSize call that provides access to the
  internal data buffer and size of a string object -- or the default
  encoded version of a Unicode object.

Internals

- On Unix, fix code for finding Python installation directory so that
  it works when argv[0] is a relative path.

- Added a true unicode_internal_encode function and fixed the
  unicode_internal_decode function to support Unicode objects directly
  rather than by generating a copy of the object.

- XXX Unicode database compression

Build and platform-specific issues

- Better support of GNU Pth via --with-pth configure option.

- Fix linker problems on Reliant UNIX

- Changes for the benefit of SunOS 4.1.4 (really!).  mmapmodule.c:
  Don't define MS_SYNC to be zero when it is undefined.  Added missing
  prototypes in posixmodule.c.

- Improved support for HP-UX build


What's new in 2.0 beta 1?
=========================

Source Incompatibilities
------------------------

None.  Note that 1.6 introduced several incompatibilities with 1.5.2,
such as single-argument append(), connect() and bind(), and changes to
str(long) and repr(float).


Binary Incompatibilities
------------------------

- Third party extensions built for Python 1.5.x or 1.6 cannot be used
with Python 2.0; these extensions will have to be rebuilt for Python
2.0.

- On Windows, attempting to import a third party extension built for
Python 1.5.x or 1.6 results in an immediate crash; there's not much we
can do about this.  Check your PYTHONPATH environment variable!

- Python bytecode files (*.pyc and *.pyo) are not compatible between
releases.


Overview of Changes Since 1.6
-----------------------------

There are many new modules (including brand new XML support through
the xml package, and i18n support through the gettext module); a list
of all new modules is included below.  Lots of bugs have been fixed.

The process for making major new changes to the language has changed
since Python 1.6.  Enhancements must now be documented by a Python
Enhancement Proposal (PEP) before they can be accepted.

There are several important syntax enhancements, described in more
detail below:

  - Augmented assignment, e.g. x += 1

  - List comprehensions, e.g. [x**2 for x in range(10)]

  - Extended import statement, e.g. import Module as Name

  - Extended print statement, e.g. print >> file, "Hello"

Other important changes:

  - Optional collection of cyclical garbage

Python Enhancement Proposal (PEP)
---------------------------------

PEP stands for Python Enhancement Proposal.  A PEP is a design
document providing information to the Python community, or describing
a new feature for Python.  The PEP should provide a concise technical
specification of the feature and a rationale for the feature.

We intend PEPs to be the primary mechanisms for proposing new
features, for collecting community input on an issue, and for
documenting the design decisions that have gone into Python.  The PEP
author is responsible for building consensus within the community and
documenting dissenting opinions.

The PEPs are available at http://python.sourceforge.net/peps/.

Augmented Assignment
--------------------

This must have been the most-requested feature of the past years!
Eleven new assignment operators were added:

    += -= *= /= %= **= <<= >>= &= ^= |=

For example,

    A += B

is similar to

    A = A + B

except that A is evaluated only once (relevant when A is something
like dict[index].attr).

However, if A is a mutable object, A may be modified in place.  Thus,
if A is a number or a string, A += B has the same effect as A = A+B
(except A is only evaluated once); but if a is a list, A += B has the
same effect as A.extend(B)!

Classes and built-in object types can override the new operators in
order to implement the in-place behavior; the not-in-place behavior is
used automatically as a fallback when an object doesn't implement the
in-place behavior.  For classes, the method name is derived from the
method name for the corresponding not-in-place operator by inserting
an 'i' in front of the name, e.g. __iadd__ implements in-place
__add__.

Augmented assignment was implemented by Thomas Wouters.


List Comprehensions
-------------------

This is a flexible new notation for lists whose elements are computed
from another list (or lists).  The simplest form is:

    [<expression> for <variable> in <sequence>]

For example, [i**2 for i in range(4)] yields the list [0, 1, 4, 9].
This is more efficient than map() with a lambda.

You can also add a condition:

    [<expression> for <variable> in <sequence> if <condition>]

For example, [w for w in words if w == w.lower()] would yield the list
of words that contain no uppercase characters.  This is more efficient
than filter() with a lambda.

You can also have nested for loops and more than one 'if' clause.  For
example, here's a function that flattens a sequence of sequences::

    def flatten(seq):
        return [x for subseq in seq for x in subseq]

    flatten([[0], [1,2,3], [4,5], [6,7,8,9], []])

This prints

    [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]

List comprehensions originated as a patch set from Greg Ewing; Skip
Montanaro and Thomas Wouters also contributed.  Described by PEP 202.


Extended Import Statement
-------------------------

Many people have asked for a way to import a module under a different
name.  This can be accomplished like this:

    import foo
    bar = foo
    del foo

but this common idiom gets old quickly.  A simple extension of the
import statement now allows this to be written as follows:

    import foo as bar

There's also a variant for 'from ... import':

    from foo import bar as spam

This also works with packages; e.g. you can write this:

    import test.regrtest as regrtest

Note that 'as' is not a new keyword -- it is recognized only in this
context (this is only possible because the syntax for the import
statement doesn't involve expressions).

Implemented by Thomas Wouters.  Described by PEP 221.


Extended Print Statement
------------------------

Easily the most controversial new feature, this extension to the print
statement adds an option to make the output go to a different file
than the default sys.stdout.

For example, to write an error message to sys.stderr, you can now
write:

    print >> sys.stderr, "Error: bad dog!"

As a special feature, if the expression used to indicate the file
evaluates to None, the current value of sys.stdout used.  Thus:

    print >> None, "Hello world"

is equivalent to

    print "Hello world"

Design and implementation by Barry Warsaw.  Described by PEP 214.


Optional Collection of Cyclical Garbage
---------------------------------------

Python is now equipped with a garbage collector that can hunt down
cyclical references between Python objects.  It's no replacement for
reference counting; in fact, it depends on the reference counts being
correct, and decides that a set of objects belong to a cycle if all
their reference counts can be accounted for from their references to
each other.  This devious scheme was first proposed by Eric Tiedemann,
and brought to implementation by Neil Schemenauer.

There's a module "gc" that lets you control some parameters of the
garbage collection.  There's also an option to the configure script
that lets you enable or disable the garbage collection.  In 2.0b1,
it's on by default, so that we (hopefully) can collect decent user
experience with this new feature.  There are some questions about its
performance.  if it proves to be too much of a problem, we'll turn it
off by default in the final 2.0 release.


Smaller Changes
---------------

A new function zip() was added.  zip(seq1, seq2, ...) is equivalent to
map(None, seq1, seq2, ...) when the sequences have the same length;
i.e. zip([1,2,3], [10,20,30]) returns [(1,10), (2,20), (3,30)].  When
the lists are not all the same length, the shortest list wins:
zip([1,2,3], [10,20]) returns [(1,10), (2,20)].  See PEP 201.

sys.version_info is a tuple (major, minor, micro, level, serial).

Dictionaries have an odd new method, setdefault(key, default).
dict.setdefault(key, default) returns dict[key] if it exists; if not,
it sets dict[key] to default and returns that value.  Thus:

    dict.setdefault(key, []).append(item)

does the same work as this common idiom:

    if not dict.has_key(key):
        dict[key] = []
    dict[key].append(item)

There are two new variants of SyntaxError that are raised for
indentation-related errors: IndentationError and TabError.

Changed \x to consume exactly two hex digits; see PEP 223.  Added \U
escape that consumes exactly eight hex digits.

The limits on the size of expressions and file in Python source code
have been raised from 2**16 to 2**32.  Previous versions of Python
were limited because the maximum argument size the Python VM accepted
was 2**16.  This limited the size of object constructor expressions,
e.g. [1,2,3] or {'a':1, 'b':2}, and the size of source files.  This
limit was raised thanks to a patch by Charles Waldman that effectively
fixes the problem.  It is now much more likely that you will be
limited by available memory than by an arbitrary limit in Python.

The interpreter's maximum recursion depth can be modified by Python
programs using sys.getrecursionlimit and sys.setrecursionlimit.  This
limit is the maximum number of recursive calls that can be made by
Python code.  The limit exists to prevent infinite recursion from
overflowing the C stack and causing a core dump.  The default value is
1000.  The maximum safe value for a particular platform can be found
by running Misc/find_recursionlimit.py.

New Modules and Packages
------------------------

atexit - for registering functions to be called when Python exits.

imputil - Greg Stein's alternative API for writing custom import
hooks.

pyexpat - an interface to the Expat XML parser, contributed by Paul
Prescod.

xml - a new package with XML support code organized (so far) in three
subpackages: xml.dom, xml.sax, and xml.parsers.  Describing these
would fill a volume.  There's a special feature whereby a
user-installed package named _xmlplus overrides the standard
xmlpackage; this is intended to give the XML SIG a hook to distribute
backwards-compatible updates to the standard xml package.

webbrowser - a platform-independent API to launch a web browser.


Changed Modules
---------------

array -- new methods for array objects: count, extend, index, pop, and
remove

binascii -- new functions b2a_hex and a2b_hex that convert between
binary data and its hex representation

calendar -- Many new functions that support features including control
over which day of the week is the first day, returning strings instead
of printing them.  Also new symbolic constants for days of week,
e.g. MONDAY, ..., SUNDAY.

cgi -- FieldStorage objects have a getvalue method that works like a
dictionary's get method and returns the value attribute of the object.

ConfigParser -- The parser object has new methods has_option,
remove_section, remove_option, set, and write.  They allow the module
to be used for writing config files as well as reading them.

ftplib -- ntransfercmd(), transfercmd(), and retrbinary() all now
optionally support the RFC 959 REST command.

gzip -- readline and readlines now accept optional size arguments

httplib -- New interfaces and support for HTTP/1.1 by Greg Stein.  See
the module doc strings for details.

locale -- implement getdefaultlocale for Win32 and Macintosh

marshal -- no longer dumps core when marshaling deeply nested or
recursive data structures

os -- new functions isatty, seteuid, setegid, setreuid, setregid

os/popen2 -- popen2/popen3/popen4 support under Windows.  popen2/popen3
support under Unix.

os/pty -- support for openpty and forkpty

os.path -- fix semantics of os.path.commonprefix

smtplib -- support for sending very long messages

socket -- new function getfqdn()

readline -- new functions to read, write and truncate history files.
The readline section of the library reference manual contains an
example.

select -- add interface to poll system call

shutil -- new copyfileobj function

SimpleHTTPServer, CGIHTTPServer -- Fix problems with buffering in the
HTTP server.

Tkinter -- optimization of function flatten

urllib -- scans environment variables for proxy configuration,
e.g. http_proxy.

whichdb -- recognizes dumbdbm format


Obsolete Modules
----------------

None.  However note that 1.6 made a whole slew of modules obsolete:
stdwin, soundex, cml, cmpcache, dircache, dump, find, grep, packmail,
poly, zmod, strop, util, whatsound.


Changed, New, Obsolete Tools
----------------------------

None.


C-level Changes
---------------

Several cleanup jobs were carried out throughout the source code.

All C code was converted to ANSI C; we got rid of all uses of the
Py_PROTO() macro, which makes the header files a lot more readable.

Most of the portability hacks were moved to a new header file,
pyport.h; several other new header files were added and some old
header files were removed, in an attempt to create a more rational set
of header files.  (Few of these ever need to be included explicitly;
they are all included by Python.h.)

Trent Mick ensured portability to 64-bit platforms, under both Linux
and Win64, especially for the new Intel Itanium processor.  Mick also
added large file support for Linux64 and Win64.

The C APIs to return an object's size have been update to consistently
use the form PyXXX_Size, e.g. PySequence_Size and PyDict_Size.  In
previous versions, the abstract interfaces used PyXXX_Length and the
concrete interfaces used PyXXX_Size.  The old names,
e.g. PyObject_Length, are still available for backwards compatibility
at the API level, but are deprecated.

The PyOS_CheckStack function has been implemented on Windows by
Fredrik Lundh.  It prevents Python from failing with a stack overflow
on Windows.

The GC changes resulted in creation of two new slots on object,
tp_traverse and tp_clear.  The augmented assignment changes result in
the creation of a new slot for each in-place operator.

The GC API creates new requirements for container types implemented in
C extension modules.  See Include/objimpl.h for details.

PyErr_Format has been updated to automatically calculate the size of
the buffer needed to hold the formatted result string.  This change
prevents crashes caused by programmer error.

New C API calls: PyObject_AsFileDescriptor, PyErr_WriteUnraisable.

PyRun_AnyFileEx, PyRun_SimpleFileEx, PyRun_FileEx -- New functions
that are the same as their non-Ex counterparts except they take an
extra flag argument that tells them to close the file when done.

XXX There were other API changes that should be fleshed out here.


Windows Changes
---------------

New popen2/popen3/peopen4 in os module (see Changed Modules above).

os.popen is much more usable on Windows 95 and 98.  See Microsoft
Knowledge Base article Q150956.  The Win9x workaround described there
is implemented by the new w9xpopen.exe helper in the root of your
Python installation.  Note that Python uses this internally; it is not
a standalone program.

Administrator privileges are no longer required to install Python
on Windows NT or Windows 2000.  If you have administrator privileges,
Python's registry info will be written under HKEY_LOCAL_MACHINE.
Otherwise the installer backs off to writing Python's registry info
under HKEY_CURRENT_USER.  The latter is sufficient for all "normal"
uses of Python, but will prevent some advanced uses from working
(for example, running a Python script as an NT service, or possibly
from CGI).

[This was new in 1.6] The installer no longer runs a separate Tcl/Tk
installer; instead, it installs the needed Tcl/Tk files directly in the
Python directory.  If you already have a Tcl/Tk installation, this
wastes some disk space (about 4 Megs) but avoids problems with
conflicting Tcl/Tk installations, and makes it much easier for Python
to ensure that Tcl/Tk can find all its files.

[This was new in 1.6] The Windows installer now installs by default in
\Python20\ on the default volume, instead of \Program Files\Python-2.0\.

======================================================================