NEWS 96.7 KB
Newer Older
1 2 3 4
+++++++++++
Python News
+++++++++++

5 6
(editors: check NEWS.help for information about editing NEWS using ReST.)

Tim Peters's avatar
Tim Peters committed
7 8 9
What's New in Python 2.3 alpha 1?
=================================

10 11
*XXX Release date: DD-MMM-2002 XXX*

Tim Peters's avatar
Tim Peters committed
12
Type/class unification and new-style classes
13
--------------------------------------------
14

15 16 17
- Exposed the PyImport_FrozenModules variable in import.c through
  imp.get_frozenmodules() and imp.set_frozenmodules().  This is
  useful for freezing tools written in Python that use Python for
18 19
  bootstrapping the frozen application.  (XXX: this feature will be
  backed out if the zipfile import mechanism gets in before 2.3.a1.)
20

21 22
- One can now assign to __bases__ and __name__ of new-style classes.

23 24
- dict() now accepts keyword arguments so that dict(one=1, two=2)
  is the equivalent of {"one": 1, "two": 2}.  Accordingly,
25
  the existing (but undocumented) 'items' keyword argument has
26
  been eliminated.  This means that dict(items=someMapping) now has
27 28
  a different meaning than before.

29 30 31
- int() now returns a long object if the argument is outside the
  integer range, so int("4"*1000), int(1e200) and int(1L<<1000) will
  all return long objects instead of raising an OverflowError.
Tim Peters's avatar
Tim Peters committed
32

Andrew M. Kuchling's avatar
Andrew M. Kuchling committed
33
- Assignment to __class__ is disallowed if either the old or the new
34
  class is a statically allocated type object (such as defined by an
35
  extension module).  This prevents anomalies like 2.__class__ = bool.
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83

- New-style object creation and deallocation have been sped up
  significantly; they are now faster than classic instance creation
  and deallocation.

- The __slots__ variable can now mention "private" names, and the
  right thing will happen (e.g. __slots__ = ["__foo"]).

- The built-ins slice() and buffer() are now callable types.  The
  types classobj (formerly class), code, function, instance, and
  instancemethod (formerly instance-method), which have no built-in
  names but are accessible through the types module, are now also
  callable.  The type dict-proxy is renamed to dictproxy.

- Cycles going through the __class__ link of a new-style instance are
  now detected by the garbage collector.

- Classes using __slots__ are now properly garbage collected.
  [SF bug 519621]

- Tightened the __slots__ rules: a slot name must be a valid Python
  identifier.

- The constructor for the module type now requires a name argument and
  takes an optional docstring argument.  Previously, this constructor
  ignored its arguments.  As a consequence, deriving a class from a
  module (not from the module type) is now illegal; previously this
  created an unnamed module, just like invoking the module type did.
  [SF bug 563060]

- A new type object, 'basestring', is added.  This is a common base type
  for 'str' and 'unicode', and can be used instead of
  types.StringTypes, e.g. to test whether something is "a string":
  isinstance(x, basestring) is True for Unicode and 8-bit strings.  This
  is an abstract base class and cannot be instantiated directly.

