NEWS 92.8 KB
Newer Older
1 2 3 4 5
What's New in Python 2.2a3?
===========================

Core

6 7 8
- Conversion of long to float now raises OverflowError if the long is too
  big to represent as a C double.

9 10 11 12 13 14
- The 3-argument builtin pow() no longer allows a third non-None argument
  if either of the first two arguments is a float, or if both are of
  integer types and the second argument is negative (in which latter case
  the arguments are converted to float, so this is really the same
  restriction).

15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
- The builtin dir() now returns more information, and sometimes much
  more, generally naming all attributes of an object, and all attributes
  reachable from the object via its class, and from its class's base
  classes, and so on from them too.  Example:  in 2.2a2, dir([]) returned
  an empty list.  In 2.2a3,

  >>> dir([])
  ['__add__', '__class__', '__contains__', '__delattr__', '__delitem__',
   '__eq__', '__ge__', '__getattr__', '__getitem__', '__getslice__',
   '__gt__', '__hash__', '__iadd__', '__imul__', '__init__', '__le__',
   '__len__', '__lt__', '__mul__', '__ne__', '__new__', '__repr__',
   '__rmul__', '__setattr__', '__setitem__', '__setslice__', '__str__',
   'append', 'count', 'extend', 'index', 'insert', 'pop', 'remove',
   'reverse', 'sort']

  dir(module) continues to return only the module's attributes, though.

32
- Overflowing operations on plain ints now return a long int rather
33 34 35 36 37
  than raising OverflowError.  This is a partial implementation of PEP
  237.  You can use -Wdefault::OverflowWarning to enable a warning for
  this situation, and -Werror::OverflowWarning to revert to the old
  OverflowError exception.

38
- A new command line option, -Q<arg>, is added to control run-time
39
  warnings for the use of classic division.  (See PEP 238.)  Possible
40
  values are -Qold, -Qwarn, and -Qnew.  The default is -Qold, meaning
41
  the / operator has its classic meaning and no warnings are issued.
42 43
  Using -Qwarn issues a run-time warning about all uses of classic
  division for int, long, float and complex arguments.  Using -Qnew is
44
  questionable; it turns on new division by default, but only in the
45
  __main__ module.  You can usefully combine -Qwarn and -Qnew: this
46 47 48
  gives the __main__ module new division, and warns about classic
  division everywhere else.

49
- Many built-in types can now be subclassed.  This applies to int,
50 51 52 53 54 55 56 57 58
  long, float, str, unicode, and tuple.  (The types complex, list and
  dictionary can also be subclassed; this was introduced earlier.)
  Note that restrictions apply when subclassing immutable built-in
  types: you can only affect the value of the instance by overloading
  __new__.  You can add mutable attributes, and the subclass instances
  will have a __dict__ attribute, but you cannot change the "value"
  (as implemented by the base class) of an immutable subclass instance
  once it is created.

59 60 61 62
- The dictionary constructor now takes an optional argument, a
  mapping-like object, and initializes the dictionary from its
  (key, value) pairs.

63
- A new built-in type, super, has been added.  This facilitates making
64 65 66
  "cooperative super calls" in a multiple inheritance setting.  For an
  explanation, see http://www.python.org/2.2/descrintro.html#cooperation

67
- A new built-in type, getset, has been added.  This enables the
68 69 70 71 72
  creation of "computed attributes".  Such attributes are implemented
  by getter and setter functions (or only one of these for read-only
  or write-only attributes), without the need to override
  __getattr__.  See http://www.python.org/2.2/descrintro.html#getset

73
- The syntax of floating-point and imaginary literals has been
74 75 76 77 78
  liberalized, to allow leading zeroes.  Examples of literals now
  legal that were SyntaxErrors before:

      00.0    0e3   0100j   07.5   00000000000000000008.

79
- An old tokenizer bug allowed floating point literals with an incomplete
80 81
  exponent, such as 1e and 3.1e-.  Such literals now raise SyntaxError.

82 83
Library

84 85 86
- telnetlib includes symbolic names for the options, and support for
  setting an option negotiation callback.

87 88 89 90 91 92 93
- The new C standard no longer requires that math libraries set errno to
  ERANGE on overflow.  For platform libraries that exploit this new
  freedom, Python's overflow-checking was wholly broken.  A new overflow-
  checking scheme attempts to repair that, but may not be reliable on all
  platforms (C doesn't seem to provide anything both useful and portable
  in this area anymore).

94 95 96
- Asynchronous timeout actions are available through the new class
  threading.Timer.

97 98 99
- math.log and math.log10 now return sensible results for even huge
  long arguments.  For example, math.log10(10 ** 10000) ~= 10000.0.

100
- A new function, imp.lock_held(), returns 1 when the import lock is
101 102
  currently held.  See the docs for the imp module.

103
- pickle, cPickle and marshal on 32-bit platforms can now correctly read
104 105 106 107
  dumps containing ints written on platforms where Python ints are 8 bytes.
  When read on a box where Python ints are 4 bytes, such values are
  converted to Python longs.

108
- In restricted execution mode (using the rexec module), unmarshalling
109 110
  code objects is no longer allowed.  This plugs a security hole.

111 112 113 114
Tools

Build

115 116 117
C API

- New function PyObject_Dir(obj), like Python __builtin__.dir(obj).
118

119 120 121 122 123 124 125 126 127
- Note that PyLong_AsDouble can fail!  This has always been true, but no
  callers checked for it.  It's more likely to fail now, because overflow
  errors are properly detected now.  The proper way to check:

  double x = PyLong_AsDouble(some_long_object);
  if (x == -1.0 && PyErr_Occurred()) {
          /* The conversion failed. */
  }

128
- The GC API has been changed.  Extensions that use the old API will still
129 130 131 132
  compile but will not participate in GC.  To upgrade an extension
  module:

    - rename Py_TPFLAGS_GC to PyTPFLAGS_HAVE_GC
133

134 135
    - use PyObject_GC_New or PyObject_GC_NewVar to allocate objects and
      PyObject_GC_Del to deallocate them
136

137 138
    - rename PyObject_GC_Init to PyObject_GC_Track and PyObject_GC_Fini
      to PyObject_GC_UnTrack
139

140 141 142 143
    - remove PyGC_HEAD_SIZE from object size calculations

    - remove calls to PyObject_AS_GC and PyObject_FROM_GC

144
- Two new functions: PyString_FromFormat() and PyString_FromFormatV().
145 146 147
  These can be used safely to construct string objects from a
  sprintf-style format string (similar to the format string supported
  by PyErr_Format()).
148

149 150
New platforms

151 152 153 154 155
- Stephen Hansen contributed patches sufficient to get a clean compile
  under Borland C (Windows), but he reports problems running it and ran
  out of time to complete the port.  Volunteers?  Expect a MemoryError
  when importing the types module; this is probably shallow, and
  causing later failures too.
156

157 158 159 160
Tests

Windows

161 162 163 164 165 166
- Large file support is now enabled on Win32 platforms as well as on
  Win64.  This means that, for example, you can use f.tell() and f.seek()
  to manipulate files larger than 2 gigabytes (provided you have enough
  disk space, and are using a Windows filesystem that supports large
  partitions).

167
- The w9xpopen hack is now used on Windows NT and 2000 too when COMPSPEC
168 169
  points to command.com (patch from Brian Quinlan).

170

Tim Peters's avatar
Tim Peters committed
171 172 173
What's New in Python 2.2a2?
===========================

174 175
Build

176 177 178
- Tim Peters developed a brand new Windows installer using Wise 8.1,
  generously donated to us by Wise Solutions.

179 180 181
- configure supports a new option --enable-unicode, with the values
  ucs2 and ucs4 (new in 2.2a1). With --disable-unicode, the Unicode
  type and supporting code is completely removed from the interpreter.
Barry Warsaw's avatar
Barry Warsaw committed
182

183 184 185 186
- A new configure option --enable-framework builds a Mac OS X framework,
  which "make frameworkinstall" will install. This provides a starting
  point for more mac-like functionality, join pythonmac-sig@python.org
  if you are interested in helping.
187

Barry Warsaw's avatar
Barry Warsaw committed
188 189 190 191
- The NeXT platform is no longer supported.

- The `new' module is now statically linked.

192 193 194
Tools

- The new Tools/scripts/cleanfuture.py can be used to automatically
Andrew M. Kuchling's avatar
Andrew M. Kuchling committed
195
  edit out obsolete future statements from Python source code.  See
196 197
  the module docstring for details.

Tim Peters's avatar
Tim Peters committed
198 199
Tests

200
- regrtest.py now knows which tests are expected to be skipped on some
Barry Warsaw's avatar
Barry Warsaw committed
201 202 203
  platforms, allowing to give clearer test result output.  regrtest
  also has optional --use/-u switch to run normally disabled tests
  which require network access or consume significant disk resources.
204

Tim Peters's avatar
Tim Peters committed
205 206 207 208 209
- Several new tests in the standard test suite, with special thanks to
  Nick Mathewson.

Core

Barry Warsaw's avatar
Barry Warsaw committed
210 211 212 213 214 215 216 217 218
- The floor division operator // has been added as outlined in PEP
  238.  The / operator still provides classic division (and will until
  Python 3.0) unless "from __future__ import division" is included, in
  which case the / operator will provide true division.  The operator
  module provides truediv() and floordiv() functions.  Augmented
  assignment variants are included, as are the equivalent overloadable
  methods and C API methods.  See the PEP for a full discussion:
  <http://python.sf.net/peps/pep-0238.html>

219 220 221 222 223
- Future statements are now effective in simulated interactive shells
  (like IDLE).  This should "just work" by magic, but read Michael
  Hudson's "Future statements in simulated shells" PEP 264 for full
  details:  <http://python.sf.net/peps/pep-0264.html>.

224 225 226 227 228 229
- The type/class unification (PEP 252-253) was integrated into the
  trunk and is not so tentative any more (the exact specification of
  some features is still tentative).  A lot of work has done on fixing
  bugs and adding robustness and features (performance still has to
  come a long way).

Marc-André Lemburg's avatar
Marc-André Lemburg committed
230 231 232 233
- Warnings about a mismatch in the Python API during extension import
  now use the Python warning framework (which makes it possible to
  write filters for these warnings).

234 235 236 237 238 239
- A function's __dict__ (aka func_dict) will now always be a
  dictionary.  It used to be possible to delete it or set it to None,
  but now both actions raise TypeErrors.  It is still legal to set it
  to a dictionary object.  Getting func.__dict__ before any attributes
  have been assigned now returns an empty dictionary instead of None.

240 241 242 243 244 245 246
- A new command line option, -E, was added which disables the use of
  all environment variables, or at least those that are specifically
  significant to Python.  Usually those have a name starting with
  "PYTHON".  This was used to fix a problem where the tests fail if
  the user happens to have PYTHONHOME or PYTHONPATH pointing to an
  older distribution.

247 248
Library

249 250
- New class Differ and new functions ndiff() and restore() in difflib.py.
  These package the algorithms used by the popular Tools/scripts/ndiff.py,
251
  for programmatic reuse.
252

253 254 255 256 257 258
- New function xml.sax.saxutils.quoteattr():  Quote an XML attribute
  value using the minimal quoting required for the value; more
  reliable than using xml.sax.saxutils.escape() for attribute values.

- Readline completion support for cmd.Cmd was added.

Barry Warsaw's avatar
Barry Warsaw committed
259 260 261 262 263 264 265 266
- Calling os.tempnam() or os.tmpnam() generate RuntimeWarnings.

- Added function threading.BoundedSemaphore()

- Added Ka-Ping Yee's cgitb.py module.

- The `new' module now exposes the CO_xxx flags.