- Changed new-style class instantiation so that when C's __new__
  method returns something that's not a C instance, its __init__ is
  not called.  [SF bug #537450]

- Fixed super() to work correctly with class methods.  [SF bug #535444]

- If you try to pickle an instance of a class that has __slots__ but
  doesn't define or override __getstate__, a TypeError is now raised.
  This is done by adding a bozo __getstate__ to the class that always
  raises TypeError.  (Before, this would appear to be pickled, but the
  state of the slots would be lost.)

Tim Peters's avatar
Tim Peters committed
84
Core and builtins
85
-----------------
Tim Peters's avatar
Tim Peters committed
86

87 88 89 90 91 92 93 94 95 96
- Thanks to Armin Rigo, the last known way to provoke a system crash
  by cleverly arranging for a comparison function to mutate a list
  during a list.sort() operation has been fixed.  The effect of
  attempting to mutate a list, or even to inspect its contents or
  length, while a sort is in progress, is not defined by the language.
  The C implementation of Python 2.3 attempts to detect mutations,
  and raise ValueError if one occurs, but there's no guarantee that
  all mutations will be caught, or that any will be caught across
  releases or implementations.

Martin v. Löwis's avatar
Martin v. Löwis committed
97
- Unicode file name processing for Windows (PEP 277) is implemented.
98 99
  All platforms now have an os.path.supports_unicode_filenames attribute,
  which is set to True on Windows NT/2000/XP, and False elsewhere.
Martin v. Löwis's avatar
Martin v. Löwis committed
100

101 102 103
- Codec error handling callbacks (PEP 293) are implemented.
  Error handling in unicode.encode or str.decode can now be customized.

104 105 106 107
- A subtle change to the semantics of the built-in function intern():
  interned strings are no longer immortal.  You must keep a reference
  to the return value intern() around to get the benefit.

108 109 110
- Use of 'None' as a variable, argument or attribute name now
  issues a SyntaxWarning.  In the future, None may become a keyword.

Michael W. Hudson's avatar
Michael W. Hudson committed
111 112 113 114 115
- SET_LINENO is gone.  co_lnotab is now consulted to determine when to
  call the trace function.  C code that accessed f_lineno should call
  PyCode_Addr2Line instead (f_lineno is still there, but not kept up
  to date).

116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138
- There's a new warning category, FutureWarning.  This is used to warn
  about a number of situations where the value or sign of an integer
  result will change in Python 2.4 as a result of PEP 237 (integer
  unification).  The warnings implement stage B0 mentioned in that
  PEP.  The warnings are about the following situations:

    - Octal and hex literals without 'L' prefix in the inclusive range
      [0x80000000..0xffffffff]; these are currently negative ints, but
      in Python 2.4 they will be positive longs with the same bit
      pattern.

    - Left shifts on integer values that cause the outcome to lose
      bits or have a different sign than the left operand.  To be
      precise: x<<n where this currently doesn't yield the same value
      as long(x)<<n; in Python 2.4, the outcome will be long(x)<<n.

    - Conversions from ints to string that show negative values as
      unsigned ints in the inclusive range [0x80000000..0xffffffff];
      this affects the functions hex() and oct(), and the string
      formatting codes %u, %o, %x, and %X.  In Python 2.4, these will
      show signed values (e.g. hex(-1) currently returns "0xffffffff";
      in Python 2.4 it will return "-0x1").

139 140 141 142
    - The bits manipulated under the cover by sys.setcheckinterval() have
      been changed.  Both the check interval and the ticker used to be
      per-thread values.  They are now just a pair of global variables.  In
      addition, the default check interval was boosted from 10 to 100
143 144 145 146
      bytecode instructions.  This may have some effect on systems that
      relied on the old default value.  In particular, in multi-threaded
      applications which try to be highly responsive, response time will
      increase by some (perhaps imperceptible) amount.
147

148 149 150 151 152
- When multiplying very large integers, a version of the so-called
  Karatsuba algorithm is now used.  This is most effective if the
  inputs have roughly the same size.  If they both have about N digits,
  Karatsuba multiplication has O(N**1.58) runtime (the exponent is
  log_base_2(3)) instead of the previous O(N**2).  Measured results may
153 154 155 156 157 158 159
  be better or worse than that, depending on platform quirks.  Besides
  the O() improvement in raw instruction count, the Karatsuba algorithm
  appears to have much better cache behavior on extremely large integers
  (starting in the ballpark of a million bits).  Note that this is a
  simple implementation, and there's no intent here to compete with,
  e.g., GMP.  It gives a very nice speedup when it applies, but a package
  devoted to fast large-integer arithmetic should run circles around it.
160

161 162 163
- u'%c' will now raise a ValueError in case the argument is an
  integer outside the valid range of Unicode code point ordinals.

164 165 166 167 168 169 170 171 172 173
- The tempfile module has been overhauled for enhanced security.  The
  mktemp() function is now deprecated; new, safe replacements are
  mkstemp() (for files) and mkdtemp() (for directories), and the
  higher-level functions NamedTemporaryFile() and TemporaryFile().
  Use of some global variables in this module is also deprecated; the
  new functions have keyword arguments to provide the same
  functionality.  All Lib, Tools and Demo modules that used the unsafe
  interfaces have been updated to use the safe replacements.  Thanks
  to Zack Weinberg!

174 175 176 177 178
- When x is an object whose class implements __mul__ and __rmul__,
  1.0*x would correctly invoke __rmul__, but 1*x would erroneously
  invoke __mul__.  This was due to the sequence-repeat code in the int
  type.  This has been fixed now.

179 180 181 182
- Previously, "str1 in str2" required str1 to be a string of length 1.
  This restriction has been relaxed to allow str1 to be a string of
  any length.  Thus "'el' in 'hello world'" returns True now.

183 184 185 186 187 188 189 190
- File objects are now their own iterators.  For a file f, iter(f) now
  returns f (unless f is closed), and f.next() is similar to
  f.readline() when EOF is not reached; however, f.next() uses a
  readahead buffer that messes up the file position, so mixing
  f.next() and f.readline() (or other methods) doesn't work right.
  Calling f.seek() drops the readahead buffer, but other operations
  don't.  It so happens that this gives a nice additional speed boost
  to "for line in file:"; the xreadlines method and corresponding
191
  module are now obsolete.  Thanks to Oren Tirosh!
192

193 194 195
- Encoding declarations (PEP 263, phase 1) have been implemented.  A
  comment of the form "# -*- coding: <encodingname> -*-" in the first
  or second line of a Python source file indicates the encoding.
196

197 198 199 200 201 202 203 204
- list.sort() has a new implementation.  While cross-platform results
  may vary, and in data-dependent ways, this is much faster on many
  kinds of partially ordered lists than the previous implementation,
  and reported to be just as fast on randomly ordered lists on
  several major platforms.  This sort is also stable (if A==B and A
  precedes B in the list at the start, A precedes B after the sort too),
  although the language definition does not guarantee stability.  A
  potential drawback is that list.sort() may require temp space of
205
  len(list)*2 bytes (``*4`` on a 64-bit machine).  It's therefore possible
206 207 208
  for list.sort() to raise MemoryError now, even if a comparison function
  does not.  See <http://www.python.org/sf/587076> for full details.

209 210 211 212 213 214 215 216
- All standard iterators now ensure that, once StopIteration has been
  raised, all future calls to next() on the same iterator will also
  raise StopIteration.  There used to be various counterexamples to
  this behavior, which could caused confusion or subtle program
  breakage, without any benefits.  (Note that this is still an
  iterator's responsibility; the iterator framework does not enforce
  this.)

217 218
- Ctrl+C handling on Windows has been made more consistent with
  other platforms.  KeyboardInterrupt can now reliably be caught,
219
  and Ctrl+C at an interactive prompt no longer terminates the
220
  process under NT/2k/XP (it never did under Win9x).  Ctrl+C will
221 222
  interrupt time.sleep() in the main thread, and any child processes
  created via the popen family (on win2k; we can't make win9x work
223 224
  reliably) are also interrupted (as generally happens on for Linux/Unix.)
  [SF bugs 231273, 439992 and 581232]
225

226 227 228 229
- sys.getwindowsversion() has been added on Windows.  This
  returns a tuple with information about the version of Windows
  currently running.

230 231 232 233 234
- Slices and repetitions of buffer objects now consistently return
  a string.  Formerly, strings would be returned most of the time,
  but a buffer object would be returned when the repetition count
  was one or when the slice range was all inclusive.

235 236 237
- Unicode objects in sys.path are no longer ignored but treated
  as directory names.

238 239 240
- Fixed string.startswith and string.endswith builtin methods
  so they accept negative indices.  [SF bug 493951]

241 242 243
- Fixed a bug with a continue inside a try block and a yield in the
  finally clause.  [SF bug 567538]

244
- Most builtin sequences now support "extended slices", i.e. slices
245 246
  with a third "stride" parameter.  For example, "hello world"[::-1]
  gives "dlrow olleh".
247

248 249 250 251 252 253
- A new warning PendingDeprecationWarning was added to provide
  direction on features which are in the process of being deprecated.
  The warning will not be printed by default.  To see the pending
  deprecations, use -Walways::PendingDeprecationWarning::
  as a command line option or warnings.filterwarnings() in code.

254 255 256 257 258
- Deprecated features of xrange objects have been removed as
  promised.  The start, stop, and step attributes and the tolist()
  method no longer exist.  xrange repetition and slicing have been
  removed.

259 260 261 262
- New builtin function enumerate(x), from PEP 279.  Example:
  enumerate("abc") is an iterator returning (0,"a"), (1,"b"), (2,"c").
  The argument can be an arbitrary iterable object.

263 264 265 266
- The assert statement no longer tests __debug__ at runtime.  This means
  that assert statements cannot be disabled by assigning a false value
  to __debug__.

267 268 269 270
- A method zfill() was added to str and unicode, that fills a numeric
  string to the left with zeros.  For example,
  "+123".zfill(6) -> "+00123".

271 272 273 274
- Complex numbers supported divmod() and the // and % operators, but
  these make no sense.  Since this was documented, they're being
  deprecated now.

275 276 277
- String and unicode methods lstrip(), rstrip() and strip() now take
  an optional argument that specifies the characters to strip.  For
  example, "Foo!!!?!?!?".rstrip("?!") -> "Foo".
Guido van Rossum's avatar
Guido van Rossum committed
278

279 280 281 282 283
- There's a new dictionary constructor (a class method of the dict
  class), dict.fromkeys(iterable, value=None).  It constructs a
  dictionary with keys taken from the iterable and all values set to a
  single value.  It can be used for building sets and for removing
  duplicates from sequences.
284

Guido van Rossum's avatar
Guido van Rossum committed
285 286 287
- Added a new dict method pop(key).  This removes and returns the
  value corresponding to key.  [SF patch #539949]

Guido van Rossum's avatar
Guido van Rossum committed
288 289 290
- A new built-in type, bool, has been added, as well as built-in
  names for its two values, True and False.  Comparisons and sundry
  other operations that return a truth value have been changed to
Andrew M. Kuchling's avatar
Andrew M. Kuchling committed
291
  return a bool instead.  Read PEP 285 for an explanation of why this
Guido van Rossum's avatar
Guido van Rossum committed
292 293
  is backward compatible.

Guido van Rossum's avatar
Guido van Rossum committed
294 295 296 297 298 299
- Fixed two bugs reported as SF #535905: under certain conditions,
  deallocating a deeply nested structure could cause a segfault in the
  garbage collector, due to interaction with the "trashcan" code;
  access to the current frame during destruction of a local variable
  could access a pointer to freed memory.

Guido van Rossum's avatar
Guido van Rossum committed
300 301 302 303 304 305
- The optional object allocator ("pymalloc") has been enabled by
  default.  The recommended practice for memory allocation and
  deallocation has been streamlined.  A header file is included,
  Misc/pymemcompat.h, which can be bundled with 3rd party extensions
  and lets them use the same API with Python versions from 1.5.2
  onwards.
306

307 308 309
- PyErr_Display will provide file and line information for all exceptions
  that have an attribute print_file_and_line, not just SyntaxErrors.

310 311 312
- The UTF-8 codec will now encode and decode Unicode surrogates
  correctly and without raising exceptions for unpaired ones.

313 314 315 316 317 318
- Universal newlines (PEP 278) is implemented.  Briefly, using 'U'
  instead of 'r' when opening a text file for reading changes the line
  ending convention so that any of '\r', '\r\n', and '\n' is
  recognized (even mixed in one file); all three are converted to
  '\n', the standard Python line end character.

319 320 321 322
- file.xreadlines() now raises a ValueError if the file is closed:
  Previously, an xreadlines object was returned which would raise
  a ValueError when the xreadlines.next() method was called.

Andrew M. Kuchling's avatar
Andrew M. Kuchling committed
323
- sys.exit() inadvertently allowed more than one argument.
324 325
  An exception will now be raised if more than one argument is used.

Tim Peters's avatar
Tim Peters committed
326
Extension modules
327
-----------------
Tim Peters's avatar
Tim Peters committed
328

329 330 331
- _tkinter now returns Tcl objects, instead of strings. Objects which
  have Python equivalents are converted to Python objects, other objects
  are wrapped. This can be configured through the wantobjects method,
332
  or Tkinter.wantobjects.
333

Andrew M. Kuchling's avatar
Andrew M. Kuchling committed
334
- The PyBSDDB wrapper around the Sleepycat Berkeley DB library has been
Martin v. Löwis's avatar
Martin v. Löwis committed
335 336 337 338
  added as the package bsddb. The traditional bsddb module is still
  available in source code, but not built automatically anymore, and
  is now named bsddb185.

339 340
- unicodedata was updated to Unicode 3.2. It supports normalization
  and names for Hangul syllables and CJK unified ideographs.
341

342 343
- resource.getrlimit() now returns longs instead of ints.

Martin v. Löwis's avatar
Martin v. Löwis committed
344 345 346
- readline now dynamically adjusts its input/output stream if
  sys.stdin/stdout changes.

347 348 349 350
- The _tkinter module (and hence Tkinter) has dropped support for
  Tcl/Tk 8.0 and 8.1.  Only Tcl/Tk versions 8.2, 8.3 and 8.4 are
  supported.

351 352
- cPickle.BadPickleGet is now a class.

353 354
- The time stamps in os.stat_result are floating point numbers
  after stat_float_times has been called.
355

356 357 358
- If the size passed to mmap.mmap() is larger than the length of the
  file on non-Windows platforms, a ValueError is raised. [SF bug 585792]

359 360
- The xreadlines module is slated for obsolescence.

361 362 363
- The strptime function in the time module is now always available (a
  Python implementation is used when the C library doesn't define it).

364 365 366 367
- The 'new' module is no longer an extension, but a Python module that
  only exists for backwards compatibility.  Its contents are no longer
  functions but callable type objects.

368
- The bsddb.*open functions can now take 'None' as a filename.
369
  This will create a temporary in-memory bsddb that won't be
370
  written to disk.
371

372 373
- posix.lchown, posix.killpg, posix.mknod, and posix.getpgid have been
  added where available.
374

375 376
- The locale module now exposes the C library's gettext interface. It
  also has a new function getpreferredencoding.
377

Tim Peters's avatar
Tim Peters committed
378 379 380 381 382
- A security hole ("double free") was found in zlib-1.1.3, a popular
  third party compression library used by some Python modules.  The
  hole was quickly plugged in zlib-1.1.4, and the Windows build of
  Python now ships with zlib-1.1.4.

383 384
- pwd, grp, and resource return enhanced tuples now, with symbolic
  field names.
385

386 387 388 389 390
- array.array is now a type object. A new format character
  'u' indicates Py_UNICODE arrays. For those, .tounicode and
  .fromunicode methods are available. Arrays now support __iadd__
  and __imul__.

Neal Norwitz's avatar
Neal Norwitz committed
391
- dl now builds on every system that has dlfcn.h.  Failure in case
392 393 394
  of sizeof(int)!=sizeof(long)!=sizeof(void*) is delayed until dl.open
  is called.

Michael W. Hudson's avatar
Michael W. Hudson committed
395 396 397
- signal.sigpending, signal.sigprocmask and signal.sigsuspend have
  been added where available.

398 399 400 401
- The sys module acquired a new attribute, api_version, which evaluates
  to the value of the PYTHON_API_VERSION macro with which the
  interpreter was compiled.

402 403 404
- Fixed bug #470582: sre module would return a tuple (None, 'a', 'ab')
  when applying the regular expression '^((a)c)?(ab)$' on 'ab'. It now
  returns (None, None, 'ab'), as expected. Also fixed handling of
405
  lastindex/lastgroup match attributes in similar cases. For example,
406 407 408
  when running the expression r'(a)(b)?b' over 'ab', lastindex must be
  1, not 2.

409 410 411 412 413
- Fixed bug #581080: sre scanner was not checking the buffer limit
  before increasing the current pointer. This was creating an infinite
  loop in the search function, once the pointer exceeded the buffer
  limit.

414 415 416 417
- The os.fdopen function now enforces a file mode starting with the
  letter 'r', 'w' or 'a', otherwise a ValueError is raised. This fixes
  bug #623464.

Tim Peters's avatar
Tim Peters committed
418
Library
419
-------
Tim Peters's avatar
Tim Peters committed
420

421 422 423
- doctest.testmod can now be called without argument, which means to
  test the current module.

424 425 426 427 428 429
- When cancelling a server that implemented threading with a keyboard
  interrupt, the server would shut down but not terminate (waiting on
  client threads). A new member variable, daemon_threads, was added to
  the ThreadingMixIn class in SocketServer.py to make it explicit that
  this behavior needs to be controlled.

Guido van Rossum's avatar
Guido van Rossum committed
430
- A new module, optparse, provides a fancy alternative to getopt for
Andrew M. Kuchling's avatar
Andrew M. Kuchling committed
431
  command line parsing.  It is a slightly modified version of Greg
Guido van Rossum's avatar
Guido van Rossum committed
432 433
  Ward's Optik package.

434 435 436 437 438 439 440
- UserDict.py now defines a DictMixin class which defines all dictionary
  methods for classes that already have a minimum mapping interface.
  This greatly simplifies writing classes that need to be substitutable
  for dictionaries (such as the shelve module).

- shelve.py now subclasses from UserDict.DictMixin.  Now shelve supports
  all dictionary methods.  This eases the transition to persistent
Andrew M. Kuchling's avatar
Andrew M. Kuchling committed
441
  storage for scripts originally written with dictionaries in mind.
442

443 444 445 446
- shelve.open and the various classes in shelve.py now accept an optional
  binary flag, which defaults to False.  If True, the values stored in the
  shelf are binary pickles.

447 448 449
- A new package, logging, implements the logging API defined by PEP
  282.  The code is written by Vinay Sajip.

450 451 452
- StreamReader, StreamReaderWriter and StreamRecoder in the codecs
  modules are iterators now.

453 454 455 456 457 458
- gzip.py now handles files exceeding 2GB.  Files over 4GB also work
  now (provided the OS supports it, and Python is configured with large
  file support), but in that case the underlying gzip file format can
  record only the least-significant 32 bits of the file size, so that
  some tools working with gzipped files may report an incorrect file
  size.
459

460 461 462
- xml.sax.saxutils.unescape has been added, to replace entity references
  with their entity value.

463 464
- Queue.Queue.{put,get} now support an optional timeout argument.

465 466
- Various features of Tk 8.4 are exposed in Tkinter.py. The multiple
  option of tkFileDialog is exposed as function askopenfile{,name}s.
467

468 469
- Various configure methods of Tkinter have been stream-lined, so that
  tag_configure, image_configure, window_configure now return a
470
  dictionary when invoked with no argument.
471

472 473 474 475 476 477 478 479 480 481 482
- Importing the readline module now no longer has the side effect of
  calling setlocale(LC_CTYPE, "").  The initial "C" locale, or
  whatever locale is explicitly set by the user, is preserved.  If you
  want repr() of 8-bit strings in your preferred encoding to preserve
  all printable characters of that encoding, you have to add the
  following code to your $PYTHONSTARTUP file or to your application's
  main():

    import locale
    locale.setlocale(locale.LC_CTYPE, "")

483 484 485
- shutil.move was added. shutil.copytree now reports errors as an
  exception at the end, instead of printing error messages.

486 487 488 489 490 491
- Encoding name normalization was generalized to not only
  replace hyphens with underscores, but also all other non-alphanumeric
  characters (with the exception of the dot which is used for Python
  package names during lookup). The aliases.py mapping was updated
  to the new standard.

492 493 494 495 496
- mimetypes has two new functions: guess_all_extensions() which
  returns a list of all known extensions for a mime type, and
  add_type() which adds one mapping between a mime type and
  an extension to the database.

497 498 499 500 501 502 503
- New module: sets, defines the class Set that implements a mutable
  set type using the keys of a dict to represent the set.  There's
  also a class ImmutableSet which is useful when you need sets of sets
  or when you need to use sets as dict keys, and a class BaseSet which
  is the base class of the two.  (This is not documented yet, but
  help(sets) gives a wealth of information.)

504 505
- Added operator.pow(a,b) which is equivalent to a**b.

506
- Added random.sample(population,k) for random sampling without replacement.
507
  Returns a k length list of unique elements chosen from the population.
508

509 510 511 512 513
- random.randrange(-sys.maxint-1, sys.maxint) no longer raises
  OverflowError.  That is, it now accepts any combination of 'start'
  and 'stop' arguments so long as each is in the range of Python's
  bounded integers.

514 515 516 517
- New "algorithms" module: heapq, implements a heap queue.  Thanks to
  Kevin O'Connor for the code and François Pinard for an entertaining
  write-up explaining the theory and practical uses of heaps.

Marc-André Lemburg's avatar
Marc-André Lemburg committed
518 519
- New encoding for the Palm OS character set: palmos.

520 521 522 523 524
- binascii.crc32() and the zipfile module had problems on some 64-bit
  platforms.  These have been fixed.  On a platform with 8-byte C longs,
  crc32() now returns a signed-extended 4-byte result, so that its value
  as a Python int is equal to the value computed a 32-bit platform.

525 526 527
- xml.dom.minidom.toxml and toprettyxml now take an optional encoding
  argument.

Guido van Rossum's avatar
Guido van Rossum committed
528 529 530 531 532 533
- Some fixes in the copy module: when an object is copied through its
  __reduce__ method, there was no check for a __setstate__ method on
  the result [SF patch 565085]; deepcopy should treat instances of
  custom metaclasses the same way it treats instances of type 'type'
  [SF patch 560794].

534 535 536
- Sockets now support timeout mode.  After s.settimeout(T), where T is
  a float expressing seconds, subsequent operations raise an exception
  if they cannot be completed within T seconds.  To disable timeout
537 538 539
  mode, use s.settimeout(None).  There's also a module function,
  socket.setdefaulttimeout(T), which sets the default for all sockets
  created henceforth.
540 541 542

- getopt.gnu_getopt was added.  This supports GNU-style option
  processing, where options can be mixed with non-option arguments.
543

Michael W. Hudson's avatar
Michael W. Hudson committed
544 545 546 547
- Stop using strings for exceptions.  String objects used for
  exceptions are now classes deriving from Exception.  The objects
  changed were: Tkinter.TclError, bdb.BdbQuit, macpath.norm_error,
  tabnanny.NannyNag, and xdrlib.Error.
548

549 550 551 552 553 554
- Constants BOM_UTF8, BOM_UTF16, BOM_UTF16_LE, BOM_UTF16_BE,
  BOM_UTF32, BOM_UTF32_LE and BOM_UTF32_BE that represent the Byte
  Order Mark in UTF-8, UTF-16 and UTF-32 encodings for little and
  big endian systems were added to the codecs module. The old names
  BOM32_* and BOM64_* were off by a factor of 2.

555
- Added conversion functions math.degrees() and math.radians().
556

557 558 559 560 561 562 563
- ftplib.retrlines() now tests for callback is None rather than testing
  for False.  Was causing an error when given a callback object which
  was callable but also returned len() as zero.  The change may
  create new breakage if the caller relied on the undocumented behavior
  and called with callback set to [] or some other False value not
  identical to None.

564 565 566 567 568 569 570
- random.gauss() uses a piece of hidden state used by nothing else,
  and the .seed() and .whseed() methods failed to reset it.  In other
  words, setting the seed didn't completely determine the sequence of
  results produced by random.gauss().  It does now.  Programs repeatedly
  mixing calls to a seed method with calls to gauss() may see different
  results now.

571 572 573
- The pickle.Pickler class grew a clear_memo() method to mimic that
  provided by cPickle.Pickler.

574 575 576 577 578 579 580 581 582
- difflib's SequenceMatcher class now does a dynamic analysis of
  which elements are so frequent as to constitute noise.  For
  comparing files as sequences of lines, this generally works better
  than the IS_LINE_JUNK function, and function ndiff's linejunk
  argument defaults to None now as a result.  A happy benefit is
  that SequenceMatcher may run much faster now when applied
  to large files with many duplicate lines (for example, C program
  text with lots of repeated "}" and "return NULL;" lines).

583 584
- New Text.dump() method in Tkinter module.

585 586 587 588 589 590 591 592 593
- New distutils commands for building packagers were added to
  support pkgtool on Solaris and swinstall on HP-UX.

- distutils now has a new abstract binary packager base class
  command/bdist_packager, which simplifies writing packagers.
  This will hopefully provide the missing bits to encourage
  people to submit more packagers, e.g. for Debian, FreeBSD
  and other systems.

594 595 596 597
- The UTF-16, -LE and -BE stream readers now raise a
  NotImplementedError for all calls to .readline(). Previously, they
  used to just produce garbage or fail with an encoding error --
  UTF-16 is a 2-byte encoding and the C lib's line reading APIs don't
598 599
  work well with these.

600 601
- compileall now supports quiet operation.

Andrew M. Kuchling's avatar
Andrew M. Kuchling committed
602
- The BaseHTTPServer now implements optional HTTP/1.1 persistent
603 604
  connections.

605 606 607 608
- socket module: the SSL support was broken out of the main
  _socket module C helper and placed into a new _ssl helper
  which now gets imported by socket.py if available and working.

609 610 611
- encodings package: added aliases for all supported IANA character
  sets

612 613 614 615
- ftplib: to safeguard the user's privacy, anonymous login will use
  "anonymous@" as default password, rather than the real user and host
  name.

616 617 618 619
- webbrowser: tightened up the command passed to os.system() so that
  arbitrary shell code can't be executed because a bogus URL was
  passed in.

620
- gettext.translation has an optional fallback argument, and
621
  gettext.find an optional all argument. Translations will now fallback
622 623
  on a per-message basis. The module supports plural forms, by means
  of gettext.[d]ngettext and Translation.[u]ngettext.
624

625 626
- distutils bdist commands now offer a --skip-build option.

Walter Dörwald's avatar
Walter Dörwald committed
627 628
- warnings.warn now accepts a Warning instance as first argument.

629 630 631 632
- The xml.sax.expatreader.ExpatParser class will no longer create
  circular references by using itself as the locator that gets passed
  to the content handler implementation.  [SF bug #535474]

633 634 635 636 637 638
- The email.Parser.Parser class now properly parses strings regardless
  of their line endings, which can be any of \r, \n, or \r\n (CR, LF,
  or CRLF).  Also, the Header class's constructor default arguments
  has changed slightly so that an explicit maxlinelen value is always
  honored.

639 640 641 642 643 644 645 646
- distutils' build_ext command now links c++ extensions with the c++
  compiler available in the Makefile or CXX environment variable, if
  running under *nix.

- New module bz2: provides a comprehensive interface for the bz2 compression
  library.  It implements a complete file interface, one-shot (de)compression
  functions, and types for sequential (de)compression.

647 648 649
- New pdb command `pp' which is like `p' except that it pretty-prints
  the value of its expression argument.

650 651 652 653
- Now bdist_rpm distutils command understands a verify_script option in
  the config file, including the contents of the referred filename in
  the "%verifyscript" section of the rpm spec file.

Gustavo Niemeyer's avatar
Gustavo Niemeyer committed
654 655 656 657
- Fixed bug #495695: webbrowser module would run graphic browsers in a
  unix environment even if DISPLAY was not set. Also, support for
  skipstone browser was included.

Tim Peters's avatar
Tim Peters committed
658
Tools/Demos
659
-----------
Tim Peters's avatar
Tim Peters committed
660

661 662 663
- pygettext.py now supports globbing on Windows, and accepts module
  names in addition to accepting file names.

Guido van Rossum's avatar
Guido van Rossum committed
664 665 666 667 668
- The SGI demos (Demo/sgi) have been removed.  Nobody thought they
  were interesting any more.  (The SGI library modules and extensions
  are still there; it is believed that at least some of these are
  still used and useful.)

Fred Drake's avatar
Fred Drake committed
669 670 671 672
- IDLE supports the new encoding declarations (PEP 263); it can also
  deal with legacy 8-bit files if they use the locale's encoding. It
  allows non-ASCII strings in the interactive shell and executes them
  in the locale's encoding.
Martin v. Löwis's avatar
Martin v. Löwis committed
673

674 675 676 677
- freeze.py now produces binaries which can import shared modules,
  unlike before when this failed due to missing symbol exports in
  the generated binary.

Tim Peters's avatar
Tim Peters committed
678
Build
679
-----
Tim Peters's avatar
Tim Peters committed
680

681 682
- On Unix, IDLE is now installed automatically.

683 684 685
- The fpectl module is not built by default; it's dangerous or useless
  except in the hands of experts.

686
- The public Python C API will generally be declared using PyAPI_FUNC
687 688 689
  and PyAPI_DATA macros, while Python extension module init functions
  will be declared with PyMODINIT_FUNC.  DL_EXPORT/DL_IMPORT macros
  are deprecated.
690

691 692 693 694 695 696 697 698
- A bug was fixed that could cause COUNT_ALLOCS builds to segfault, or
  get into infinite loops, when a new-style class got garbage-collected.
  Unfortunately, to avoid this, the way COUNT_ALLOCS works requires
  that new-style classes be immortal in COUNT_ALLOCS builds.  Note that
  COUNT_ALLOCS is not enabled by default, in either release or debug
  builds, and that new-style classes are immortal only in COUNT_ALLOCS
  builds.

699 700 701 702 703 704 705 706 707
- Compiling out the cyclic garbage collector is no longer an option.
  The old symbol WITH_CYCLE_GC is now ignored, and Python.h arranges
  that it's always defined (for the benefit of any extension modules
  that may be conditionalizing on it).  A bonus is that any extension
  type participating in cyclic gc can choose to participate in the
  Py_TRASHCAN mechanism now too; in the absence of cyclic gc, this used
  to require editing the core to teach the trashcan mechanism about the
  new type.

708
- According to Annex F of the current C standard,
709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725

    The Standard C macro HUGE_VAL and its float and long double analogs,
    HUGE_VALF and HUGE_VALL, expand to expressions whose values are
    positive infinities.

  Python only uses the double HUGE_VAL, and only to #define its own symbol
  Py_HUGE_VAL.  Some platforms have incorrect definitions for HUGE_VAL.
  pyport.h used to try to worm around that, but the workarounds triggered
  other bugs on other platforms, so we gave up.  If your platform defines
  HUGE_VAL incorrectly, you'll need to #define Py_HUGE_VAL to something
  that works on your platform.  The only instance of this I'm sure about
  is on an unknown subset of Cray systems, described here:

  http://www.cray.com/swpubs/manuals/SN-2194_2.0/html-SN-2194_2.0/x3138.htm

  Presumably 2.3a1 breaks such systems.  If anyone uses such a system, help!

726 727 728 729
- The configure option --without-doc-strings can be used to remove the
  doc strings from the builtin functions and modules; this reduces the
  size of the executable.

730 731 732 733
- The universal newlines option (PEP 278) is on by default.  On Unix
  it can be disabled by passing --without-universal-newlines to the
  configure script.  On other platforms, remove
  WITH_UNIVERSAL_NEWLINES from pyconfig.h.
734

735 736
- On Unix, a shared libpython2.3.so can be created with --enable-shared.

737 738 739
- All uses of the CACHE_HASH, INTERN_STRINGS, and DONT_SHARE_SHORT_STRINGS
  preprocessor symbols were eliminated.  The internal decisions they
  controlled stopped being experimental long ago.
740

741 742 743
- The tools used to build the documentation now work under Cygwin as
  well as Unix.

744 745 746 747 748
- The bsddb and dbm module builds have been changed to try and avoid version
  skew problems and disable linkage with Berkeley DB 1.85 unless the
  installer knows what s/he's doing.  See the section on building these
  modules in the README file for details.

Tim Peters's avatar
Tim Peters committed
749
C API
750
-----
Tim Peters's avatar
Tim Peters committed
751

752 753
- PyNumber_Check() now returns true for string and unicode objects.
  This is a result of these types having a partially defined
754
  tp_as_number slot.  (This is not a feature, but an indication that
Walter Dörwald's avatar
Walter Dörwald committed
755
  PyNumber_Check() is not very useful to determine numeric behavior.
756
  It may be deprecated.)
757

758 759 760 761 762 763 764 765 766 767 768 769 770
- The string object's layout has changed: the pointer member
  ob_sinterned has been replaced by an int member ob_sstate.  On some
  platforms (e.g. most 64-bit systems) this may change the offset of
  the ob_sval member, so as a precaution the API_VERSION has been
  incremented.  The apparently unused feature of "indirect interned
  strings", supported by the ob_sinterned member, is gone.  Interned
  strings are now usually mortal; theres a new API,
  PyString_InternImmortal() that creates immortal interned strings.
  (The ob_sstate member can only take three values; however, while
  making it a char saves a few bytes per string object on average, in
  it also slowed things down a bit because ob_sval was no longer
  aligned.)

771 772 773 774
- The Py_InitModule*() functions now accept NULL for the 'methods'
  argument.  Modules without global functions are becoming more common
  now that factories can be types rather than functions.

775 776 777
- New C API PyUnicode_FromOrdinal() which exposes unichr() at C
  level.

778 779 780 781 782 783
- New functions PyErr_SetExcFromWindowsErr() and
  PyErr_SetExcFromWindowsErrWithFilename(). Similar to
  PyErr_SetFromWindowsErrWithFilename() and
  PyErr_SetFromWindowsErr(), but they allow to specify
  the exception type to raise. Available on Windows.

784 785 786 787
- Py_FatalError() is now declared as taking a const char* argument.  It
  was previously declared without const.  This should not affect working
  code.

788 789 790 791
- Added new macro PySequence_ITEM(o, i) that directly calls
  sq_item without rechecking that o is a sequence and without
  adjusting for negative indices.

792 793 794 795
- PyRange_New() now raises ValueError if the fourth argument is not 1.
  This is part of the removal of deprecated features of the xrange
  object.

796 797 798 799
- PyNumber_Coerce() and PyNumber_CoerceEx() now also invoke the type's
  coercion if both arguments have the same type but this type has the
  CHECKTYPES flag set.  This is to better support proxies.

800 801
- The type of tp_free has been changed from "``void (*)(PyObject *)``" to
  "``void (*)(void *)``".
802 803 804

- PyObject_Del, PyObject_GC_Del are now functions instead of macros.

805 806 807 808 809 810 811
- A type can now inherit its metatype from its base type.  Previously,
  when PyType_Ready() was called, if ob_type was found to be NULL, it
  was always set to &PyType_Type; now it is set to base->ob_type,
  where base is tp_base, defaulting to &PyObject_Type.

- PyType_Ready() accidentally did not inherit tp_is_gc; now it does.

812
- The PyCore_* family of APIs have been removed.
813

Andrew M. Kuchling's avatar
Andrew M. Kuchling committed
814
- The "u#" parser marker will now pass through Unicode objects as-is
815 816
  without going through the buffer API.

817
- The enumerators of cmp_op have been renamed to use the prefix ``PyCmp_``.
818

819 820 821 822 823
- An old #define of ANY as void has been removed from pyport.h.  This
  hasn't been used since Python's pre-ANSI days, and the #define has
  been marked as obsolete since then.  SF bug 495548 says it created
  conflicts with other packages, so keeping it around wasn't harmless.

Tim Peters's avatar
Tim Peters committed
824 825 826
- Because Python's magic number scheme broke on January 1st, we decided
  to stop Python development.  Thanks for all the fish!

827
- Some of us don't like fish, so we changed Python's magic number
828 829
  scheme to a new one. See Python/import.c for details.

Tim Peters's avatar
Tim Peters committed
830
New platforms
831
-------------
Tim Peters's avatar
Tim Peters committed
832

833 834
- OpenVMS is now supported.

Martin v. Löwis's avatar
Martin v. Löwis committed
835 836
- AtheOS is now supported.

Andrew MacIntyre's avatar
Andrew MacIntyre committed
837 838
- the EMX runtime environment on OS/2 is now supported.

839 840
- GNU/Hurd is now supported.

Tim Peters's avatar
Tim Peters committed
841
Tests
842 843
-----

844 845 846
- The regrtest.py script's -u option now provides a way to say "allow
  all resources except this one."  For example, to allow everything
  except bsddb, give the option '-uall,-bsddb'.
Tim Peters's avatar
Tim Peters committed
847 848

Windows
849
-------
Tim Peters's avatar
Tim Peters committed
850

Tim Peters's avatar
Tim Peters committed
851 852 853 854 855
- The Windows distribution now ships with version 4.0.14 of the
  Sleepycat Berkeley database library.  This should be a huge
  improvement over the previous Berkeley DB 1.85, which had many
  bugs.
  XXX What are the licensing issues here?
856 857 858
  XXX If a user has a database created with a previous verion of
  XXX     Python, what must they do to convert it?
  XXX I'm still not sure how to link this thing (see PCbuild/readme.txt).
Tim Peters's avatar
Tim Peters committed
859
  XXX The version # is likely to change before 2.3a1.
Mark Hammond's avatar
Mark Hammond committed
860 861 862
  
- The Windows distribution now ships with a Secure Sockets Library (SLL) 
   module (_ssl.pyd)
Tim Peters's avatar
Tim Peters committed
863

864 865 866
- The Windows distribution now ships with Tcl/Tk version 8.4.1 (it
  previously shipped with Tcl/Tk 8.3.2).

867 868 869 870 871
- When Python is built under a Microsoft compiler, sys.version now
  includes the compiler version number (_MSC_VER).  For example, under
  MSVC 6, sys.version constains the substring "MSC v.1200 ".  1200 is
  the value of _MSC_VER under MSVC 6.

872 873 874 875
- Sometimes the uninstall executable (UNWISE.EXE) vanishes.  One cause
  of that has been fixed in the installer (disabled Wise's "delete in-
  use files" uninstall option).

Guido van Rossum's avatar
Guido van Rossum committed
876 877
- Fixed a bug in urllib's proxy handling in Windows.  [SF bug #503031]

878 879 880
- The installer now installs Start menu shortcuts under (the local
  equivalent of) "All Users" when doing an Admin install.

881 882 883 884
- file.truncate([newsize]) now works on Windows for all newsize values.
  It used to fail if newsize didn't fit in 32 bits, reflecting a
  limitation of MS _chsize (which is no longer used).

885 886 887 888 889
- os.waitpid() is now implemented for Windows, and can be used to block
  until a specified process exits.  This is similar to, but not exactly
  the same as, os.waitpid() on POSIX systems.  If you're waiting for
  a specific process whose pid was obtained from one of the spawn()
  functions, the same Python os.waitpid() code works across platforms.
890 891 892
  See the docs for details.  The docs were changed to clarify that
  spawn functions return, and waitpid requires, a process handle on
  Windows (not the same thing as a Windows process id).
893

894
- New tempfile.TemporaryFile implementation for Windows:  this doesn't
Andrew M. Kuchling's avatar
Andrew M. Kuchling committed
895
  need a TemporaryFileWrapper wrapper anymore, and should be immune
896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916
  to a nasty problem:  before 2.3, if you got a temp file on Windows, it
  got wrapped in an object whose close() method first closed the
  underlying file, then deleted the file.  This usually worked fine.
  However, the spawn family of functions on Windows create (at a low C
  level) the same set of open files in the spawned process Q as were
  open in the spawning process P.  If a temp file f was among them, then
  doing f.close() in P first closed P's C-level file handle on f, but Q's
  C-level file handle on f remained open, so the attempt in P to delete f
  blew up with a "Permission denied" error (Windows doesn't allow
  deleting open files).  This was surprising, subtle, and difficult to
  work around.

- The os module now exports all the symbolic constants usable with the
  low-level os.open() on Windows:  the new constants in 2.3 are
  O_NOINHERIT, O_SHORT_LIVED, O_TEMPORARY, O_RANDOM and O_SEQUENTIAL.
  The others were also available in 2.2:  O_APPEND, O_BINARY, O_CREAT,
  O_EXCL, O_RDONLY, O_RDWR, O_TEXT, O_TRUNC and O_WRONLY.  Contrary
  to Microsoft docs, O_SHORT_LIVED does not seem to imply O_TEMPORARY
  (so specify both if you want both; note that neither is useful unless
  specified with O_CREAT too).

Tim Peters's avatar
Tim Peters committed
917
Mac
918 919 920
----

Yet to be written.
Tim Peters's avatar
Tim Peters committed
921 922


923 924 925
What's New in Python 2.2 final?
===============================

926 927
*Release date: 21-Dec-2001*

928
Type/class unification and new-style classes
929
--------------------------------------------
930

931 932 933
- pickle.py, cPickle: allow pickling instances of new-style classes
  with a custom metaclass.

934
Core and builtins
935
-----------------
936

937 938 939
- weakref proxy object: when comparing, unwrap both arguments if both
  are proxies.

940
Extension modules
941
-----------------
942

943 944 945 946 947 948 949 950 951
- binascii.b2a_base64(): fix a potential buffer overrun when encoding
  very short strings.

- cPickle: the obscure "fast" mode was suspected of causing stack
  overflows on the Mac.  Hopefully fixed this by setting the recursion
  limit much smaller.  If the limit is too low (it only affects
  performance), you can change it by defining PY_CPICKLE_FAST_LIMIT
  when compiling cPickle.c (or in pyconfig.h).

952
Library
953
-------
954

955 956 957 958 959 960 961 962 963
- dumbdbm.py: fixed a dumb old bug (the file didn't get synched at
  close or delete time).

- rfc822.py: fixed a bug where the address '<>' was converted to None
  instead of an empty string (also fixes the email.Utils module).

- xmlrpclib.py: version 1.0.0; uses precision for doubles.

- test suite: the pickle and cPickle tests were not executing any code
Andrew M. Kuchling's avatar
Andrew M. Kuchling committed
964
  when run from the standard regression test.
965

966
Tools/Demos
967
-----------
968 969

Build
970
-----
971 972

C API
973
-----
974 975

New platforms
976
-------------
977 978

Tests
979
-----
980 981

Windows
982
-------
983

984 985 986 987 988 989 990 991 992 993 994
- distutils package: fixed broken Windows installers (bdist_wininst).

- tempfile.py: prevent mysterious warnings when TemporaryFileWrapper
  instances are deleted at process exit time.

- socket.py: prevent mysterious warnings when socket instances are
  deleted at process exit time.

- posixmodule.c: fix a Windows crash with stat() of a filename ending
  in backslash.

995
Mac
996
----
997

998 999 1000 1001
- The Carbon toolbox modules have been upgraded to Universal Headers
  3.4, and experimental CoreGraphics and CarbonEvents modules have
  been added.  All only for framework-enabled MacOSX.

1002

Tim Peters's avatar
Tim Peters committed
1003
What's New in Python 2.2c1?
Tim Peters's avatar
Tim Peters committed
1004 1005
===========================

1006 1007
*Release date: 14-Dec-2001*

Tim Peters's avatar
Tim Peters committed
1008
Type/class unification and new-style classes
1009
--------------------------------------------
Tim Peters's avatar
Tim Peters committed
1010

1011 1012 1013 1014 1015 1016 1017
- Guido's tutorial introduction to the new type/class features has
  been extensively updated.  See

      http://www.python.org/2.2/descrintro.html

  That remains the primary documentation in this area.

1018 1019 1020
- Fixed a leak: instance variables declared with __slots__ were never
  deleted!

Guido van Rossum's avatar
Guido van Rossum committed
1021 1022 1023 1024 1025 1026
- The "delete attribute" method of descriptor objects is called
  __delete__, not __del__.  In previous releases, it was mistakenly
  called __del__, which created an unfortunate overloading condition
  with finalizers.  (The "get attribute" and "set attribute" methods
  are still called __get__ and __set__, respectively.)

Guido van Rossum's avatar
Guido van Rossum committed
1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040
- Some subtle issues with the super built-in were fixed:

  (a) When super itself is subclassed, its __get__ method would still
      return an instance of the base class (i.e., of super).

  (b) super(C, C()).__class__ would return C rather than super.  This
      is confusing.  To fix this, I decided to change the semantics of
      super so that it only applies to code attributes, not to data
      attributes.  After all, overriding data attributes is not
      supported anyway.

  (c) The __get__ method didn't check whether the argument was an
      instance of the type used in creation of the super instance.

1041 1042 1043 1044 1045
- Previously, hash() of an instance of a subclass of a mutable type
  (list or dictionary) would return some value, rather than raising
  TypeError.  This has been fixed.  Also, directly calling
  dict.__hash__ and list.__hash__ now raises the same TypeError
  (previously, these were the same as object.__hash__).
Guido van Rossum's avatar
Guido van Rossum committed
1046

1047 1048 1049 1050
- New-style objects now support deleting their __dict__.  This is for
  all intents and purposes equivalent to assigning a brand new empty
  dictionary, but saves space if the object is not used further.

Tim Peters's avatar
Tim Peters committed
1051
Core and builtins
1052
-----------------
Tim Peters's avatar
Tim Peters committed
1053

Tim Peters's avatar
Tim Peters committed
1054 1055 1056 1057 1058 1059
- -Qnew now works as documented in PEP 238:  when -Qnew is passed on
  the command line, all occurrences of "/" use true division instead
  of classic division.  See the PEP for details.  Note that "all"
  means all instances in library and 3rd-party modules, as well as in
  your own code.  As the PEP says, -Qnew is intended for use only in
  educational environments with control over the libraries in use.
1060 1061 1062 1063
  Note that test_coercion.py in the standard Python test suite fails
  under -Qnew; this is expected, and won't be repaired until true
  division becomes the default (in the meantime, test_coercion is
  testing the current rules).
Tim Peters's avatar
Tim Peters committed
1064

1065 1066 1067 1068
- complex() now only allows the first argument to be a string
  argument, and raises TypeError if either the second arg is a string
  or if the second arg is specified when the first is a string.

Tim Peters's avatar
Tim Peters committed
1069
Extension modules
1070
-----------------
Tim Peters's avatar
Tim Peters committed
1071

1072 1073
- gc.get_referents was renamed to gc.get_referrers.

Tim Peters's avatar
Tim Peters committed
1074
Library
1075
-------
Tim Peters's avatar
Tim Peters committed
1076

1077 1078 1079 1080 1081 1082 1083
- Functions in the os.spawn() family now release the global interpreter
  lock around calling the platform spawn.  They should always have done
  this, but did not before 2.2c1.  Multithreaded programs calling
  an os.spawn function with P_WAIT will no longer block all Python threads
  until the spawned program completes.  It's possible that some programs
  relies on blocking, although more likely by accident than by design.

1084 1085
- webbrowser defaults to netscape.exe on OS/2 now.

1086 1087
- Tix.ResizeHandle exposes detach_widget, hide, and show.

1088 1089
- The charset alias windows_1252 has been added.

1090 1091 1092 1093 1094 1095
- types.StringTypes is a tuple containing the defined string types;
  usually this will be (str, unicode), but if Python was compiled
  without Unicode support it will be just (str,).

- The pulldom and minidom modules were synchronized to PyXML.

Tim Peters's avatar
Tim Peters committed
1096
Tools/Demos
1097
-----------
Tim Peters's avatar
Tim Peters committed
1098

1099 1100 1101
- A new script called Tools/scripts/google.py was added, which fires
  off a search on Google.

Tim Peters's avatar
Tim Peters committed
1102
Build
1103
-----
Tim Peters's avatar
Tim Peters committed
1104

1105 1106 1107 1108 1109 1110 1111 1112
- Note that release builds of Python should arrange to define the
  preprocessor symbol NDEBUG on the command line (or equivalent).
  In the 2.2 pre-release series we tried to define this by magic in
  Python.h instead, but it proved to cause problems for extension
  authors.  The Unix, Windows and Mac builds now all define NDEBUG in
  release builds via cmdline (or equivalent) instead.  Ports to
  other platforms should do likewise.

1113 1114 1115 1116
- It is no longer necessary to use --with-suffix when building on a
  case-insensitive file system (such as Mac OS X HFS+). In the build
  directory an extension is used, but not in the installed python.

Tim Peters's avatar
Tim Peters committed
1117
C API
1118
-----
Tim Peters's avatar
Tim Peters committed
1119

1120 1121 1122 1123
- New function PyDict_MergeFromSeq2() exposes the builtin dict
  constructor's logic for updating a dictionary from an iterable object
  producing key-value pairs.

1124
- PyArg_ParseTupleAndKeywords() requires that the number of entries in
1125
  the keyword list equal the number of argument specifiers.  This
1126 1127 1128 1129 1130
  wasn't checked correctly, and PyArg_ParseTupleAndKeywords could even
  dump core in some bad cases.  This has been repaired.  As a result,
  PyArg_ParseTupleAndKeywords may raise RuntimeError in bad cases that
  previously went unchallenged.

Tim Peters's avatar
Tim Peters committed
1131
New platforms
1132
-------------
Tim Peters's avatar
Tim Peters committed
1133 1134

Tests
1135
-----
Tim Peters's avatar
Tim Peters committed
1136 1137

Windows
1138
-------
Tim Peters's avatar
Tim Peters committed
1139 1140

Mac
1141
----
Tim Peters's avatar
Tim Peters committed
1142

1143 1144
- In unix-Python on Mac OS X (and darwin) sys.platform is now "darwin",
  without any trailing digits.
Tim Peters's avatar
Tim Peters committed
1145

1146 1147 1148 1149 1150 1151
- Changed logic for finding python home in Mac OS X framework Pythons.
  Now sys.executable points to the executable again, in stead of to
  the shared library. The latter is used only for locating the python
  home.


Tim Peters's avatar
Tim Peters committed
1152 1153 1154
What's New in Python 2.2b2?
===========================

1155 1156
*Release date: 16-Nov-2001*

Tim Peters's avatar
Tim Peters committed
1157
Type/class unification and new-style classes
1158
--------------------------------------------
Tim Peters's avatar
Tim Peters committed
1159

1160 1161
- Multiple inheritance mixing new-style and classic classes in the
  list of base classes is now allowed, so this works now:
1162 1163

      class Classic: pass
1164
      class Mixed(Classic, object): pass
1165 1166 1167

  The MRO (method resolution order) for each base class is respected
  according to its kind, but the MRO for the derived class is computed
Andrew M. Kuchling's avatar
Andrew M. Kuchling committed
1168
  using new-style MRO rules if any base class is a new-style class.
1169 1170
  This needs to be documented.

1171 1172 1173
- The new builtin dictionary() constructor, and dictionary type, have
  been renamed to dict.  This reflects a decade of common usage.

1174 1175 1176 1177
- dict() now accepts an iterable object producing 2-sequences.  For
  example, dict(d.items()) == d for any dictionary d.  The argument,
  and the elements of the argument, can be any iterable objects.

1178 1179 1180
- New-style classes can now have a __del__ method, which is called
  when the instance is deleted (just like for classic classes).

Guido van Rossum's avatar
Guido van Rossum committed
1181 1182 1183 1184
- Assignment to object.__dict__ is now possible, for objects that are
  instances of new-style classes that have a __dict__ (unless the base
  class forbids it).

1185 1186 1187 1188
- Methods of built-in types now properly check for keyword arguments
  (formerly these were silently ignored).  The only built-in methods
  that take keyword arguments are __call__, __init__ and __new__.

1189 1190
- The socket function has been converted to a type; see below.

Tim Peters's avatar
Tim Peters committed
1191
Core and builtins
1192
-----------------
Tim Peters's avatar
Tim Peters committed
1193

1194 1195
- Assignment to __debug__ raises SyntaxError at compile-time.  This
  was promised when 2.1c1 was released as "What's New in Python 2.1c1"
1196
  (see below) says.
1197

Guido van Rossum's avatar
Guido van Rossum committed
1198 1199 1200
- Clarified the error messages for unsupported operands to an operator
  (like 1 + '').

Tim Peters's avatar
Tim Peters committed
1201
Extension modules
1202
-----------------
Tim Peters's avatar
Tim Peters committed
1203

1204 1205 1206 1207
- mmap has a new keyword argument, "access", allowing a uniform way for
  both Windows and Unix users to create read-only, write-through and
  copy-on-write memory mappings.  This was previously possible only on
  Unix.  A new keyword argument was required to support this in a
Andrew M. Kuchling's avatar
Andrew M. Kuchling committed
1208
  uniform way because the mmap() signatures had diverged across
1209 1210
  platforms.  Thanks to Jay T Miller for repairing this!

1211 1212 1213 1214 1215
- By default, the gc.garbage list now contains only those instances in
  unreachable cycles that have __del__ methods; in 2.1 it contained all
  instances in unreachable cycles.  "Instances" here has been generalized
  to include instances of both new-style and old-style classes.

Guido van Rossum's avatar
Guido van Rossum committed
1216 1217
- The socket module defines a new method for socket objects,
  sendall().  This is like send() but may make multiple calls to
1218 1219 1220
  send() until all data has been sent.  Also, the socket function has
  been converted to a subclassable type, like list and tuple (etc.)
  before it; socket and SocketType are now the same thing.
Guido van Rossum's avatar
Guido van Rossum committed
1221 1222 1223

- Various bugfixes to the curses module.  There is now a test suite
  for the curses module (you have to run it manually).
1224

1225 1226 1227
- binascii.b2a_base64 no longer places an arbitrary restriction of 57
  bytes on its input.

Tim Peters's avatar
Tim Peters committed
1228
Library
1229
-------
Tim Peters's avatar
Tim Peters committed
1230

1231
- tkFileDialog exposes a Directory class and askdirectory
1232 1233
  convenience function.

1234 1235 1236
- Symbolic group names in regular expressions must be unique.  For
  example, the regexp r'(?P<abc>)(?P<abc>)' is not allowed, because a
  single name can't mean both "group 1" and "group 2" simultaneously.
1237 1238 1239 1240 1241 1242
  Python 2.2 detects this error at regexp compilation time;
  previously, the error went undetected, and results were
  unpredictable.  Also in sre, the pattern.split(), pattern.sub(), and
  pattern.subn() methods have been rewritten in C.  Also, an
  experimental function/method finditer() has been added, which works
  like findall() but returns an iterator.
1243

1244 1245 1246 1247 1248
- Tix exposes more commands through the classes DirSelectBox,
  DirSelectDialog, ListNoteBook, Meter, CheckList, and the
  methods tix_addbitmapdir, tix_cget, tix_configure, tix_filedialog,
  tix_getbitmap, tix_getimage, tix_option_get, and tix_resetoptions.

1249 1250 1251 1252
- Traceback objects are now scanned by cyclic garbage collection, so
  cycles created by casual use of sys.exc_info() no longer cause
  permanent memory leaks (provided garbage collection is enabled).

1253 1254 1255 1256 1257
- os.extsep -- a new variable needed by the RISCOS support.  It is the
  separator used by extensions, and is '.' on all platforms except
  RISCOS, where it is '/'.  There is no need to use this variable
  unless you have a masochistic desire to port your code to RISCOS.

1258 1259
- mimetypes.py has optional support for non-standard, but commonly
  found types.  guess_type() and guess_extension() now accept an
1260
  optional 'strict' flag, defaulting to true, which controls whether
1261 1262 1263 1264 1265 1266 1267 1268
  recognize non-standard types or not.  A few non-standard types we
  know about have been added.  Also, when run as a script, there are
  new -l and -e options.

- statcache is now deprecated.

- email.Utils.formatdate() now produces the preferred RFC 2822 style
  dates with numeric timezones (it used to produce obsolete dates
1269
  hard coded to "GMT" timezone).  An optional 'localtime' flag is
1270 1271 1272 1273 1274 1275 1276 1277
  added to produce dates in the local timezone, with daylight savings
  time properly taken into account.

- In pickle and cPickle, instead of masking errors in load() by
  transforming them into SystemError, we let the original exception
  propagate out.  Also, implement support for __safe_for_unpickling__
  in pickle, as it already was supported in cPickle.

Tim Peters's avatar
Tim Peters committed
1278
Tools/Demos
1279
-----------
Tim Peters's avatar
Tim Peters committed
1280 1281

Build
1282
-----
Tim Peters's avatar
Tim Peters committed
1283

1284 1285 1286 1287 1288
- The dbm module is built using libdb1 if available.  The bsddb module
  is built with libdb3 if available.

- Misc/Makefile.pre.in has been removed by BDFL pronouncement.

Tim Peters's avatar
Tim Peters committed
1289
C API
1290
-----
Tim Peters's avatar
Tim Peters committed
1291

1292 1293 1294 1295
- New function PySequence_Fast_GET_SIZE() returns the size of a non-
  NULL result from PySequence_Fast(), more quickly than calling
  PySequence_Size().

1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307
- New argument unpacking function PyArg_UnpackTuple() added.

- New functions PyObject_CallFunctionObjArgs() and
  PyObject_CallMethodObjArgs() have been added to make it more
  convenient and efficient to call functions and methods from C.

- PyArg_ParseTupleAndKeywords() no longer masks errors, so it's
  possible that this will propagate errors it didn't before.

- New function PyObject_CheckReadBuffer(), which returns true if its
  argument supports the single-segment readable buffer interface.

Tim Peters's avatar
Tim Peters committed
1308
New platforms
1309
-------------
Tim Peters's avatar
Tim Peters committed
1310

1311 1312 1313
- We've finally confirmed that this release builds on HP-UX 11.00,
  *with* threads, and passes the test suite.

1314 1315 1316
- Thanks to a series of patches from Michael Muller, Python may build
  again under OS/2 Visual Age C++.

1317 1318
- Updated RISCOS port by Dietmar Schwertberger.

Tim Peters's avatar
Tim Peters committed
1319
Tests
1320
-----
Tim Peters's avatar
Tim Peters committed
1321

1322 1323 1324
- Added a test script for the curses module.  It isn't run automatically;
  regrtest.py must be run with '-u curses' to enable it.

Tim Peters's avatar
Tim Peters committed
1325
Windows
1326
-------
Tim Peters's avatar
Tim Peters committed
1327

1328
Mac
1329
----
1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341

- PythonScript has been moved to unsupported and is slated to be
  removed completely in the next release.

- It should now be possible to build applets that work on both OS9 and
  OSX.

- The core is now linked with CoreServices not Carbon; as a side
  result, default 8bit encoding on OSX is now ASCII.

- Python should now build on OSX 10.1.1

Tim Peters's avatar
Tim Peters committed
1342

1343 1344 1345
What's New in Python 2.2b1?
===========================

1346 1347
*Release date: 19-Oct-2001*

1348
Type/class unification and new-style classes
1349
--------------------------------------------
1350

1351
- New-style classes are now always dynamic (except for built-in and
1352
  extension types).  There is no longer a performance penalty, and I
1353
  no longer see another reason to keep this baggage around.  One relic
1354 1355
  remains: the __dict__ of a new-style class is a read-only proxy; you
  must set the class's attribute to modify it.  As a consequence, the
1356 1357
  __defined__ attribute of new-style types no longer exists, for lack
  of need: there is once again only one __dict__ (although in the
1358 1359
  future a __cache__ may be resurrected with a similar function, if I
  can prove that it actually speeds things up).
1360

Tim Peters's avatar
Tim Peters committed
1361 1362 1363 1364 1365 1366
- C.__doc__ now works as expected for new-style classes (in 2.2a4 it
  always returned None, even when there was a class docstring).

- doctest now finds and runs docstrings attached to new-style classes,
  class methods, static methods, and properties.

1367
Core and builtins
1368
-----------------
1369

1370 1371 1372 1373 1374 1375 1376 1377 1378
- A very subtle syntactical pitfall in list comprehensions was fixed.
  For example: [a+b for a in 'abc', for b in 'def'].  The comma in
  this example is a mistake.  Previously, this would silently let 'a'
  iterate over the singleton tuple ('abc',), yielding ['abcd', 'abce',
  'abcf'] rather than the intended ['ad', 'ae', 'af', 'bd', 'be',
  'bf', 'cd', 'ce', 'cf'].  Now, this is flagged as a syntax error.
  Note that [a for a in <singleton>] is a convoluted way to say
  [<singleton>] anyway, so it's not like any expressiveness is lost.

1379 1380 1381 1382 1383
- getattr(obj, name, default) now only catches AttributeError, as
  documented, rather than returning the default value for all
  exceptions (which could mask bugs in a __getattr__ hook, for
  example).

1384
- Weak reference objects are now part of the core and offer a C API.
1385
  A bug which could allow a core dump when binary operations involved
Andrew M. Kuchling's avatar
Andrew M. Kuchling committed
1386
  proxy reference has been fixed.  weakref.ReferenceError is now a
1387
  built-in exception.
1388

1389 1390 1391
- unicode(obj) now behaves more like str(obj), accepting arbitrary
  objects, and calling a __unicode__ method if it exists.
  unicode(obj, encoding) and unicode(obj, encoding, errors) still
1392
  require an 8-bit string or character buffer argument.
1393

1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404
- isinstance() now allows any object as the first argument and a
  class, a type or something with a __bases__ tuple attribute for the
  second argument.  The second argument may also be a tuple of a
  class, type, or something with __bases__, in which case isinstance()
  will return true if the first argument is an instance of any of the
  things contained in the second argument tuple.  E.g.

  isinstance(x, (A, B))

  returns true if x is an instance of A or B.

1405
Extension modules
1406
-----------------
1407 1408 1409

- thread.start_new_thread() now returns the thread ID (previously None).

1410 1411
- binascii has now two quopri support functions, a2b_qp and b2a_qp.

1412 1413 1414 1415 1416 1417 1418 1419 1420
- readline now supports setting the startup_hook and the
  pre_event_hook, and adds the add_history() function.

- os and posix supports chroot(), setgroups() and unsetenv() where
  available.  The stat(), fstat(), statvfs() and fstatvfs() functions
  now return "pseudo-sequences" -- the various fields can now be
  accessed as attributes (e.g. os.stat("/").st_mtime) but for
  backwards compatibility they also behave as a fixed-length sequence.
  Some platform-specific fields (e.g. st_rdev) are only accessible as
1421 1422 1423 1424 1425
  attributes.

- time: localtime(), gmtime() and strptime() now return a
  pseudo-sequence similar to the os.stat() return value, with
  attributes like tm_year etc.
1426

1427 1428 1429
- Decompression objects in the zlib module now accept an optional
  second parameter to decompress() that specifies the maximum amount
  of memory to use for the uncompressed data.
1430

1431 1432 1433
- optional SSL support in the socket module now exports OpenSSL
  functions RAND_add(), RAND_egd(), and RAND_status().  These calls
  are useful on platforms like Solaris where OpenSSL does not
1434 1435 1436 1437 1438
  automatically seed its PRNG.  Also, the keyfile and certfile
  arguments to socket.ssl() are now optional.

- posixmodule (and by extension, the os module on POSIX platforms) now
  exports O_LARGEFILE, O_DIRECT, O_DIRECTORY, and O_NOFOLLOW.
1439

1440
Library
1441
-------
1442

1443 1444 1445
- doctest now excludes functions and classes not defined by the module
  being tested, thanks to Tim Hochberg.

1446 1447 1448 1449 1450
- HotShot, a new profiler implemented using a C-based callback, has
  been added.  This substantially reduces the overhead of profiling,
  but it is still quite preliminary.  Support modules and
  documentation will be added in upcoming releases (before 2.2 final).

Guido van Rossum's avatar
Guido van Rossum committed
1451 1452 1453 1454 1455
- profile now produces correct output in situations where an exception
  raised in Python is cleared by C code (e.g. hasattr()).  This used
  to cause wrong output, including spurious claims of recursive
  functions and attribution of time spent to the wrong function.

1456 1457 1458 1459 1460 1461 1462 1463 1464
  The code and documentation for the derived OldProfile and HotProfile
  profiling classes was removed.  The code hasn't worked for years (if
  you tried to use them, they raised exceptions).  OldProfile
  intended to reproduce the behavior of the profiler Python used more
  than 7 years ago, and isn't interesting anymore.  HotProfile intended
  to provide a faster profiler (but producing less information), and
  that's a worthy goal we intend to meet via a different approach (but
  without losing information).

1465
- Profile.calibrate() has a new implementation that should deliver
1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476
  a much better system-specific calibration constant.  The constant can
  now be specified in an instance constructor, or as a Profile class or
  instance variable, instead of by editing profile.py's source code.
  Calibration must still be done manually (see the docs for the profile
  module).

  Note that Profile.calibrate() must be overriden by subclasses.
  Improving the accuracy required exploiting detailed knowledge of
  profiler internals; the earlier method abstracted away the details
  and measured a simplified model instead, but consequently computed
  a constant too small by a factor of 2 on some modern machines.
1477

1478
- quopri's encode and decode methods take an optional header parameter,
1479 1480 1481
  which indicates whether output is intended for the header 'Q'
  encoding.

1482 1483 1484
- The SocketServer.ThreadingMixIn class now closes the request after
  finish_request() returns.  (Not when it errors out though.)

1485
- The nntplib module's NNTP.body() method has grown a 'file' argument
1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497
  to allow saving the message body to a file.

- The email package has added a class email.Parser.HeaderParser which
  only parses headers and does not recurse into the message's body.
  Also, the module/class MIMEAudio has been added for representing
  audio data (contributed by Anthony Baxter).

- ftplib should be able to handle files > 2GB.

- ConfigParser.getboolean() now also interprets TRUE, FALSE, YES, NO,
  ON, and OFF.

1498 1499 1500
- xml.dom.minidom NodeList objects now support the length attribute
  and item() method as required by the DOM specifications.

1501
Tools/Demos
1502
-----------
1503 1504 1505 1506

- Demo/dns was removed.  It no longer serves any purpose; a package
  derived from it is now maintained by Anthony Baxter, see
  http://PyDNS.SourceForge.net.
1507

1508 1509 1510
- The freeze tool has been made more robust, and two new options have
  been added: -X and -E.

1511
Build
1512
-----
1513

1514 1515 1516
- configure will use CXX in LINKCC if CXX is used to build main() and
  the system requires to link a C++ main using the C++ compiler.

1517
C API
1518
-----
1519

1520 1521 1522 1523 1524 1525
- The documentation for the tp_compare slot is updated to require that
  the return value must be -1, 0, 1; an arbitrary number <0 or >0 is
  not correct.  This is not yet enforced but will be enforced in
  Python 2.3; even later, we may use -2 to indicate errors and +2 for
  "NotImplemented".  Right now, -1 should be used for an error return.

1526 1527 1528 1529
- PyLong_AsLongLong() now accepts int (as well as long) arguments.
  Consequently, PyArg_ParseTuple's 'L' code also accepts int (as well
  as long) arguments.

1530 1531 1532 1533 1534 1535 1536
- PyThread_start_new_thread() now returns a long int giving the thread
  ID, if one can be calculated; it returns -1 for error, 0 if no
  thread ID is calculated (this is an incompatible change, but only
  the thread module used this API).  This code has only really been
  tested on Linux and Windows; other platforms please beware (and
  report any bugs or strange behavior).

1537 1538 1539
- PyUnicode_FromEncodedObject() no longer accepts Unicode objects as
  input.

1540
New platforms
1541
-------------
1542 1543

Tests
1544
-----
1545 1546

Windows
1547
-------
1548

1549 1550 1551 1552
- Installer:  If you install IDLE, and don't disable file-extension
  registration, a new "Edit with IDLE" context (right-click) menu entry
  is created for .py and .pyw files.

1553 1554 1555
- The signal module now supports SIGBREAK on Windows, thanks to Steven
  Scott.  Note that SIGBREAK is unique to Windows.  The default SIGBREAK
  action remains to call Win32 ExitProcess().  This can be changed via
1556
  signal.signal().  For example::
1557

1558 1559 1560 1561
      # Make Ctrl+Break raise KeyboardInterrupt, like Python's default Ctrl+C
      # (SIGINT) behavior.
      import signal
      signal.signal(signal.SIGBREAK, signal.default_int_handler)
1562

1563 1564 1565 1566 1567 1568 1569 1570
      try:
	  while 1:
	      pass
      except KeyboardInterrupt:
	  # We get here on Ctrl+C or Ctrl+Break now; if we had not changed
	  # SIGBREAK, only on Ctrl+C (and Ctrl+Break would terminate the
	  # program without the possibility for any Python-level cleanup).
	  print "Clean exit"
1571

1572

Tim Peters's avatar
Tim Peters committed
1573 1574 1575
What's New in Python 2.2a4?
===========================

1576 1577
*Release date: 28-Sep-2001*

1578
Type/class unification and new-style classes
1579
--------------------------------------------
1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591

- pydoc and inspect are now aware of new-style classes;
  e.g. help(list) at the interactive prompt now shows proper
  documentation for all operations on list objects.

- Applications using Jim Fulton's ExtensionClass module can now safely
  be used with Python 2.2.  In particular, Zope 2.4.1 now works with
  Python 2.2 (as well as with Python 2.1.1).  The Demo/metaclass
  examples also work again.  It is hoped that Gtk and Boost also work
  with 2.2a4 and beyond.  (If you can confirm this, please write
  webmaster@python.org; if there are still problems, please open a bug
  report on SourceForge.)
Tim Peters's avatar
Tim Peters committed
1592

1593
- property() now takes 4 keyword arguments:  fget, fset, fdel and doc.
Andrew M. Kuchling's avatar
Andrew M. Kuchling committed
1594
  These map to read-only attributes 'fget', 'fset', 'fdel', and '__doc__'
1595 1596 1597 1598
  in the constructed property object.  fget, fset and fdel weren't
  discoverable from Python in 2.2a3.  __doc__ is new, and allows to
  associate a docstring with a property.

1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614
- Comparison overloading is now more completely implemented.  For
  example, a str subclass instance can properly be compared to a str
  instance, and it can properly overload comparison.  Ditto for most
  other built-in object types.

- The repr() of new-style classes has changed; instead of <type
  'M.Foo'> a new-style class is now rendered as <class 'M.Foo'>,
  *except* for built-in types, which are still rendered as <type
  'Foo'> (to avoid upsetting existing code that might parse or
  otherwise rely on repr() of certain type objects).

- The repr() of new-style objects is now always <Foo object at XXX>;
  previously, it was sometimes <Foo instance at XXX>.

- For new-style classes, what was previously called __getattr__ is now
  called __getattribute__.  This method, if defined, is called for
Andrew M. Kuchling's avatar
Andrew M. Kuchling committed
1615
  *every* attribute access.  A new __getattr__ hook more similar to the
1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643
  one in classic classes is defined which is called only if regular
  attribute access raises AttributeError; to catch *all* attribute
  access, you can use __getattribute__ (for new-style classes).  If
  both are defined, __getattribute__ is called first, and if it raises
  AttributeError, __getattr__ is called.

- The __class__ attribute of new-style objects can be assigned to.
  The new class must have the same C-level object layout as the old
  class.

- The builtin file type can be subclassed now.  In the usual pattern,
  "file" is the name of the builtin type, and file() is a new builtin
  constructor, with the same signature as the builtin open() function.
  file() is now the preferred way to open a file.

- Previously, __new__ would only see sequential arguments passed to
  the type in a constructor call; __init__ would see both sequential
  and keyword arguments.  This made no sense whatsoever any more, so
  now both __new__ and __init__ see all arguments.

- Previously, hash() applied to an instance of a subclass of str or
  unicode always returned 0.  This has been repaired.

- Previously, an operation on an instance of a subclass of an
  immutable type (int, long, float, complex, tuple, str, unicode),
  where the subtype didn't override the operation (and so the
  operation was handled by the builtin type), could return that
  instance instead a value of the base type.  For example, if s was of