267 268 269 270
New platforms

C API

Marc-André Lemburg's avatar
Marc-André Lemburg committed
271 272 273 274 275 276 277
- Two new APIs PyOS_snprintf() and PyOS_vsnprintf() were added
  which provide a cross-platform implementations for the
  relatively new snprintf()/vsnprintf() C lib APIs. In contrast to
  the standard sprintf() and vsprintf() C lib APIs, these versions
  apply bounds checking on the used buffer which enhances protection
  against buffer overruns.

278
- Unicode APIs now use name mangling to assure that mixing interpreters
279 280
  and extensions using different Unicode widths is rendered next to
  impossible. Trying to import an incompatible Unicode-aware extension
281 282 283 284
  will result in an ImportError.  Unicode extensions writers must make
  sure to check the Unicode width compatibility in their extensions by
  using at least one of the mangled Unicode APIs in the extension.

285 286 287 288 289 290
- Two new flags METH_NOARGS and METH_O are available in method definition
  tables to simplify implementation of methods with no arguments and a
  single untyped argument. Calling such methods is more efficient than
  calling corresponding METH_VARARGS methods. METH_OLDARGS is now
  deprecated.

291 292 293 294 295
Windows

- "import module" now compiles module.pyw if it exists and nothing else
  relevant is found.

Tim Peters's avatar
Tim Peters committed
296

297
What's New in Python 2.2a1?
298 299 300
===========================

Core
301

302 303 304 305 306 307 308 309 310 311 312
- TENTATIVELY, a large amount of code implementing much of what's
  described in PEP 252 (Making Types Look More Like Classes) and PEP
  253 (Subtyping Built-in Types) was added.  This will be released
  with Python 2.2a1.  Documentation will be provided separately
  through http://www.python.org/2.2/.  The purpose of releasing this
  with Python 2.2a1 is to test backwards compatibility.  It is
  possible, though not likely, that a decision is made not to release
  this code as part of 2.2 final, if any serious backwards
  incompapatibilities are found during alpha testing that cannot be
  repaired.

313
- Generators were added; this is a new way to create an iterator (see
Tim Peters's avatar
Tim Peters committed
314
  below) using what looks like a simple function containing one or
315 316 317 318 319 320 321 322 323
  more 'yield' statements.  See PEP 255.  Since this adds a new
  keyword to the language, this feature must be enabled by including a
  future statement: "from __future__ import generators" (see PEP 236).
  Generators will become a standard feature in a future release
  (probably 2.3).  Without this future statement, 'yield' remains an
  ordinary identifier, but a warning is issued each time it is used.
  (These warnings currently don't conform to the warnings framework of
  PEP 230; we intend to fix this in 2.2a2.)

324 325 326 327 328
- The UTF-16 codec was modified to be more RFC compliant. It will now
  only remove BOM characters at the start of the string and then
  only if running in native mode (UTF-16-LE and -BE won't remove a
  leading BMO character).

329 330 331 332 333 334 335
- Strings now have a new method .decode() to complement the already
  existing .encode() method. These two methods provide direct access
  to the corresponding decoders and encoders of the registered codecs.

  To enhance the usability of the .encode() method, the special
  casing of Unicode object return values was dropped (Unicode objects
  were auto-magically converted to string using the default encoding).
336

337 338 339 340 341 342 343 344 345 346 347 348 349
  Both methods will now return whatever the codec in charge of the
  requested encoding returns as object, e.g. Unicode codecs will
  return Unicode objects when decoding is requested ("äöü".decode("latin-1")
  will return u"äöü"). This enables codec writer to create codecs
  for various simple to use conversions.

  New codecs were added to demonstrate these new features (the .encode()
  and .decode() columns indicate the type of the returned objects):

  Name     | .encode() | .decode() | Description
  ----------------------------------------------------------------------
  uu       | string    | string    | UU codec (e.g. for email)
  base64   | string    | string    | base64 codec
Guido van Rossum's avatar
Guido van Rossum committed
350
  quopri   | string    | string    | quoted-printable codec
351 352 353 354
  zlib     | string    | string    | zlib compression
  hex      | string    | string    | 2-byte hex codec
  rot-13   | string    | Unicode   | ROT-13 Unicode charmap codec

355 356 357
- Some operating systems now support the concept of a default Unicode
  encoding for file system operations.  Notably, Windows supports 'mbcs'
  as the default.  The Macintosh will also adopt this concept in the medium
358
  term, although the default encoding for that platform will be other than
359
  'mbcs'.
360 361

  On operating system that support non-ASCII filenames, it is common for
362 363 364 365 366
  functions that return filenames (such as os.listdir()) to return Python
  string objects pre-encoded using the default file system encoding for
  the platform.  As this encoding is likely to be different from Python's
  default encoding, converting this name to a Unicode object before passing
  it back to the Operating System would result in a Unicode error, as Python
367 368
  would attempt to use its default encoding (generally ASCII) rather than
  the default encoding for the file system.
369

370 371 372
  In general, this change simply removes surprises when working with
  Unicode and the file system, making these operations work as you expect,
  increasing the transparency of Unicode objects in this context.
373
  See [????] for more details, including examples.
374

375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394
- Float (and complex) literals in source code were evaluated to full
  precision only when running from a .py file; the same code loaded from a
  .pyc (or .pyo) file could suffer numeric differences starting at about the
  12th significant decimal digit.  For example, on a machine with IEEE-754
  floating arithmetic,

      x = 9007199254740992.0
      print long(x)

  printed 9007199254740992 if run directly from .py, but 9007199254740000
  if from a compiled (.pyc or .pyo) file.  This was due to marshal using
  str(float) instead of repr(float) when building code objects.  marshal
  now uses repr(float) instead, which should reproduce floats to full
  machine precision (assuming the platform C float<->string I/O conversion
  functions are of good quality).

  This may cause floating-point results to change in some cases, and
  usually for the better, but may also cause numerically unstable
  algorithms to break.

395 396 397 398 399 400 401 402 403 404
- The implementation of dicts suffers fewer collisions, which has speed
  benefits.  However, the order in which dict entries appear in dict.keys(),
  dict.values() and dict.items() may differ from previous releases for a
  given dict.  Nothing is defined about this order, so no program should
  rely on it.  Nevertheless, it's easy to write test cases that rely on the
  order by accident, typically because of printing the str() or repr() of a
  dict to an "expected results" file.  See Lib/test/test_support.py's new
  sortdict(dict) function for a simple way to display a dict in sorted
  order.

405 406 407
- Many other small changes to dicts were made, resulting in faster
  operation along the most common code paths.

408 409 410
- Dictionary objects now support the "in" operator: "x in dict" means
  the same as dict.has_key(x).

411 412 413 414 415
- The update() method of dictionaries now accepts generic mapping
  objects.  Specifically the argument object must support the .keys()
  and __getitem__() methods.  This allows you to say, for example,
  {}.update(UserDict())

416 417 418 419 420 421 422 423 424
- Iterators were added; this is a generalized way of providing values
  to a for loop.  See PEP 234.  There's a new built-in function iter()
  to return an iterator.  There's a new protocol to get the next value
  from an iterator using the next() method (in Python) or the
  tp_iternext slot (in C).  There's a new protocol to get iterators
  using the __iter__() method (in Python) or the tp_iter slot (in C).
  Iterating (i.e. a for loop) over a dictionary generates its keys.
  Iterating over a file generates its lines.

425 426
- The following functions were generalized to work nicely with iterator
  arguments:
427
    map(), filter(), reduce(), zip()
428 429
    list(), tuple() (PySequence_Tuple() and PySequence_Fast() in C API)
    max(), min()
430 431
    join() method of strings
    extend() method of lists
432 433
    'x in y' and 'x not in y' (PySequence_Contains() in C API)
    operator.countOf() (PySequence_Count() in C API)
434 435
    right-hand side of assignment statements with multiple targets, such as
        x, y, z = some_iterable_object_returning_exactly_3_values
436

437 438 439
- Accessing module attributes is significantly faster (for example,
  random.random or os.path or yourPythonModule.yourAttribute).

440 441 442
- Comparing dictionary objects via == and != is faster, and now works even
  if the keys and values don't support comparisons other than ==.

443 444 445 446 447
- Comparing dictionaries in ways other than == and != is slower:  there were
  insecurities in the dict comparison implementation that could cause Python
  to crash if the element comparison routines for the dict keys and/or
  values mutated the dicts.  Making the code bulletproof slowed it down.

448 449
- Collisions in dicts are resolved via a new approach, which can help
  dramatically in bad cases.  For example, looking up every key in a dict
450
  d with d.keys() == [i << 16 for i in range(20000)] is approximately 500x
451 452
  faster now.  Thanks to Christian Tismer for pointing out the cause and
  the nature of an effective cure (last December! better late than never).
453

454 455 456
- repr() is much faster for large containers (dict, list, tuple).


457 458
Library

459 460 461 462 463
- The constants ascii_letters, ascii_lowercase. and ascii_uppercase
  were added to the string module.  These a locale-indenpendent
  constants, unlike letters, lowercase, and uppercase.  These are now
  use in appropriate locations in the standard library.

464 465 466
- The flags used in dlopen calls can now be configured using
  sys.setdlopenflags and queried using sys.getdlopenflags.

Guido van Rossum's avatar
Guido van Rossum committed
467 468 469 470 471
- Fredrik Lundh's xmlrpclib is now a standard library module.  This
  provides full client-side XML-RPC support.  In addition,
  Demo/xmlrpc/ contains two server frameworks (one SocketServer-based,
  one asyncore-based).  Thanks to Eric Raymond for the documentation.

Guido van Rossum's avatar
Guido van Rossum committed
472 473 474 475
- The xrange() object is simplified: it no longer supports slicing,
  repetition, comparisons, efficient 'in' checking, the tolist()
  method, or the start, stop and step attributes.  See PEP 260.