Andrew M. Kuchling's avatar
Andrew M. Kuchling committed
1644
  a str subclass type, s[:] returned s as-is.  Now it returns a str
1645 1646
  with the same value as s.

1647 1648
- Provisional support for pickling new-style objects has been added.

1649
Core
1650
----
1651

1652 1653
- file.writelines() now accepts any iterable object producing strings.

1654 1655 1656 1657 1658 1659
- PyUnicode_FromEncodedObject() now works very much like
  PyObject_Str(obj) in that it tries to use __str__/tp_str
  on the object if the object is not a string or buffer. This
  makes unicode() behave like str() when applied to non-string/buffer
  objects.

Andrew M. Kuchling's avatar
Andrew M. Kuchling committed
1660 1661
- PyFile_WriteObject now passes Unicode objects to the file's write
  method. As a result, all file-like objects which may be the target
1662 1663 1664
  of a print statement must support Unicode objects, i.e. they must
  at least convert them into ASCII strings.

1665 1666 1667 1668
- Thread scheduling on Solaris should be improved; it is no longer
  necessary to insert a small sleep at the start of a thread in order
  to let other runnable threads be scheduled.

Tim Peters's avatar
Tim Peters committed
1669
Library
1670
-------
Tim Peters's avatar
Tim Peters committed
1671

1672 1673 1674 1675 1676
- StringIO.StringIO instances and cStringIO.StringIO instances support
  read character buffer compatible objects for their .write() methods.
  These objects are converted to strings and then handled as such
  by the instances.

1677 1678 1679 1680
- The "email" package has been added.  This is basically a port of the
  mimelib package <http://sf.net/projects/mimelib> with API changes
  and some implementations updated to use iterators and generators.

1681 1682 1683 1684
- difflib.ndiff() and difflib.Differ.compare() are generators now.  This
  restores the ability of Tools/scripts/ndiff.py to start producing output
  before the entire comparison is complete.

1685 1686 1687 1688
- StringIO.StringIO instances and cStringIO.StringIO instances support
  iteration just like file objects (i.e. their .readline() method is
  called for each iteration until it returns an empty string).

1689 1690 1691 1692
- The codecs module has grown four new helper APIs to access
  builtin codecs: getencoder(), getdecoder(), getreader(),
  getwriter().

1693 1694 1695
- SimpleXMLRPCServer: a new module (based upon SimpleHTMLServer)
  simplifies writing XML RPC servers.

Barry Warsaw's avatar
Barry Warsaw committed
1696
- os.path.realpath(): a new function that returns the absolute pathname
1697 1698 1699
  after interpretation of symbolic links.  On non-Unix systems, this
  is an alias for os.path.abspath().