Martin v. Löwis's avatar
Martin v. Löwis committed
476 477
- A new function fnmatch.filter to filter lists of file names was added.

478 479
- calendar.py uses month and day names based on the current locale.

480 481 482 483
- strop is now *really* obsolete (this was announced before with 1.6),
  and issues DeprecationWarning when used (except for the four items
  that are still imported into string.py).

484 485 486 487 488
- Cookie.py now sorts key+value pairs by key in output strings.

- pprint.isrecursive(object) didn't correctly identify recursive objects.
  Now it does.

489 490
- pprint functions now much faster for large containers (tuple, list, dict).

491 492 493 494 495
- New 'q' and 'Q' format codes in the struct module, corresponding to C
  types "long long" and "unsigned long long" (on Windows, __int64).  In
  native mode, these can be used only when the platform C compiler supports
  these types (when HAVE_LONG_LONG is #define'd by the Python config
  process), and then they inherit the sizes and alignments of the C types.
496 497
  In standard mode, 'q' and 'Q' are supported on all platforms, and are
  8-byte integral types.
498

499 500 501 502 503
- The site module installs a new built-in function 'help' that invokes
  pydoc.help.  It must be invoked as 'help()'; when invoked as 'help',
  it displays a message reminding the user to use 'help()' or
  'help(object)'.

504 505 506 507 508 509 510 511
Tests

- New test_mutants.py runs dict comparisons where the key and value
  comparison operators mutute the dicts randomly during comparison.  This
  rapidly causes Python to crash under earlier releases (not for the faint
  of heart:  it can also cause Win9x to freeze or reboot!).

- New test_pprint.py verfies that pprint.isrecursive() and
512 513
  pprint.isreadable() return sensible results.  Also verifies that simple
  cases produce correct output.
514

515 516 517 518 519 520
C API

- Removed the unused last_is_sticky argument from the internal
  _PyTuple_Resize().  If this affects you, you were cheating.


521 522 523
======================================================================


524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544
What's New in Python 2.1 (final)?
=================================

We only changed a few things since the last release candidate, all in
Python library code:

- A bug in the locale module was fixed that affected locales which
  define no grouping for numeric formatting.

- A few bugs in the weakref module's implementations of weak
  dictionaries (WeakValueDictionary and WeakKeyDictionary) were fixed,
  and the test suite was updated to check for these bugs.

- An old bug in the os.path.walk() function (introduced in Python
  2.0!) was fixed: a non-existent file would cause an exception
  instead of being ignored.

- Fixed a few bugs in the new symtable module found by Neil Norwitz's
  PyChecker.


Guido van Rossum's avatar
Guido van Rossum committed
545 546
What's New in Python 2.1c2?
===========================
547

Guido van Rossum's avatar
Guido van Rossum committed
548 549 550
A flurry of small changes, and one showstopper fixed in the nick of
time made it necessary to release another release candidate.  The list
here is the *complete* list of patches (except version updates):
551

Guido van Rossum's avatar
Guido van Rossum committed
552
Core
553

Guido van Rossum's avatar
Guido van Rossum committed
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 617 618 619 620 621 622 623 624 625 626 627 628 629
- Tim discovered a nasty bug in the dictionary code, caused by
  PyDict_Next() calling dict_resize(), and the GC code's use of
  PyDict_Next() violating an assumption in dict_items().  This was
  fixed with considerable amounts of band-aid, but the net effect is a
  saner and more robust implementation.

- Made a bunch of symbols static that were accidentally global.

Build and Ports

- The setup.py script didn't check for a new enough version of zlib
  (1.1.3 is needed).  Now it does.

- Changed "make clean" target to also remove shared libraries.

- Added a more general warning about the SGI Irix optimizer to README.

Library

- Fix a bug in urllib.basejoin("http://host", "../file.html") which
  omitted the slash between host and file.html.

- The mailbox module's _Mailbox class contained a completely broken
  and undocumented seek() method.  Ripped it out.

- Fixed a bunch of typos in various library modules (urllib2, smtpd,
  sgmllib, netrc, chunk) found by Neil Norwitz's PyChecker.

- Fixed a few last-minute bugs in unittest.

Extensions

- Reverted the patch to the OpenSSL code in socketmodule.c to support
  RAND_status() and the EGD, and the subsequent patch that tried to
  fix it for pre-0.9.5 versions; the problem with the patch is that on
  some systems it issues a warning whenever socket is imported, and
  that's unacceptable.

Tests

- Fixed the pickle tests to work with "import test.test_pickle".

- Tweaked test_locale.py to actually run the test Windows.

- In distutils/archive_util.py, call zipfile.ZipFile() with mode "w",
  not "wb" (which is not a valid mode at all).

- Fix pstats browser crashes.  Import readline if it exists to make
  the user interface nicer.

- Add "import thread" to the top of test modules that import the
  threading module (test_asynchat and test_threadedtempfile).  This
  prevents test failures caused by a broken threading module resulting
  from a previously caught failed import.

- Changed test_asynchat.py to set the SO_REUSEADDR option; this was
  needed on some platforms (e.g. Solaris 8) when the tests are run
  twice in succession.

- Skip rather than fail test_sunaudiodev if no audio device is found.


What's New in Python 2.1c1?
===========================

This list was significantly updated when 2.1c2 was released; the 2.1c1
release didn't mention most changes that were actually part of 2.1c1:

Legal

- Copyright was assigned to the Python Software Foundation (PSF) and a
  PSF license (very similar to the CNRI license) was added.

- The CNRI copyright notice was updated to include 2001.

Core
630

631 632 633
- After a public outcry, assignment to __debug__ is no longer illegal;
  instead, a warning is issued.  It will become illegal in 2.2.

Guido van Rossum's avatar
Guido van Rossum committed
634 635 636 637 638 639 640 641 642 643 644 645 646
- Fixed a core dump with "%#x" % 0, and changed the semantics so that
  "%#x" now always prepends "0x", even if the value is zero.

- Fixed some nits in the bytecode compiler.

- Fixed core dumps when calling certain kinds of non-functions.

- Fixed various core dumps caused by reference count bugs.

Build and Ports

- Use INSTALL_SCRIPT to install script files.

647 648
- New port: SCO Unixware 7, by Billy G. Allie.

Guido van Rossum's avatar
Guido van Rossum committed
649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739
- Updated RISCOS port.

- Updated BeOS port and notes.

- Various other porting problems resolved.

Library

- The TERMIOS and SOCKET modules are now truly obsolete and
  unnecessary.  Their symbols are incorporated in the termios and
  socket modules.

- Fixed some 64-bit bugs in pickle, cPickle, and struct, and added
  better tests for pickling.

- threading: make Condition.wait() robust against KeyboardInterrupt.

- zipfile: add support to zipfile to support opening an archive
  represented by an open file rather than a file name.  Fix bug where
  the archive was not properly closed.  Fixed a bug in this bugfix
  where flush() was called for a read-only file.

- imputil: added an uninstall() method to the ImportManager.

- Canvas: fixed bugs in lower() and tkraise() methods.

- SocketServer: API change (added overridable close_request() method)
  so that the TCP server can explicitly close the request.

- pstats: Eric Raymond added a simple interactive statistics browser,
  invoked when the module is run as a script.

- locale: fixed a problem in format().

- webbrowser: made it work when the BROWSER environment variable has a
  value like "/usr/bin/netscape".  Made it auto-detect Konqueror for
  KDE 2.  Fixed some other nits.

- unittest: changes to allow using a different exception than
  AssertionError, and added a few more function aliases.  Some other
  small changes.

- urllib, urllib2: fixed redirect problems and a coupleof other nits.

- asynchat: fixed a critical bug in asynchat that slipped through the
  2.1b2 release.  Fixed another rare bug.

- Fix some unqualified except: clauses (always a bad code example).

XML

- pyexpat: new API get_version_string().

- Fixed some minidom bugs.

Extensions

- Fixed a core dump in _weakref.  Removed the weakref.mapping()
  function (it adds nothing to the API).

- Rationalized the use of header files in the readline module, to make
  it compile (albeit with some warnings) with the very recent readline
  4.2, without breaking for earlier versions.

- Hopefully fixed a buffering problem in linuxaudiodev.

- Attempted a fix to make the OpenSSL support in the socket module
  work again with pre-0.9.5 versions of OpenSSL.

Tests

- Added a test case for asynchat and asyncore.

- Removed coupling between tests where one test failing could break
  another.

Tools

- Ping added an interactive help browser to pydoc, fixed some nits
  in the rest of the pydoc code, and added some features to his
  inspect module.

- An updated python-mode.el version 4.1 which integrates Ken
  Manheimer's pdbtrack.el.  This makes debugging Python code via pdb
  much nicer in XEmacs and Emacs.  When stepping through your program
  with pdb, in either the shell window or the *Python* window, the
  source file and line will be tracked by an arrow.  Very cool!

- IDLE: syntax warnings in interactive mode are changed into errors.

- Some improvements to Tools/webchecker (ignore some more URL types,
740
  follow some more links).
Guido van Rossum's avatar
Guido van Rossum committed
741 742

- Brought the Tools/compiler package up to date.
743

744

Martin v. Löwis's avatar
Martin v. Löwis committed
745 746 747
What's New in Python 2.1 beta 2?
================================

748 749
(Unlisted are many fixed bugs, more documentation, etc.)

Martin v. Löwis's avatar
Martin v. Löwis committed
750 751
Core language, builtins, and interpreter