1700 1701 1702
- operator.indexOf() (PySequence_Index() in the C API) now works with any
  iterable object.

1703 1704 1705 1706 1707
- smtplib now supports various authentication and security features of
  the SMTP protocol through the new login() and starttls() methods.

- hmac: a new module implementing keyed hashing for message
  authentication.
1708

1709 1710
- mimetypes now recognizes more extensions and file types.  At the
  same time, some mappings not sanctioned by IANA were removed.
1711

1712
- The "compiler" package has been brought up to date to the state of
1713 1714 1715 1716 1717
  Python 2.2 bytecode generation.  It has also been promoted from a
  Tool to a standard library package.  (Tools/compiler still exists as
  a sample driver.)

Tools
1718
-----
1719

Tim Peters's avatar
Tim Peters committed
1720
Build
1721
-----
Tim Peters's avatar
Tim Peters committed
1722

1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740
- Large file support (LFS) is now automatic when the platform supports
  it; no more manual configuration tweaks are needed.  On Linux, at
  least, it's possible to have a system whose C library supports large
  files but whose kernel doesn't; in this case, large file support is
  still enabled but doesn't do you any good unless you upgrade your
  kernel or share your Python executable with another system whose
  kernel has large file support.

- The configure script now supplies plausible defaults in a
  cross-compilation environment.  This doesn't mean that the supplied
  values are always correct, or that cross-compilation now works
  flawlessly -- but it's a first step (and it shuts up most of
  autoconf's warnings about AC_TRY_RUN).