752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770
- The nested scopes work (enabled by "from __future__ import
  nested_scopes") is completed; in particular, the future now extends
  into code executed through exec, eval() and execfile(), and into the
  interactive interpreter.

- When calling a base class method (e.g. BaseClass.__init__(self)),
  this is now allowed even if self is not strictly spoken a class
  instance (e.g. when using metaclasses or the Don Beaudry hook).

- Slice objects are now comparable but not hashable; this prevents
  dict[:] from being accepted but meaningless.

- Complex division is now calculated using less braindead algorithms.
  This doesn't change semantics except it's more likely to give useful
  results in extreme cases.  Complex repr() now uses full precision
  like float repr().

- sgmllib.py now calls handle_decl() for simple <!...> declarations.

771 772 773 774 775 776
- It is illegal to assign to the name __debug__, which is set when the
  interpreter starts.  It is effectively a compile-time constant.

- A warning will be issued if a global statement for a variable
  follows a use or assignment of that variable.

Martin v. Löwis's avatar
Martin v. Löwis committed
777 778
Standard library

779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812
- unittest.py, a unit testing framework by Steve Purcell (PyUNIT,
  inspired by JUnit), is now part of the standard library.  You now
  have a choice of two testing frameworks: unittest requires you to
  write testcases as separate code, doctest gathers them from
  docstrings.  Both approaches have their advantages and
  disadvantages.

- A new module Tix was added, which wraps the Tix extension library
  for Tk.  With that module, it is not necessary to statically link
  Tix with _tkinter, since Tix will be loaded with Tcl's "package
  require" command.  See Demo/tix/.

- tzparse.py is now obsolete.

- In gzip.py, the seek() and tell() methods are removed -- they were
  non-functional anyway, and it's better if callers can test for their
  existence with hasattr().

Python/C API

- PyDict_Next(): it is now safe to call PyDict_SetItem() with a key
  that's already in the dictionary during a PyDict_Next() iteration.
  This used to fail occasionally when a dictionary resize operation
  could be triggered that would rehash all the keys.  All other
  modifications to the dictionary are still off-limits during a
  PyDict_Next() iteration!

- New extended APIs related to passing compiler variables around.

- New abstract APIs PyObject_IsInstance(), PyObject_IsSubclass()
  implement isinstance() and issubclass().

- Py_BuildValue() now has a "D" conversion to create a Python complex
  number from a Py_complex C value.
Martin v. Löwis's avatar
Martin v. Löwis committed
813

814 815 816 817 818 819
- Extensions types which support weak references must now set the
  field allocated for the weak reference machinery to NULL themselves;
  this is done to avoid the cost of checking each object for having a
  weakly referencable type in PyObject_INIT(), since most types are
  not weakly referencable.

820 821 822 823 824 825 826 827
- PyFrame_FastToLocals() and PyFrame_LocalsToFast() copy bindings for
  free variables and cell variables to and from the frame's f_locals.

- Variants of several functions defined in pythonrun.h have been added
  to support the nested_scopes future statement.  The variants all end
  in Flags and take an extra argument, a PyCompilerFlags *; examples:
  PyRun_AnyFileExFlags(), PyRun_InteractiveLoopFlags().  These
  variants may be removed in Python 2.2, when nested scopes are
828
  mandatory.
829

830 831 832 833 834
Distutils

- the sdist command now writes a PKG-INFO file, as described in PEP 241,
  into the release tree.

835
- several enhancements to the bdist_wininst command from Thomas Heller
836 837 838 839
  (an uninstaller, more customization of the installer's display)

- from Jack Jansen: added Mac-specific code to generate a dialog for
  users to specify the command-line (because providing a command-line with
840
  MacPython is awkward).  Jack also made various fixes for the Mac
841
  and the Metrowerks compiler.
842 843 844

- added 'platforms' and 'keywords' to the set of metadata that can be
  specified for a distribution.
845 846 847 848 849

- applied patches from Jason Tishler to make the compiler class work with
  Cygwin.


850 851
What's New in Python 2.1 beta 1?
================================
852 853 854

Core language, builtins, and interpreter

855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890
- Following an outcry from the community about the amount of code
  broken by the nested scopes feature introduced in 2.1a2, we decided
  to make this feature optional, and to wait until Python 2.2 (or at
  least 6 months) to make it standard.  The option can be enabled on a
  per-module basis by adding "from __future__ import nested_scopes" at
  the beginning of a module (before any other statements, but after
  comments and an optional docstring).  See PEP 236 (Back to the
  __future__) for a description of the __future__ statement.  PEP 227
  (Statically Nested Scopes) has been updated to reflect this change,
  and to clarify the semantics in a number of endcases.

- The nested scopes code, when enabled, has been hardened, and most
  bugs and memory leaks in it have been fixed.

- Compile-time warnings are now generated for a number of conditions
  that will break or change in meaning when nested scopes are enabled:

  - Using "from...import *" or "exec" without in-clause in a function
    scope that also defines a lambda or nested function with one or
    more free (non-local) variables.  The presence of the import* or
    bare exec makes it impossible for the compiler to determine the
    exact set of local variables in the outer scope, which makes it
    impossible to determine the bindings for free variables in the
    inner scope.  To avoid the warning about import *, change it into
    an import of explicitly name object, or move the import* statement
    to the global scope; to avoid the warning about bare exec, use
    exec...in... (a good idea anyway -- there's a possibility that
    bare exec will be deprecated in the future).

  - Use of a global variable in a nested scope with the same name as a
    local variable in a surrounding scope.  This will change in
    meaning with nested scopes: the name in the inner scope will
    reference the variable in the outer scope rather than the global
    of the same name.  To avoid the warning, either rename the outer
    variable, or use a global statement in the inner function.

891 892 893 894 895 896 897 898 899
- An optional object allocator has been included.  This allocator is
  optimized for Python objects and should be faster and use less memory
  than the standard system allocator.  It is not enabled by default
  because of possible thread safety problems.  The allocator is only
  protected by the Python interpreter lock and it is possible that some
  extension modules require a thread safe allocator.  The object
  allocator can be enabled by providing the "--with-pymalloc" option to
  configure.

900 901
Standard library

Martin v. Löwis's avatar
Martin v. Löwis committed
902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917
- pyexpat now detects the expat version if expat.h defines it. A
  number of additional handlers are provided, which are only available
  since expat 1.95. In addition, the methods SetParamEntityParsing and
  GetInputContext of Parser objects are available with 1.95.x
  only. Parser objects now provide the ordered_attributes and
  specified_attributes attributes. A new module expat.model was added,
  which offers a number of additional constants if 1.95.x is used.

- xml.dom offers the new functions registerDOMImplementation and
  getDOMImplementation.

- xml.dom.minidom offers a toprettyxml method. A number of DOM
  conformance issues have been resolved. In particular, Element now
  has an hasAttributes method, and the handling of namespaces was
  improved.

Andrew M. Kuchling's avatar
Andrew M. Kuchling committed
918 919 920 921
- Ka-Ping Yee contributed two new modules: inspect.py, a module for
  getting information about live Python code, and pydoc.py, a module
  for interactively converting docstrings to HTML or text.
  Tools/scripts/pydoc, which is now automatically installed into
922
  <prefix>/bin, uses pydoc.py to display documentation; try running
923 924
  "pydoc -h" for instructions.  "pydoc -g" pops up a small GUI that
  lets you browse the module docstrings using a web browser.
Andrew M. Kuchling's avatar
Andrew M. Kuchling committed
925

926 927 928 929 930 931
- New library module difflib.py, primarily packaging the SequenceMatcher
  class at the heart of the popular ndiff.py file-comparison tool.

- doctest.py (a framework for verifying Python code examples in docstrings)
  is now part of the std library.

932 933
Windows changes

934 935 936 937
- A new entry in the Start menu, "Module Docs", runs "pydoc -g" -- a
  small GUI that lets you browse the module docstrings using your
  default web browser.

938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955
- Import is now case-sensitive.  PEP 235 (Import on Case-Insensitive
  Platforms) is implemented.  See

      http://python.sourceforge.net/peps/pep-0235.html

  for full details, especially the "Current Lower-Left Semantics" section.
  The new Windows import rules are simpler than before:

  A. If the PYTHONCASEOK environment variable exists, same as
     before:  silently accept the first case-insensitive match of any
     kind; raise ImportError if none found.

  B. Else search sys.path for the first case-sensitive match; raise
     ImportError if none found.

  The same rules have been implented on other platforms with case-
  insensitive but case-preserving filesystems too (including Cygwin, and
  several flavors of Macintosh operating systems).
956

957 958 959
- winsound module:  Under Win9x, winsound.Beep() now attempts to simulate
  what it's supposed to do (and does do under NT and 2000) via direct
  port manipulation.  It's unknown whether this will work on all systems,
960
  but it does work on my Win98SE systems now and was known to be useless on
961 962
  all Win9x systems before.

963 964
- Build:  Subproject _test (effectively) renamed to _testcapi.

965 966 967 968 969 970 971 972
New platforms

- 2.1 should compile and run out of the box under MacOS X, even using HFS+.
  Thanks to Steven Majewski!

- 2.1 should compile and run out of the box on Cygwin.  Thanks to Jason
  Tishler!

Guido van Rossum's avatar
Guido van Rossum committed
973 974 975 976 977 978 979 980
- 2.1 contains new files and patches for RISCOS, thanks to Dietmar
  Schwertberger!  See RISCOS/README for more information -- it seems
  that because of the bizarre filename conventions on RISCOS, no port
  to that platform is easy.  Note that the new variable os.endsep is
  silently supported in order to make life easier on this platform,
  but we don't advertise it because it's not worth for most folks to
  care about RISCOS portability.

981

982 983
What's New in Python 2.1 alpha 2?
=================================
Tim Peters's avatar
Tim Peters committed
984

985 986
Core language, builtins, and interpreter

Jeremy Hylton's avatar
Jeremy Hylton committed
987 988 989 990 991 992 993 994
- Scopes nest.  If a name is used in a function or class, but is not
  local, the definition in the nearest enclosing function scope will
  be used.  One consequence of this change is that lambda statements
  could reference variables in the namespaces where the lambda is
  defined.  In some unusual cases, this change will break code.

  In all previous version of Python, names were resolved in exactly
  three namespaces -- the local namespace, the global namespace, and
Jeremy Hylton's avatar
Jeremy Hylton committed
995
  the builtin namespace.  According to this old definition, if a
Jeremy Hylton's avatar
Jeremy Hylton committed
996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019
  function A is defined within a function B, the names bound in B are
  not visible in A.  The new rules make names bound in B visible in A,
  unless A contains a name binding that hides the binding in B.

  Section 4.1 of the reference manual describes the new scoping rules
  in detail.  The test script in Lib/test/test_scope.py demonstrates
  some of the effects of the change.

  The new rules will cause existing code to break if it defines nested
  functions where an outer function has local variables with the same
  name as globals or builtins used by the inner function.  Example:

    def munge(str):
        def helper(x):
            return str(x)
        if type(str) != type(''):
            str = helper(str)
        return str.strip()

  Under the old rules, the name str in helper() is bound to the
  builtin function str().  Under the new rules, it will be bound to
  the argument named str and an error will occur when helper() is
  called.

Jeremy Hylton's avatar
Jeremy Hylton committed
1020 1021 1022 1023 1024 1025 1026
- The compiler will report a SyntaxError if "from ... import *" occurs
  in a function or class scope.  The language reference has documented
  that this case is illegal, but the compiler never checked for it.
  The recent introduction of nested scope makes the meaning of this
  form of name binding ambiguous.  In a future release, the compiler
  may allow this form when there is no possibility of ambiguity.

Tim Peters's avatar
Tim Peters committed
1027 1028 1029 1030 1031 1032 1033
- repr(string) is easier to read, now using hex escapes instead of octal,
  and using \t, \n and \r instead of \011, \012 and \015 (respectively):

  >>> "\texample \r\n" + chr(0) + chr(255)
  '\texample \r\n\x00\xff'         # in 2.1
  '\011example \015\012\000\377'   # in 2.0

1034 1035 1036
- Functions are now compared and hashed by identity, not by value, since
  the func_code attribute is writable.

1037 1038 1039 1040 1041 1042
- Weak references (PEP 205) have been added.  This involves a few
  changes in the core, an extension module (_weakref), and a Python
  module (weakref).  The weakref module is the public interface.  It
  includes support for "explicit" weak references, proxy objects, and
  mappings with weakly held values.

1043 1044
- A 'continue' statement can now appear in a try block within the body
  of a loop.  It is still not possible to use continue in a finally
1045
  clause.
1046

1047 1048
Standard library

1049 1050 1051 1052 1053 1054 1055
- mailbox.py now has a new class, PortableUnixMailbox which is
  identical to UnixMailbox but uses a more portable scheme for
  determining From_ separators.  Also, the constructors for all the
  classes in this module have a new optional `factory' argument, which
  is a callable used when new message classes must be instantiated by
  the next() method.

1056 1057 1058
- random.py is now self-contained, and offers all the functionality of
  the now-deprecated whrandom.py.  See the docs for details.  random.py
  also supports new functions getstate() and setstate(), for saving
1059 1060 1061 1062 1063 1064
  and restoring the internal state of the generator; and jumpahead(n),
  for quickly forcing the internal state to be the same as if n calls to
  random() had been made.  The latter is particularly useful for multi-
  threaded programs, creating one instance of the random.Random() class for
  each thread, then using .jumpahead() to force each instance to use a
  non-overlapping segment of the full period.
1065

1066 1067 1068 1069 1070 1071 1072 1073 1074 1075
- random.py's seed() function is new.  For bit-for-bit compatibility with
  prior releases, use the whseed function instead.  The new seed function
  addresses two problems:  (1) The old function couldn't produce more than
  about 2**24 distinct internal states; the new one about 2**45 (the best
  that can be done in the Wichmann-Hill generator).  (2) The old function
  sometimes produced identical internal states when passed distinct
  integers, and there was no simple way to predict when that would happen;
  the new one guarantees to produce distinct internal states for all
  arguments in [0, 27814431486576L).

1076 1077 1078
- The socket module now supports raw packets on Linux.  The socket
  family is AF_PACKET.

1079 1080 1081
- test_capi.py is a start at running tests of the Python C API.  The tests
  are implemented by the new Modules/_testmodule.c.

Jeremy Hylton's avatar
Jeremy Hylton committed
1082 1083 1084 1085
- A new extension module, _symtable, provides provisional access to the
  internal symbol table used by the Python compiler.  A higher-level
  interface will be added on top of _symtable in a future release.

1086 1087
- Removed the obsolete soundex module.

Martin v. Löwis's avatar
Martin v. Löwis committed
1088 1089 1090 1091 1092 1093
- xml.dom.minidom now uses the standard DOM exceptions. Node supports
  the isSameNode method; NamedNodeMap the get method.

- xml.sax.expatreader supports the lexical handler property; it
  generates comment, startCDATA, and endCDATA events.

1094 1095 1096 1097
Windows changes

- Build procedure:  the zlib project is built in a different way that
  ensures the zlib header files used can no longer get out of synch with
1098 1099 1100 1101 1102
  the zlib binary used.  See PCbuild\readme.txt for details.  Your old
  zlib-related directories can be deleted; you'll need to download fresh
  source for zlib and unpack it into a new directory.

- Build:  New subproject _test for the benefit of test_capi.py (see above).
1103

1104 1105 1106 1107
- Build:  New subproject _symtable, for new DLL _symtable.pyd (a nascent
  interface to some Python compiler internals).

- Build:  Subproject ucnhash is gone, since the code was folded into the
1108
  unicodedata subproject.
1109

1110 1111 1112 1113 1114
What's New in Python 2.1 alpha 1?
=================================

Core language, builtins, and interpreter

1115 1116 1117 1118
- There is a new Unicode companion to the PyObject_Str() API
  called PyObject_Unicode(). It behaves in the same way as the
  former, but assures that the returned value is an Unicode object
  (applying the usual coercion if necessary).
1119

1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137
- The comparison operators support "rich comparison overloading" (PEP
  207).  C extension types can provide a rich comparison function in
  the new tp_richcompare slot in the type object.  The cmp() function
  and the C function PyObject_Compare() first try the new rich
  comparison operators before trying the old 3-way comparison.  There
  is also a new C API PyObject_RichCompare() (which also falls back on
  the old 3-way comparison, but does not constrain the outcome of the
  rich comparison to a Boolean result).

  The rich comparison function takes two objects (at least one of
  which is guaranteed to have the type that provided the function) and
  an integer indicating the opcode, which can be Py_LT, Py_LE, Py_EQ,
  Py_NE, Py_GT, Py_GE (for <, <=, ==, !=, >, >=), and returns a Python
  object, which may be NotImplemented (in which case the tp_compare
  slot function is used as a fallback, if defined).

  Classes can overload individual comparison operators by defining one
  or more of the methods__lt__, __le__, __eq__, __ne__, __gt__,
1138 1139 1140 1141 1142 1143 1144
  __ge__.  There are no explicit "reflected argument" versions of
  these; instead, __lt__ and __gt__ are each other's reflection,
  likewise for__le__ and __ge__; __eq__ and __ne__ are their own
  reflection (similar at the C level).  No other implications are
  made; in particular, Python does not assume that == is the Boolean
  inverse of !=, or that < is the Boolean inverse of >=.  This makes
  it possible to define types with partial orderings.
1145 1146 1147 1148 1149

  Classes or types that want to implement (in)equality tests but not
  the ordering operators (i.e. unordered types) should implement ==
  and !=, and raise an error for the ordering operators.

1150
  It is possible to define types whose rich comparison results are not
1151 1152 1153 1154 1155 1156
  Boolean; e.g. a matrix type might want to return a matrix of bits
  for A < B, giving elementwise comparisons.  Such types should ensure
  that any interpretation of their value in a Boolean context raises
  an exception, e.g. by defining __nonzero__ (or the tp_nonzero slot
  at the C level) to always raise an exception.

1157 1158 1159 1160 1161 1162 1163
- Complex numbers use rich comparisons to define == and != but raise
  an exception for <, <=, > and >=.  Unfortunately, this also means
  that cmp() of two complex numbers raises an exception when the two
  numbers differ.  Since it is not mathematically meaningful to compare
  complex numbers except for equality, I hope that this doesn't break
  too much code.

Tim Peters's avatar
Tim Peters committed
1164
- The outcome of comparing non-numeric objects of different types is
1165 1166 1167 1168 1169 1170
  not defined by the language, other than that it's arbitrary but
  consistent (see the Reference Manual).  An implementation detail changed
  in 2.1a1 such that None now compares less than any other object.  Code
  relying on this new behavior (like code that relied on the previous
  behavior) does so at its own risk.

1171 1172 1173 1174 1175 1176
- Functions and methods now support getting and setting arbitrarily
  named attributes (PEP 232).  Functions have a new __dict__
  (a.k.a. func_dict) which hold the function attributes.  Methods get
  and set attributes on their underlying im_func.  It is a TypeError
  to set an attribute on a bound method.

1177 1178 1179 1180 1181 1182 1183 1184
- The xrange() object implementation has been improved so that
  xrange(sys.maxint) can be used on 64-bit platforms.  There's still a
  limitation that in this case len(xrange(sys.maxint)) can't be
  calculated, but the common idiom "for i in xrange(sys.maxint)" will
  work fine as long as the index i doesn't actually reach 2**31.
  (Python uses regular ints for sequence and string indices; fixing
  that is much more work.)

Guido van Rossum's avatar
Guido van Rossum committed
1185 1186
- Two changes to from...import:

1187 1188 1189
  1) "from M import X" now works even if (after loading module M)
     sys.modules['M'] is not a real module; it's basically a getattr()
     operation with AttributeError exceptions changed into ImportError.
Guido van Rossum's avatar
Guido van Rossum committed
1190 1191 1192 1193 1194 1195

  2) "from M import *" now looks for M.__all__ to decide which names to
     import; if M.__all__ doesn't exist, it uses M.__dict__.keys() but
     filters out names starting with '_' as before.  Whether or not
     __all__ exists, there's no restriction on the type of M.

1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206
- File objects have a new method, xreadlines().  This is the fastest
  way to iterate over all lines in a file:

  for line in file.xreadlines():
      ...do something to line...

  See the xreadlines module (mentioned below) for how to do this for
  other file-like objects.

- Even if you don't use file.xreadlines(), you may expect a speedup on
  line-by-line input.  The file.readline() method has been optimized
1207 1208 1209 1210 1211 1212
  quite a bit in platform-specific ways:  on systems (like Linux) that
  support flockfile(), getc_unlocked(), and funlockfile(), those are
  used by default.  On systems (like Windows) without getc_unlocked(),
  a complicated (but still thread-safe) method using fgets() is used by
  default.

1213 1214
  You can force use of the fgets() method by #define'ing
  USE_FGETS_IN_GETLINE at build time (it may be faster than
1215 1216
  getc_unlocked()).

1217 1218
  You can force fgets() not to be used by #define'ing
  DONT_USE_FGETS_IN_GETLINE (this is the first thing to try if std test
1219 1220 1221 1222 1223
  test_bufio.py fails -- and let us know if it does!).

- In addition, the fileinput module, while still slower than the other
  methods on most platforms, has been sped up too, by using
  file.readlines(sizehint).
1224 1225 1226 1227 1228 1229 1230 1231 1232 1233

- Support for run-time warnings has been added, including a new
  command line option (-W) to specify the disposition of warnings.
  See the description of the warnings module below.

- Extensive changes have been made to the coercion code.  This mostly
  affects extension modules (which can now implement mixed-type
  numerical operators without having to use coercion), but
  occasionally, in boundary cases the coercion semantics have changed
  subtly.  Since this was a terrible gray area of the language, this
Guido van Rossum's avatar
Typo.  
Guido van Rossum committed
1234
  is considered an improvement.  Also note that __rcmp__ is no longer
1235
  supported -- instead of calling __rcmp__, __cmp__ is called with
1236
  reflected arguments.
1237

1238 1239 1240 1241 1242 1243
- In connection with the coercion changes, a new built-in singleton
  object, NotImplemented is defined.  This can be returned for
  operations that wish to indicate they are not implemented for a
  particular combination of arguments.  From C, this is
  Py_NotImplemented.

1244 1245 1246
- The interpreter accepts now bytecode files on the command line even
  if they do not have a .pyc or .pyo extension. On Linux, after executing

1247 1248 1249 1250
import imp,sys,string
magic = string.join(["\\x%.2x" % ord(c) for c in imp.get_magic()],"")
reg = ':pyc:M::%s::%s:' % (magic, sys.executable)
open("/proc/sys/fs/binfmt_misc/register","wb").write(reg)
1251 1252 1253 1254

  any byte code file can be used as an executable (i.e. as an argument
  to execve(2)).

1255
- %[xXo] formats of negative Python longs now produce a sign
1256 1257 1258 1259 1260 1261 1262 1263
  character.  In 1.6 and earlier, they never produced a sign,
  and raised an error if the value of the long was too large
  to fit in a Python int.  In 2.0, they produced a sign if and
  only if too large to fit in an int.  This was inconsistent
  across platforms (because the size of an int varies across
  platforms), and inconsistent with hex() and oct().  Example:

  >>> "%x" % -0x42L
1264
  '-42'      # in 2.1
1265 1266 1267 1268
  'ffffffbe' # in 2.0 and before, on 32-bit machines
  >>> hex(-0x42L)
  '-0x42L'   # in all versions of Python

1269 1270 1271 1272 1273 1274 1275 1276 1277 1278
  The behavior of %d formats for negative Python longs remains
  the same as in 2.0 (although in 1.6 and before, they raised
  an error if the long didn't fit in a Python int).

  %u formats don't make sense for Python longs, but are allowed
  and treated the same as %d in 2.1.  In 2.0, a negative long
  formatted via %u produced a sign if and only if too large to
  fit in an int.  In 1.6 and earlier, a negative long formatted
  via %u raised an error if it was too big to fit in an int.

Guido van Rossum's avatar
Guido van Rossum committed
1279 1280 1281 1282 1283 1284 1285
- Dictionary objects have an odd new method, popitem().  This removes
  an arbitrary item from the dictionary and returns it (in the form of
  a (key, value) pair).  This can be useful for algorithms that use a
  dictionary as a bag of "to do" items and repeatedly need to pick one
  item.  Such algorithms normally end up running in quadratic time;
  using popitem() they can usually be made to run in linear time.

1286 1287
Standard library

1288 1289 1290 1291
- In the time module, the time argument to the functions strftime,
  localtime, gmtime, asctime and ctime is now optional, defaulting to
  the current time (in the local timezone).

1292 1293 1294 1295 1296 1297 1298
- The ftplib module now defaults to passive mode, which is deemed a
  more useful default given that clients are often inside firewalls
  these days.  Note that this could break if ftplib is used to connect
  to a *server* that is inside a firewall, from outside; this is
  expected to be a very rare situation.  To fix that, you can call
  ftp.set_pasv(0).

1299 1300 1301 1302
- The module site now treats .pth files not only for path configuration,
  but also supports extensions to the initialization code: Lines starting
  with import are executed.

1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326
- There's a new module, warnings, which implements a mechanism for
  issuing and filtering warnings.  There are some new built-in
  exceptions that serve as warning categories, and a new command line
  option, -W, to control warnings (e.g. -Wi ignores all warnings, -We
  turns warnings into errors).  warnings.warn(message[, category])
  issues a warning message; this can also be called from C as
  PyErr_Warn(category, message).

- A new module xreadlines was added.  This exports a single factory
  function, xreadlines().  The intention is that this code is the
  absolutely fastest way to iterate over all lines in an open
  file(-like) object:

  import xreadlines
  for line in xreadlines.xreadlines(file):
      ...do something to line...

  This is equivalent to the previous the speed record holder using
  file.readlines(sizehint).  Note that if file is a real file object
  (as opposed to a file-like object), this is equivalent:

  for line in file.xreadlines():
      ...do something to line...

1327 1328 1329 1330 1331 1332
- The bisect module has new functions bisect_left, insort_left,
  bisect_right and insort_right.  The old names bisect and insort
  are now aliases for bisect_right and insort_right.  XXX_right
  and XXX_left methods differ in what happens when the new element
  compares equal to one or more elements already in the list:  the
  XXX_left methods insert to the left, the XXX_right methods to the
1333 1334
  right.  Code that doesn't care where equal elements end up should
  continue to use the old, short names ("bisect" and "insort").
1335

1336 1337 1338
- The new curses.panel module wraps the panel library that forms part
  of SYSV curses and ncurses.  Contributed by Thomas Gellekum.

1339 1340 1341 1342 1343 1344 1345
- The SocketServer module now sets the allow_reuse_address flag by
  default in the TCPServer class.

- A new function, sys._getframe(), returns the stack frame pointer of
  the caller.  This is intended only as a building block for
  higher-level mechanisms such as string interpolation.

Martin v. Löwis's avatar
Martin v. Löwis committed
1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365
- The pyexpat module supports a number of new handlers, which are
  available only in expat 1.2. If invocation of a callback fails, it
  will report an additional frame in the traceback. Parser objects
  participate now in garbage collection. If expat reports an unknown
  encoding, pyexpat will try to use a Python codec; that works only
  for single-byte charsets. The parser type objects is exposed as
  XMLParserObject.

- xml.dom now offers standard definitions for symbolic node type and
  exception code constants, and a hierarchy of DOM exceptions. minidom
  was adjusted to use them.

- The conformance of xml.dom.minidom to the DOM specification was
  improved. It detects a number of additional error cases; the
  previous/next relationship works even when the tree is modified;
  Node supports the normalize() method; NamedNodeMap, DocumentType and
  DOMImplementation classes were added; Element supports the
  hasAttribute and hasAttributeNS methods; and Text supports the splitText
  method.

1366 1367
Build issues

1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379
- For Unix (and Unix-compatible) builds, configuration and building of
  extension modules is now greatly automated.  Rather than having to
  edit the Modules/Setup file to indicate which modules should be
  built and where their include files and libraries are, a
  distutils-based setup.py script now takes care of building most
  extension modules.  All extension modules built this way are built
  as shared libraries.  Only a few modules that must be linked
  statically are still listed in the Setup file; you won't need to
  edit their configuration.

- Python should now build out of the box on Cygwin.  If it doesn't,
  mail to Jason Tishler (jlt63 at users.sourceforge.net).
1380 1381 1382 1383 1384 1385 1386

- Python now always uses its own (renamed) implementation of getopt()
  -- there's too much variation among C library getopt()
  implementations.

- C++ compilers are better supported; the CXX macro is always set to a
  C++ compiler if one is found.
1387

1388 1389 1390 1391 1392 1393 1394 1395
Windows changes

- select module:  By default under Windows, a select() call
  can specify no more than 64 sockets.  Python now boosts
  this Microsoft default to 512.  If you need even more than
  that, see the MS docs (you'll need to #define FD_SETSIZE
  and recompile Python from source).

1396 1397 1398
- Support for Windows 3.1, DOS and OS/2 is gone.  The Lib/dos-8x3
  subdirectory is no more!

1399

1400
What's New in Python 2.0?
Fred Drake's avatar
Fred Drake committed
1401
=========================
1402

1403
Below is a list of all relevant changes since release 1.6.  Older
Guido van Rossum's avatar
Guido van Rossum committed
1404 1405 1406
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.
1407

Guido van Rossum's avatar
Guido van Rossum committed
1408 1409 1410
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/.
1411

Guido van Rossum's avatar
Guido van Rossum committed
1412
--Guido van Rossum (home page: http://www.pythonlabs.com/~guido/)
1413 1414

======================================================================
1415

1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429
What's new in 2.0 (since release candidate 1)?
==============================================

Standard library

- The copy_reg module was modified to clarify its intended use: to
  register pickle support for extension types, not for classes.
  pickle() will raise a TypeError if it is passed a class.

- Fixed a bug in gettext's "normalize and expand" code that prevented
  it from finding an existing .mo file.

- Restored support for HTTP/0.9 servers in httplib.

1430 1431 1432 1433 1434
- The math module was changed to stop raising OverflowError in case of
  underflow, and return 0 instead in underflow cases.  Whether Python
  used to raise OverflowError in case of underflow was platform-
  dependent (it did when the platform math library set errno to ERANGE
  on underflow).
1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454

- Fixed a bug in StringIO that occurred when the file position was not
  at the end of the file and write() was called with enough data to
  extend past the end of the file.

- Fixed a bug that caused Tkinter error messages to get lost on
  Windows.  The bug was fixed by replacing direct use of
  interp->result with Tcl_GetStringResult(interp).

- Fixed bug in urllib2 that caused it to fail when it received an HTTP
  redirect response.

- Several changes were made to distutils: Some debugging code was
  removed from util.  Fixed the installer used when an external zip
  program (like WinZip) is not found; the source code for this
  installer is in Misc/distutils.  check_lib() was modified to behave
  more like AC_CHECK_LIB by add other_libraries() as a parameter.  The
  test for whether installed modules are on sys.path was changed to
  use both normcase() and normpath().

Jeremy Hylton's avatar
Jeremy Hylton committed
1455 1456
- Several minor bugs were fixed in the xml package (the minidom,
  pulldom, expatreader, and saxutils modules).
1457 1458 1459 1460 1461

- The regression test driver (regrtest.py) behavior when invoked with
  -l changed: It now reports a count of objects that are recognized as
  garbage but not freed by the garbage collector.

1462 1463 1464 1465 1466
- The regression test for the math module was changed to test
  exceptional behavior when the test is run in verbose mode.  Python
  cannot yet guarantee consistent exception behavior across platforms,
  so the exception part of test_math is run only in verbose mode, and
  may fail on your platform.
1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477

Internals

- PyOS_CheckStack() has been disabled on Win64, where it caused
  test_sre to fail.

Build issues

- Changed compiler flags, so that gcc is always invoked with -Wall and
  -Wstrict-prototypes.  Users compiling Python with GCC should see
  exactly one warning, except if they have passed configure the
1478
  --with-pydebug flag.  The expected warning is for getopt() in
Tim Peters's avatar
Tim Peters committed
1479
  Modules/main.c.  This warning will be fixed for Python 2.1.
1480

1481
- Fixed configure to add -threads argument during linking on OSF1.
1482 1483 1484 1485 1486 1487 1488 1489

Tools and other miscellany

- The compiler in Tools/compiler was updated to support the new
  language features introduced in 2.0: extended print statement, list
  comprehensions, and augmented assignments.  The new compiler should
  also be backwards compatible with Python 1.5.2; the compiler will
  always generate code for the version of the interpreter it runs
1490
  under.
1491

1492 1493 1494
What's new in 2.0 release candidate 1 (since beta 2)?
=====================================================

1495 1496 1497 1498 1499 1500 1501 1502 1503 1504
What is release candidate 1?

We believe that release candidate 1 will fix all known bugs that we
intend to fix for the 2.0 final release.  This release should be a bit
more stable than the previous betas.  We would like to see even more
widespread testing before the final release, so we are producing this
release candidate.  The final release will be exactly the same unless
any show-stopping (or brown bag) bugs are found by testers of the
release candidate.

1505
All the changes since the last beta release are bug fixes or changes
1506
to support building Python for specific platforms.
1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532

Core language, builtins, and interpreter

- A bug that caused crashes when __coerce__ was used with augmented
  assignment, e.g. +=, was fixed.

- Raise ZeroDivisionError when raising zero to a negative number,
  e.g. 0.0 ** -2.0.  Note that math.pow is unrelated to the builtin
  power operator and the result of math.pow(0.0, -2.0) will vary by
  platform.  On Linux, it raises a ValueError.

- A bug in Unicode string interpolation was fixed that occasionally
  caused errors with formats including "%%".  For example, the
  following expression "%% %s" % u"abc" no longer raises a TypeError.

- Compilation of deeply nested expressions raises MemoryError instead
  of SyntaxError, e.g. eval("[" * 50 + "]" * 50).

- In 2.0b2 on Windows, the interpreter wrote .pyc files in text mode,
  rendering them useless.  They are now written in binary mode again.

Standard library

- Keyword arguments are now accepted for most pattern and match object
  methods in SRE, the standard regular expression engine.

1533
- In SRE, fixed error with negative lookahead and lookbehind that
Jeremy Hylton's avatar
typo  
Jeremy Hylton committed
1534
  manifested itself as a runtime error in patterns like "(?<!abc)(def)".
1535

1536 1537
- Several bugs in the Unicode handling and error handling in _tkinter
  were fixed.
1538 1539 1540 1541 1542 1543 1544

- Fix memory management errors in Merge() and Tkapp_Call() routines.

- Several changes were made to cStringIO to make it compatible with
  the file-like object interface and with StringIO.  If operations are
  performed on a closed object, an exception is raised.  The truncate
  method now accepts a position argument and readline accepts a size
1545
  argument.
1546 1547 1548

- There were many changes made to the linuxaudiodev module and its
  test suite; as a result, a short, unexpected audio sample should now
1549
  play when the regression test is run.
1550 1551 1552

  Note that this module is named poorly, because it should work
  correctly on any platform that supports the Open Sound System
1553
  (OSS).
1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566

  The module now raises exceptions when errors occur instead of
  crashing.  It also defines the AFMT_A_LAW format (logarithmic A-law
  audio) and defines a getptr() method that calls the
  SNDCTL_DSP_GETxPTR ioctl defined in the OSS Programmer's Guide.

- The library_version attribute, introduced in an earlier beta, was
  removed because it can not be supported with early versions of the C
  readline library, which provides no way to determine the version at
  compile-time.

- The binascii module is now enabled on Win64.

1567 1568 1569
- tokenize.py no longer suffers "recursion depth" errors when parsing
  programs with very long string literals.

1570 1571
Internals

1572
- Fixed several buffer overflow vulnerabilities in calculate_path(),
1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600
  which is called when the interpreter starts up to determine where
  the standard library is installed.  These vulnerabilities affect all
  previous versions of Python and can be exploited by setting very
  long values for PYTHONHOME or argv[0].  The risk is greatest for a
  setuid Python script, although use of the wrapper in
  Misc/setuid-prog.c will eliminate the vulnerability.

- Fixed garbage collection bugs in instance creation that were
  triggered when errors occurred during initialization.  The solution,
  applied in cPickle and in PyInstance_New(), is to call
  PyObject_GC_Init() after the initialization of the object's
  container attributes is complete.

- pyexpat adds definitions of PyModule_AddStringConstant and
  PyModule_AddObject if the Python version is less than 2.0, which
  provides compatibility with PyXML on Python 1.5.2.

- If the platform has a bogus definition for LONG_BIT (the number of
  bits in a long), an error will be reported at compile time.

- Fix bugs in _PyTuple_Resize() which caused hard-to-interpret garbage
  collection crashes and possibly other, unreported crashes.

- Fixed a memory leak in _PyUnicode_Fini().

Build issues

- configure now accepts a --with-suffix option that specifies the
1601
  executable suffix.  This is useful for builds on Cygwin and Mac OS
1602
  X, for example.
1603 1604 1605 1606 1607 1608 1609 1610 1611 1612

- The mmap.PAGESIZE constant is now initialized using sysconf when
  possible, which eliminates a dependency on -lucb for Reliant UNIX.

- The md5 file should now compile on all platforms.

- The select module now compiles on platforms that do not define
  POLLRDNORM and related constants.

- Darwin (Mac OS X):  Initial support for static builds on this
1613
  platform.
1614

1615 1616 1617 1618 1619
- BeOS: A number of changes were made to the build and installation
  process.  ar-fake now operates on a directory of object files.
  dl_export.h is gone, and its macros now appear on the mwcc command
  line during build on PPC BeOS.

1620
- Platform directory in lib/python2.0 is "plat-beos5" (or
1621
  "plat-beos4", if building on BeOS 4.5), rather than "plat-beos".
1622 1623 1624 1625 1626 1627 1628 1629 1630

- Cygwin: Support for shared libraries, Tkinter, and sockets.

- SunOS 4.1.4_JL: Fix test for directory existence in configure.

Tools and other miscellany

- Removed debugging prints from main used with freeze.

1631 1632
- IDLE auto-indent no longer crashes when it encounters Unicode
  characters.
1633 1634 1635 1636 1637 1638

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

Core language, builtins, and interpreter

Tim Peters's avatar
Tim Peters committed
1639
- Add support for unbounded ints in %d,i,u,x,X,o formats; for example
1640 1641 1642 1643
  "%d" % 2L**64 == "18446744073709551616".

- Add -h and -V command line options to print the usage message and
  Python version number and exit immediately.
1644

Jeremy Hylton's avatar
Jeremy Hylton committed
1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655
- eval() and exec accept Unicode objects as code parameters.

- getattr() and setattr() now also accept Unicode objects for the
  attribute name, which are converted to strings using the default
  encoding before lookup.

- Multiplication on string and Unicode now does proper bounds
  checking; e.g. 'a' * 65536 * 65536 will raise ValueError, "repeated
  string is too long."

- Better error message when continue is found in try statement in a
1656
  loop.
Jeremy Hylton's avatar
Jeremy Hylton committed
1657

1658 1659 1660

Standard library and extensions

Guido van Rossum's avatar
Guido van Rossum committed
1661 1662 1663
- socket module: the OpenSSL code now adds support for RAND_status()
  and EGD (Entropy Gathering Device).

1664
- array: reverse() method of array now works.  buffer_info() now does
1665 1666
  argument checking; it still takes no arguments.

1667
- asyncore/asynchat: Included most recent version from Sam Rushing.
1668

1669
- cgi: Accept '&' or ';' as separator characters when parsing form data.
1670

1671
- CGIHTTPServer: Now works on Windows (and perhaps even Mac).
1672 1673

- ConfigParser: When reading the file, options spelled in upper case
1674
  letters are now correctly converted to lowercase.
1675 1676 1677

- copy: Copy Unicode objects atomically.

1678
- cPickle: Fail gracefully when copy_reg can't be imported.
1679

1680
- cStringIO: Implemented readlines() method.
1681

1682 1683 1684 1685 1686
- dbm: Add get() and setdefault() methods to dbm object.  Add constant
  `library' to module that names the library used.  Added doc strings
  and method names to error messages.  Uses configure to determine
  which ndbm.h file to include; Berkeley DB's nbdm and GDBM's ndbm is
  now available options.
1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697

- 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.

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

1702
- mailbox: Mailbox class conforms better to qmail specifications.
1703

Jeremy Hylton's avatar
Jeremy Hylton committed
1704 1705 1706 1707 1708
- marshal: When reading a short, sign-extend on platforms where shorts
  are bigger than 16 bits.  When reading a long, repair the unportable
  sign extension that was being done for 64-bit machines.  (It assumed
  that signed right shift sign-extends.)

1709 1710
- operator: Add contains(), invert(), __invert__() as aliases for
  __contains__(), inv(), and __inv__() respectively.
1711

1712 1713
- os: Add support for popen2() and popen3() on all platforms where
  fork() exists.  (popen4() is still in the works.)
1714

1715
- os: (Windows only:) Add startfile() function that acts like double-
Tim Peters's avatar
Tim Peters committed
1716 1717
  clicking on a file in Explorer (or passing the file name to the
  DOS "start" command).
1718

1719
- os.path: (Windows, DOS:) Treat trailing colon correctly in
Tim Peters's avatar
Tim Peters committed
1720
  os.path.join.  os.path.join("a:", "b") yields "a:b".
1721 1722 1723 1724 1725

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

1726
- posixfile: Remove broken __del__() method.
1727

1728
- py_compile: support CR+LF line terminators in source file.
1729 1730

- readline: Does not immediately exit when ^C is hit when readline and
Jeremy Hylton's avatar
Jeremy Hylton committed
1731
  threads are configured.  Adds definition of rl_library_version.  (The
1732
  latter addition requires GNU readline 2.2 or later.)
1733 1734

- rfc822: Domain literals returned by AddrlistClass method
1735
  getdomainliteral() are now properly wrapped in brackets.
1736 1737

- site: sys.setdefaultencoding() should only be called in case the
Tim Peters's avatar
Tim Peters committed
1738
  standard default encoding ("ascii") is changed. This saves quite a
1739 1740 1741 1742
  few cycles during startup since the first call to
  setdefaultencoding() will initialize the codec registry and the
  encodings package.

1743 1744
- socket: Support for size hint in readlines() method of object returned
  by makefile().
1745

1746
- sre: Added experimental expand() method to match objects.  Does not
Jeremy Hylton's avatar
typo  
Jeremy Hylton committed
1747
  use buffer interface on Unicode strings.  Does not hang if group id
1748 1749
  is followed by whitespace.

1750
- StringIO: Size hint in readlines() is now supported as documented.
1751 1752 1753 1754

- struct: Check ranges for bytes and shorts.

- urllib: Improved handling of win32 proxy settings. Fixed quote and
1755
  quote_plus functions so that the always encode a comma.
1756 1757 1758 1759 1760

- 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.

1761
- UserList: now implements __contains__().
1762

1763
- webbrowser: On Windows, use os.startfile() instead of os.popen(),
1764 1765
  which works around a bug in Norton AntiVirus 2000 that leads directly
  to a Blue Screen freeze.
1766 1767 1768 1769

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

1770 1771 1772 1773 1774
- xml.dom: DOM level 1 support for basic XML.  Includes xml.dom.minidom
  (conventional DOM), and xml.dom.pulldom, which allows building the DOM
  tree only for nodes which are sufficiently interesting to a specific
  application.  Does not provide the HTML-specific extensions.  Still
  undocumented.
1775

1776 1777 1778
- xml.sax: SAX 2 support for Python, including all the handler
  interfaces needed to process XML 1.0 compliant XML.  Some
  documentation is already available.
1779

1780 1781
- pyexpat: Renamed to xml.parsers.expat since this is part of the new,
  packagized XML support.
1782

1783

1784 1785 1786 1787 1788 1789
C API

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

Jeremy Hylton's avatar
Jeremy Hylton committed
1790
- Cleaned up definition of NULL in C source code; all definitions were
1791 1792 1793
  removed and add #error to Python.h if NULL isn't defined after
  #include of stdio.h.

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

1797 1798 1799 1800
- A wrapper API was added for signal() and sigaction().  Instead of
  either function, always use PyOS_getsig() to get a signal handler
  and PyOS_setsig() to set one.  A new convenience typedef
  PyOS_sighandler_t is defined for the type of signal handlers.
1801

1802
- Add PyString_AsStringAndSize() function that provides access to the
1803 1804 1805
  internal data buffer and size of a string object -- or the default
  encoded version of a Unicode object.

Jeremy Hylton's avatar
Jeremy Hylton committed
1806 1807
- PyString_Size() and PyString_AsString() accept Unicode objects.

1808
- The standard header <limits.h> is now included by Python.h (if it
1809 1810
  exists).  INT_MAX and LONG_MAX will always be defined, even if
  <limits.h> is not available.
1811

Jeremy Hylton's avatar
Jeremy Hylton committed
1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823
- PyFloat_FromString takes a second argument, pend, that was
  effectively useless.  It is now officially useless but preserved for
  backwards compatibility.  If the pend argument is not NULL, *pend is
  set to NULL.

- PyObject_GetAttr() and PyObject_SetAttr() now accept Unicode objects
  for the attribute name.  See note on getattr() above.

- A few bug fixes to argument processing for Unicode.
  PyArg_ParseTupleAndKeywords() now accepts "es#" and "es".
  PyArg_Parse() special cases "s#" for Unicode objects; it returns a
  pointer to the default encoded string data instead of to the raw
1824
  UTF-16.
Jeremy Hylton's avatar
Jeremy Hylton committed
1825 1826 1827

- Py_BuildValue accepts B format (for bgen-generated code).

1828

1829 1830 1831 1832 1833
Internals

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

Andrew M. Kuchling's avatar
Andrew M. Kuchling committed
1834
- Added a true unicode_internal_encode() function and fixed the
1835
  unicode_internal_decode function() to support Unicode objects directly
1836 1837
  rather than by generating a copy of the object.

Tim Peters's avatar
Tim Peters committed
1838 1839
- Several of the internal Unicode tables are much smaller now, and
  the source code should be much friendlier to weaker compilers.
1840

Jeremy Hylton's avatar
Jeremy Hylton committed
1841 1842 1843 1844
- In the garbage collector: Fixed bug in collection of tuples.  Fixed
  bug that caused some instances to be removed from the container set
  while they were still live.  Fixed parsing in gc.set_debug() for
  platforms where sizeof(long) > sizeof(int).
Jeremy Hylton's avatar
Jeremy Hylton committed
1845 1846 1847 1848 1849 1850 1851 1852

- Fixed refcount problem in instance deallocation that only occurred
  when Py_REF_DEBUG was defined and Py_TRACE_REFS was not.

- On Windows, getpythonregpath is now protected against null data in
  registry key.

- On Unix, create .pyc/.pyo files with O_EXCL flag to avoid a race
1853
  condition.
Jeremy Hylton's avatar
Jeremy Hylton committed
1854

1855

1856 1857 1858 1859
Build and platform-specific issues

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

Jeremy Hylton's avatar
Jeremy Hylton committed
1860 1861
- Python/C API now properly exposed to dynamically-loaded extension
  modules on Reliant UNIX.
1862 1863 1864 1865 1866

- 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.

Jeremy Hylton's avatar
Jeremy Hylton committed
1867
- Improved support for HP-UX build.  Threads should now be correctly
1868
  configured (on HP-UX 10.20 and 11.00).
1869

Jeremy Hylton's avatar
Jeremy Hylton committed
1870 1871 1872 1873 1874 1875 1876 1877 1878 1879
- Fix largefile support on older NetBSD systems and OpenBSD by adding
  define for TELL64.


Tools and other miscellany

- ftpmirror: Call to main() is wrapped in if __name__ == "__main__".

- freeze: The modulefinder now works with 2.0 opcodes.

1880
- IDLE:
Jeremy Hylton's avatar
Jeremy Hylton committed
1881 1882 1883 1884
  Move hackery of sys.argv until after the Tk instance has been
  created, which allows the application-specific Tkinter
  initialization to be executed if present; also pass an explicit
  className parameter to the Tk() constructor.
1885

1886 1887 1888

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

Guido van Rossum's avatar
Guido van Rossum committed
1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919
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.

1920 1921 1922 1923
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.

Guido van Rossum's avatar
Guido van Rossum committed
1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938
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

1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953
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/.
Guido van Rossum's avatar
Guido van Rossum committed
1954 1955 1956 1957 1958 1959 1960

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

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

1961
    += -= *= /= %= **= <<= >>= &= ^= |=
Guido van Rossum's avatar
Guido van Rossum committed
1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997

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>]

1998
For example, [i**2 for i in range(4)] yields the list [0, 1, 4, 9].
1999
This is more efficient than a for loop with a list.append() call.
Guido van Rossum's avatar
Guido van Rossum committed
2000 2001 2002 2003 2004 2005 2006

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
2007
than a for loop with an if statement and a list.append() call.
Guido van Rossum's avatar
Guido van Rossum committed
2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021

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
2022
Montanaro and Thomas Wouters also contributed.  Described by PEP 202.
Guido van Rossum's avatar
Guido van Rossum committed
2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051


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).

2052
Implemented by Thomas Wouters.  Described by PEP 221.
Guido van Rossum's avatar
Guido van Rossum committed
2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067


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
2068
evaluates to None, the current value of sys.stdout is used.  Thus:
Guido van Rossum's avatar
Guido van Rossum committed
2069 2070 2071 2072 2073 2074 2075

    print >> None, "Hello world"

is equivalent to

    print "Hello world"

2076
Design and implementation by Barry Warsaw.  Described by PEP 214.
Guido van Rossum's avatar
Guido van Rossum committed
2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094


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
2095
performance.  If it proves to be too much of a problem, we'll turn it
Guido van Rossum's avatar
Guido van Rossum committed
2096 2097 2098 2099 2100 2101 2102 2103 2104 2105
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:
2106
zip([1,2,3], [10,20]) returns [(1,10), (2,20)].  See PEP 201.
Guido van Rossum's avatar
Guido van Rossum committed
2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121

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)

2122 2123 2124 2125 2126
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.
Jeremy Hylton's avatar
Jeremy Hylton committed
2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143

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.
Guido van Rossum's avatar
Guido van Rossum committed
2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165

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.


2166 2167 2168
Changed Modules
---------------

2169 2170 2171 2172 2173 2174
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

Jeremy Hylton's avatar
Jeremy Hylton committed
2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187
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
2188 2189
optionally support the RFC 959 REST command.