- The Unix build is now a bit less chatty, courtesy of the parser
  generator.  The build is completely silent (except for errors) when
  using "make -s", thanks to a -q option to setup.py.

Tim Peters's avatar
Tim Peters committed
1741
C API
1742
-----
Tim Peters's avatar
Tim Peters committed
1743

1744 1745 1746
- The "structmember" API now supports some new flag bits to deny read
  and/or write access to attributes in restricted execution mode.

Tim Peters's avatar
Tim Peters committed
1747
New platforms
1748
-------------
Tim Peters's avatar
Tim Peters committed
1749

1750 1751 1752
- Compaq's iPAQ handheld, running the "familiar" Linux distribution
  (http://familiar.handhelds.org).

Tim Peters's avatar
Tim Peters committed
1753
Tests
1754
-----
Tim Peters's avatar
Tim Peters committed
1755

1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769
- The "classic" standard tests, which work by comparing stdout to
  an expected-output file under Lib/test/output/, no longer stop at
  the first mismatch.  Instead the test is run to completion, and a
  variant of ndiff-style comparison is used to report all differences.
  This is much easier to understand than the previous style of reporting.

- The unittest-based standard tests now use regrtest's test_main()
  convention, instead of running as a side-effect of merely being
  imported.  This allows these tests to be run in more natural and
  flexible ways as unittests, outside the regrtest framework.

- regrtest.py is much better integrated with unittest and doctest now,
  especially in regard to reporting errors.

Tim Peters's avatar
Tim Peters committed
1770
Windows
1771
-------
Tim Peters's avatar
Tim Peters committed
1772

1773
- Large file support now also works for files > 4GB, on filesystems
1774 1775
  that support it (NTFS under Windows 2000).  See "What's New in
  Python 2.2a3" for more detail.
1776

Tim Peters's avatar
Tim Peters committed
1777

1778 1779 1780
What's New in Python 2.2a3?
===========================

1781 1782
*Release Date: 07-Sep-2001*

1783
Core
1784
----
1785

1786 1787 1788
- Conversion of long to float now raises OverflowError if the long is too
  big to represent as a C double.

1789 1790 1791 1792 1793 1794
- 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).

1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811
- 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.

1812
- Overflowing operations on plain ints now return a long int rather
1813 1814 1815 1816 1817
  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.

1818
- A new command line option, -Q<arg>, is added to control run-time
1819
  warnings for the use of classic division.  (See PEP 238.)  Possible
1820 1821 1822 1823 1824
  values are -Qold, -Qwarn, -Qwarnall, and -Qnew.  The default is
  -Qold, meaning the / operator has its classic meaning and no
  warnings are issued.  Using -Qwarn issues a run-time warning about
  all uses of classic division for int and long arguments; -Qwarnall
  also warns about classic division for float and complex arguments
Tim Peters's avatar
Tim Peters committed
1825
  (for use with fixdiv.py).
1826 1827 1828 1829 1830 1831 1832
  [Note:  the remainder of this item (preserved below) became
  obsolete in 2.2c1 -- -Qnew has global effect in 2.2] ::

    Using -Qnew is questionable; it turns on new division by default, but
    only in the __main__ module.  You can usefully combine -Qwarn or
    -Qwarnall and -Qnew: this gives the __main__ module new division, and
    warns about classic division everywhere else.
1833

1834
- Many built-in types can now be subclassed.  This applies to int,
1835 1836 1837 1838 1839 1840 1841 1842 1843
  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.