Jeremy Hylton's avatar
Jeremy Hylton committed
2190 2191 2192 2193 2194
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.

2195 2196 2197 2198 2199 2200 2201
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

Jeremy Hylton's avatar
Jeremy Hylton committed
2202 2203 2204
os/popen2 -- popen2/popen3/popen4 support under Windows.  popen2/popen3
support under Unix.

2205
os/pty -- support for openpty and forkpty
Jeremy Hylton's avatar
Jeremy Hylton committed
2206 2207 2208 2209 2210 2211

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

smtplib -- support for sending very long messages

socket -- new function getfqdn()
2212

Jeremy Hylton's avatar
Jeremy Hylton committed
2213 2214 2215
readline -- new functions to read, write and truncate history files.
The readline section of the library reference manual contains an
example.
Guido van Rossum's avatar
Guido van Rossum committed
2216

2217 2218
select -- add interface to poll system call

Jeremy Hylton's avatar
Jeremy Hylton committed
2219 2220 2221 2222 2223
shutil -- new copyfileobj function

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

2224
Tkinter -- optimization of function flatten
Jeremy Hylton's avatar
Jeremy Hylton committed
2225 2226

urllib -- scans environment variables for proxy configuration,
2227
e.g. http_proxy.
Jeremy Hylton's avatar
Jeremy Hylton committed
2228 2229