1844 1845 1846 1847
- The dictionary constructor now takes an optional argument, a
  mapping-like object, and initializes the dictionary from its
  (key, value) pairs.

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

1852 1853 1854 1855 1856
- A new built-in type, property, has been added.  This enables the
  creation of "properties".  These are attributes 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#property
1857

1858
- The syntax of floating-point and imaginary literals has been
1859 1860 1861 1862 1863
  liberalized, to allow leading zeroes.  Examples of literals now
  legal that were SyntaxErrors before:

      00.0    0e3   0100j   07.5   00000000000000000008.

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

1867
Library
1868
-------
1869

1870
- telnetlib includes symbolic names for the options, and support for
1871 1872
  setting an option negotiation callback. It also supports processing
  of suboptions.
1873

1874 1875 1876 1877 1878 1879 1880
- 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).

1881 1882 1883
- Asynchronous timeout actions are available through the new class
  threading.Timer.

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

1887
- A new function, imp.lock_held(), returns 1 when the import lock is
1888 1889
  currently held.  See the docs for the imp module.

1890
- pickle, cPickle and marshal on 32-bit platforms can now correctly read
1891 1892 1893 1894
  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.

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

1898 1899 1900 1901
- unittest.TestResult instances no longer store references to tracebacks
  generated by test failures. This prevents unexpected dangling references
  to objects that should be garbage collected between tests.

1902
Tools
1903
-----
1904

1905 1906 1907
- Tools/scripts/fixdiv.py has been added which can be used to fix
  division operators as per PEP 238.

1908
Build
1909
-----
1910

1911 1912 1913 1914 1915
- If you are an adventurous person using Mac OS X you may want to look at
  Mac/OSX. There is a Makefile there that will build Python as a real Mac
  application, which can be used for experimenting with Carbon or Cocoa.
  Discussion of this on pythonmac-sig, please.

1916
C API
1917
-----
1918 1919

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

1921 1922
- 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
1923
  errors are properly detected now.  The proper way to check::
1924

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

1930
- The GC API has been changed.  Extensions that use the old API will still
1931 1932 1933 1934
  compile but will not participate in GC.  To upgrade an extension
  module:

    - rename Py_TPFLAGS_GC to PyTPFLAGS_HAVE_GC
1935

1936 1937
    - use PyObject_GC_New or PyObject_GC_NewVar to allocate objects and
      PyObject_GC_Del to deallocate them
1938

1939 1940
    - rename PyObject_GC_Init to PyObject_GC_Track and PyObject_GC_Fini
      to PyObject_GC_UnTrack
1941

1942 1943 1944 1945
    - remove PyGC_HEAD_SIZE from object size calculations

    - remove calls to PyObject_AS_GC and PyObject_FROM_GC

1946
- Two new functions: PyString_FromFormat() and PyString_FromFormatV().
1947 1948 1949
  These can be used safely to construct string objects from a
  sprintf-style format string (similar to the format string supported
  by PyErr_Format()).
1950

1951
New platforms
1952
-------------
1953

1954 1955 1956 1957 1958
- 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.
1959

1960
Tests
1961
-----
1962 1963

Windows
1964
-------
1965

1966 1967 1968 1969
- 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
1970 1971 1972 1973 1974
  partitions).  Windows filesystem limits:  FAT has a 2GB (gigabyte)
  filesize limit, and large file support makes no difference there.
  FAT32's limit is 4GB, and files >= 2GB are easier to use from Python now.
  NTFS has no practical limit on file size, and files of any size can be
  used from Python now.
1975

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

1979

Tim Peters's avatar
Tim Peters committed
1980 1981 1982
What's New in Python 2.2a2?
===========================

1983 1984
*Release Date: 22-Aug-2001*

1985
Build
1986
-----
1987

1988 1989 1990
- Tim Peters developed a brand new Windows installer using Wise 8.1,
  generously donated to us by Wise Solutions.

1991 1992 1993
- 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
1994

1995 1996 1997 1998
- 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.
1999

Barry Warsaw's avatar
Barry Warsaw committed
2000 2001
- The NeXT platform is no longer supported.

2002
- The 'new' module is now statically linked.
Barry Warsaw's avatar
Barry Warsaw committed
2003

2004
Tools
2005
-----
2006 2007

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

Tim Peters's avatar
Tim Peters committed
2011
Tests
2012
-----
Tim Peters's avatar
Tim Peters committed
2013

2014
- regrtest.py now knows which tests are expected to be skipped on some
Barry Warsaw's avatar
Barry Warsaw committed
2015 2016 2017
  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.
2018

Tim Peters's avatar
Tim Peters committed
2019 2020 2021 2022
- Several new tests in the standard test suite, with special thanks to
  Nick Mathewson.

Core
2023
----
Tim Peters's avatar
Tim Peters committed
2024

Barry Warsaw's avatar
Barry Warsaw committed
2025 2026 2027 2028 2029 2030 2031 2032 2033
- 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>

2034 2035 2036 2037 2038
- 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>.

2039 2040 2041 2042 2043 2044
- 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
2045 2046 2047 2048
- 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).

2049 2050 2051 2052 2053 2054
- 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.

2055 2056 2057 2058 2059 2060 2061
- 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.

2062
Library
2063
-------
2064

2065 2066
- New class Differ and new functions ndiff() and restore() in difflib.py.
  These package the algorithms used by the popular Tools/scripts/ndiff.py,
2067
  for programmatic reuse.
2068

2069 2070 2071 2072 2073 2074
- 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
2075 2076 2077 2078 2079 2080
- Calling os.tempnam() or os.tmpnam() generate RuntimeWarnings.

- Added function threading.BoundedSemaphore()

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

2081
- The 'new' module now exposes the CO_xxx flags.
Barry Warsaw's avatar
Barry Warsaw committed
2082

2083 2084
- The gc module offers the get_referents function.

2085
New platforms
2086
-------------
2087 2088

C API
2089
-----
2090

Marc-André Lemburg's avatar
Marc-André Lemburg committed
2091 2092 2093 2094 2095 2096 2097
- 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.

2098
- Unicode APIs now use name mangling to assure that mixing interpreters
2099 2100
  and extensions using different Unicode widths is rendered next to
  impossible. Trying to import an incompatible Unicode-aware extension
2101 2102 2103 2104
  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.

2105 2106 2107 2108 2109 2110
- 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.

2111
Windows
2112
-------
2113 2114 2115 2116

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

Tim Peters's avatar
Tim Peters committed
2117

2118
What's New in Python 2.2a1?
2119 2120
===========================

2121 2122
*Release date: 18-Jul-2001*

2123
Core
2124
----
2125

2126 2127 2128 2129 2130 2131 2132 2133
- 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
2134
  incompatibilities are found during alpha testing that cannot be
2135 2136
  repaired.

2137
- Generators were added; this is a new way to create an iterator (see
Tim Peters's avatar
Tim Peters committed
2138
  below) using what looks like a simple function containing one or
2139 2140 2141 2142 2143 2144 2145 2146 2147
  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.)

2148 2149 2150 2151 2152
- 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).

2153 2154 2155 2156 2157 2158 2159
- 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).
2160

2161 2162 2163 2164 2165 2166 2167 2168 2169
  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):

2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184
  +---------+-----------+-----------+-----------------------------+
  |Name     | .encode() | .decode() | Description                 |
  +=========+===========+===========+=============================+
  |uu       | string    | string    | UU codec (e.g. for email)   |
  +---------+-----------+-----------+-----------------------------+
  |base64   | string    | string    | base64 codec                |
  +---------+-----------+-----------+-----------------------------+
  |quopri   | string    | string    | quoted-printable codec      |
  +---------+-----------+-----------+-----------------------------+
  |zlib     | string    | string    | zlib compression            |
  +---------+-----------+-----------+-----------------------------+
  |hex      | string    | string    | 2-byte hex codec            |
  +---------+-----------+-----------+-----------------------------+
  |rot-13   | string    | Unicode   | ROT-13 Unicode charmap codec|
  +---------+-----------+-----------+-----------------------------+
2185

2186 2187 2188
- 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
2189
  term, although the default encoding for that platform will be other than
2190
  'mbcs'.
2191 2192

  On operating system that support non-ASCII filenames, it is common for
2193 2194 2195 2196 2197
  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
2198 2199
  would attempt to use its default encoding (generally ASCII) rather than
  the default encoding for the file system.
2200

2201 2202 2203
  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.
2204
  See [????] for more details, including examples.
2205

2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225
- 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.

2226 2227 2228 2229 2230 2231 2232 2233 2234 2235
- 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.

2236 2237 2238
- Many other small changes to dicts were made, resulting in faster
  operation along the most common code paths.

2239 2240 2241
- Dictionary objects now support the "in" operator: "x in dict" means
  the same as dict.has_key(x).

2242 2243 2244 2245 2246
- 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())

2247 2248 2249 2250 2251 2252 2253 2254 2255
- 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.

2256
- The following functions were generalized to work nicely with iterator
2257
  arguments::
2258

2259
    map(), filter(), reduce(), zip()
2260 2261
    list(), tuple() (PySequence_Tuple() and PySequence_Fast() in C API)
    max(), min()
2262 2263
    join() method of strings
    extend() method of lists
2264 2265
    'x in y' and 'x not in y' (PySequence_Contains() in C API)
    operator.countOf() (PySequence_Count() in C API)
2266
    right-hand side of assignment statements with multiple targets, such as ::
2267
        x, y, z = some_iterable_object_returning_exactly_3_values
2268

2269 2270 2271
- Accessing module attributes is significantly faster (for example,
  random.random or os.path or yourPythonModule.yourAttribute).

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

2275 2276 2277 2278 2279
- 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.

2280 2281
- 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
2282
  d with d.keys() == [i << 16 for i in range(20000)] is approximately 500x
2283 2284
  faster now.  Thanks to Christian Tismer for pointing out the cause and
  the nature of an effective cure (last December! better late than never).
2285

2286 2287 2288
- repr() is much faster for large containers (dict, list, tuple).


2289
Library
2290
-------
2291

2292
- The constants ascii_letters, ascii_lowercase. and ascii_uppercase
2293
  were added to the string module.  These a locale-independent
2294 2295 2296
  constants, unlike letters, lowercase, and uppercase.  These are now
  use in appropriate locations in the standard library.

2297 2298 2299
- 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
2300 2301 2302 2303 2304
- 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
2305 2306 2307 2308
- 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
2309 2310
- A new function fnmatch.filter to filter lists of file names was added.

2311 2312
- calendar.py uses month and day names based on the current locale.

2313 2314 2315 2316
- 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).

2317 2318 2319 2320 2321
- Cookie.py now sorts key+value pairs by key in output strings.

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

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

2324 2325 2326 2327 2328
- 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.
2329 2330
  In standard mode, 'q' and 'Q' are supported on all platforms, and are
  8-byte integral types.
2331

2332 2333 2334 2335 2336
- 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)'.

2337
Tests
2338
-----
2339 2340

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

2345
- New test_pprint.py verifies that pprint.isrecursive() and
2346 2347
  pprint.isreadable() return sensible results.  Also verifies that simple
  cases produce correct output.
2348

2349
C API
2350
-----
2351 2352 2353

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

----

**(For information about older versions, consult the HISTORY file.)**