whichdb -- recognizes dumbdbm format
2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242


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
----------------------------

2243
None.
2244 2245


Guido van Rossum's avatar
Guido van Rossum committed
2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260
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
2261 2262
and Win64, especially for the new Intel Itanium processor.  Mick also
added large file support for Linux64 and Win64.
Guido van Rossum's avatar
Guido van Rossum committed
2263

Jeremy Hylton's avatar
Jeremy Hylton committed
2264 2265 2266 2267 2268 2269 2270
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.

2271 2272 2273
The PyOS_CheckStack function has been implemented on Windows by
Fredrik Lundh.  It prevents Python from failing with a stack overflow
on Windows.
Jeremy Hylton's avatar
Jeremy Hylton committed
2274 2275 2276

The GC changes resulted in creation of two new slots on object,
tp_traverse and tp_clear.  The augmented assignment changes result in
Guido van Rossum's avatar
Guido van Rossum committed
2277
the creation of a new slot for each in-place operator.
Jeremy Hylton's avatar
Jeremy Hylton committed
2278 2279

The GC API creates new requirements for container types implemented in
Guido van Rossum's avatar
Guido van Rossum committed
2280
C extension modules.  See Include/objimpl.h for details.
Jeremy Hylton's avatar
Jeremy Hylton committed
2281

2282 2283 2284 2285 2286
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.
Jeremy Hylton's avatar
Jeremy Hylton committed
2287

2288 2289 2290
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.
2291

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

2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309

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
Guido van Rossum's avatar
Guido van Rossum committed
2310
under HKEY_CURRENT_USER.  The latter is sufficient for all "normal"
2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324
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\.

2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345

Updates to the changes between 1.5.2 and 1.6
--------------------------------------------

The 1.6 NEWS file can't be changed after the release is done, so here
is some late-breaking news:

New APIs in locale.py: normalize(), getdefaultlocale(), resetlocale(),
and changes to getlocale() and setlocale().

The new module is now enabled per default.

It is not true that the encodings codecs cannot be used for normal
strings: the string.encode() (which is also present on 8-bit strings
!) allows using them for 8-bit strings too, e.g. to convert files from
cp1252 (Windows) to latin-1 or vice-versa.

Japanese codecs are available from Tamito KAJIYAMA:
http://pseudo.grad.sccs.chukyo-u.ac.jp/~kajiyama/python/


2346
======================================================================