1 ****************************
2 What's New in Python 2.7
3 ****************************
5 :Author: A.M. Kuchling (amk at amk.ca)
9 .. Fix accents on Kristjan Valur Jonsson, Fuerstenau, Tarek Ziade.
12 Rules for maintenance:
14 * Anyone can add text to this document. Do not spend very much time
15 on the wording of your changes, because your text will probably
16 get rewritten to some degree.
18 * The maintainer will go through Misc/NEWS periodically and add
19 changes; it's therefore more important to add your changes to
20 Misc/NEWS than to this file.
22 * This is not a complete list of every single change; completeness
23 is the purpose of Misc/NEWS. Some changes I consider too small
24 or esoteric to include. If such a change is added to the text,
25 I'll just remove it. (This is another reason you shouldn't spend
26 too much time on writing your addition.)
28 * If you want to draw your new text to the attention of the
29 maintainer, add 'XXX' to the beginning of the paragraph or
32 * It's OK to just add a fragmentary note about a change. For
33 example: "XXX Describe the transmogrify() function added to the
34 socket module." The maintainer will research the change and
35 write the necessary text.
37 * You can comment out your additions if you like, but it's not
38 necessary (especially when a final release is some months away).
40 * Credit the author of a patch or bugfix. Just the name is
41 sufficient; the e-mail address isn't necessary.
43 * It's helpful to add the bug/patch number in a parenthetical comment.
45 XXX Describe the transmogrify() function added to the socket
47 (Contributed by P.Y. Developer; :issue:`12345`.)
49 This saves the maintainer some effort going through the SVN logs
50 when researching a change.
52 This article explains the new features in Python 2.7.
53 No release schedule has been decided yet for 2.7.
55 .. Compare with previous release in 2 - 3 sentences here.
56 add hyperlink when the documentation becomes available online.
61 Much as Python 2.6 incorporated features from Python 3.0,
62 version 2.7 is influenced by features from 3.1.
64 XXX mention importlib; anything else?
66 One porting change: the :option:`-3` switch now automatically
67 enables the :option:`-Qwarn` switch that causes warnings
68 about using classic division with integers and long integers.
70 .. ========================================================================
71 .. Large, PEP-level features and changes should be described here.
72 .. ========================================================================
74 PEP 372: Adding an ordered dictionary to collections
75 ====================================================
79 Several modules will now use :class:`OrderedDict` by default. The
80 :mod:`ConfigParser` module uses :class:`OrderedDict` for the list
81 of sections and the options within a section.
82 The :meth:`namedtuple._asdict` method returns an :class:`OrderedDict`
86 Other Language Changes
87 ======================
89 Some smaller changes made to the core Python language are:
91 * :meth:`str.format` method now supports automatic numbering of the replacement
92 fields. This makes using :meth:`str.format` more closely resemble using
95 >>> '{}:{}:{}'.format(2009, 04, 'Sunday')
97 >>> '{}:{}:{day}'.format(2009, 4, day='Sunday')
100 The auto-numbering takes the fields from left to right, so the first ``{...}``
101 specifier will use the first argument to :meth:`str.format`, the next
102 specifier will use the next argument, and so on. You can't mix auto-numbering
103 and explicit numbering -- either number all of your specifier fields or none
104 of them -- but you can mix auto-numbering and named fields, as in the second
105 example above. (Contributed by Eric Smith; :issue`5237`.)
107 * The :func:`int` and :func:`long` types gained a ``bit_length``
108 method that returns the number of bits necessary to represent
109 its argument in binary::
119 >>> (n+1).bit_length()
122 (Contributed by Fredrik Johansson and Victor Stinner; :issue:`3439`.)
124 * Conversions from long integers and regular integers to floating
125 point now round differently, returning the floating-point number
126 closest to the number. This doesn't matter for small integers that
127 can be converted exactly, but for large numbers that will
128 unavoidably lose precision, Python 2.7 will now approximate more
129 closely. For example, Python 2.6 computed the following::
131 >>> n = 295147905179352891391
133 2.9514790517935283e+20
134 >>> n - long(float(n))
137 Python 2.7's floating-point result is larger, but much closer to the
140 >>> n = 295147905179352891391
142 2.9514790517935289e+20
147 (Implemented by Mark Dickinson; :issue:`3166`.)
149 * The :class:`bytearray` type's :meth:`translate` method will
150 now accept ``None`` as its first argument. (Fixed by Georg Brandl;
153 .. ======================================================================
159 Several performance enhancements have been added:
161 .. * A new :program:`configure` option, :option:`--with-computed-gotos`,
162 compiles the main bytecode interpreter loop using a new dispatch
163 mechanism that gives speedups of up to 20%, depending on the system
164 and benchmark. The new mechanism is only supported on certain
165 compilers, such as gcc, SunPro, and icc.
167 * The garbage collector now performs better when many objects are
168 being allocated without deallocating any. A full garbage collection
169 pass is only performed when the middle generation has been collected
170 10 times and when the number of survivor objects from the middle
171 generation exceeds 10% of the number of objects in the oldest
172 generation. The second condition was added to reduce the number
173 of full garbage collections as the number of objects on the heap grows,
174 avoiding quadratic performance when allocating very many objects.
175 (Suggested by Martin von Loewis and implemented by Antoine Pitrou;
178 * The garbage collector tries to avoid tracking simple containers
179 which can't be part of a cycle. In Python 2.7, this is now true for
180 tuples and dicts containing atomic types (such as ints, strings,
181 etc.). Transitively, a dict containing tuples of atomic types won't
182 be tracked either. This helps reduce the cost of each
183 garbage collection by decreasing the number of objects to be
184 considered and traversed by the collector.
185 (Contributed by Antoine Pitrou; :issue:`4688`.)
187 * Integers are now stored internally either in base 2**15 or in base
188 2**30, the base being determined at build time. Previously, they
189 were always stored in base 2**15. Using base 2**30 gives
190 significant performance improvements on 64-bit machines, but
191 benchmark results on 32-bit machines have been mixed. Therefore,
192 the default is to use base 2**30 on 64-bit machines and base 2**15
193 on 32-bit machines; on Unix, there's a new configure option
194 :option:`--enable-big-digits` that can be used to override this default.
196 Apart from the performance improvements this change should be
197 invisible to end users, with one exception: for testing and
198 debugging purposes there's a new structseq ``sys.long_info`` that
199 provides information about the internal format, giving the number of
200 bits per digit and the size in bytes of the C type used to store
205 sys.long_info(bits_per_digit=30, sizeof_digit=4)
207 (Contributed by Mark Dickinson; :issue:`4258`.)
209 Another set of changes made long objects a few bytes smaller: 2 bytes
210 smaller on 32-bit systems and 6 bytes on 64-bit.
211 (Contributed by Mark Dickinson; :issue:`5260`.)
213 * The division algorithm for long integers has been made faster
214 by tightening the inner loop, doing shifts instead of multiplications,
215 and fixing an unnecessary extra iteration.
216 Various benchmarks show speedups of between 50% and 150% for long
217 integer divisions and modulo operations.
218 (Contributed by Mark Dickinson; :issue:`5512`.)
220 * The implementation of ``%`` checks for the left-side operand being
221 a Python string and special-cases it; this results in a 1-3%
222 performance increase for applications that frequently use ``%``
223 with strings, such as templating libraries.
224 (Implemented by Collin Winter; :issue:`5176`.)
226 * List comprehensions with an ``if`` condition are compiled into
227 faster bytecode. (Patch by Antoine Pitrou, back-ported to 2.7
228 by Jeffrey Yasskin; :issue:`4715`.)
230 .. ======================================================================
232 New, Improved, and Deprecated Modules
233 =====================================
235 As in every release, Python's standard library received a number of
236 enhancements and bug fixes. Here's a partial list of the most notable
237 changes, sorted alphabetically by module name. Consult the
238 :file:`Misc/NEWS` file in the source tree for a more complete list of
239 changes, or look through the Subversion logs for all the details.
241 * The :mod:`bz2` module's :class:`BZ2File` now supports the context
242 management protocol, so you can write ``with bz2.BZ2File(...) as f: ...``.
243 (Contributed by Hagen Fuerstenau; :issue:`3860`.)
245 * New class: the :class:`Counter` class in the :mod:`collections` module is
246 useful for tallying data. :class:`Counter` instances behave mostly
247 like dictionaries but return zero for missing keys instead of
248 raising a :exc:`KeyError`:
251 :options: +NORMALIZE_WHITESPACE
253 >>> from collections import Counter
255 >>> for letter in 'here is a sample of english text':
259 Counter({' ': 6, 'e': 5, 's': 3, 'a': 2, 'i': 2, 'h': 2,
260 'l': 2, 't': 2, 'g': 1, 'f': 1, 'm': 1, 'o': 1, 'n': 1,
261 'p': 1, 'r': 1, 'x': 1})
267 There are two additional :class:`Counter` methods: :meth:`most_common`
268 returns the N most common elements and their counts, and :meth:`elements`
269 returns an iterator over the contained element, repeating each element
270 as many times as its count::
273 [(' ', 6), ('e', 5), ('s', 3), ('a', 2), ('i', 2)]
275 'a', 'a', ' ', ' ', ' ', ' ', ' ', ' ',
276 'e', 'e', 'e', 'e', 'e', 'g', 'f', 'i', 'i',
277 'h', 'h', 'm', 'l', 'l', 'o', 'n', 'p', 's',
278 's', 's', 'r', 't', 't', 'x'
280 Contributed by Raymond Hettinger; :issue:`1696199`.
282 The :class:`namedtuple` class now has an optional *rename* parameter.
283 If *rename* is true, field names that are invalid because they've
284 been repeated or that aren't legal Python identifiers will be
285 renamed to legal names that are derived from the field's
286 position within the list of fields:
288 >>> from collections import namedtuple
289 >>> T = namedtuple('T', ['field1', '$illegal', 'for', 'field2'], rename=True)
291 ('field1', '_1', '_2', 'field2')
293 (Added by Raymond Hettinger; :issue:`1818`.)
295 The :class:`deque` data type now exposes its maximum length as the
296 read-only :attr:`maxlen` attribute. (Added by Raymond Hettinger.)
298 * In Distutils, :func:`distutils.sdist.add_defaults` now uses
299 *package_dir* and *data_files* to create the MANIFEST file.
300 :mod:`distutils.sysconfig` will now read the :envvar:`AR`
301 environment variable.
303 It is no longer mandatory to store clear-text passwords in the
304 :file:`.pypirc` file when registering and uploading packages to PyPI. As long
305 as the username is present in that file, the :mod:`distutils` package will
306 prompt for the password if not present. (Added by Tarek Ziade,
307 based on an initial contribution by Nathan Van Gheem; :issue:`4394`.)
309 A Distutils setup can now specify that a C extension is optional by
310 setting the *optional* option setting to true. If this optional is
311 supplied, failure to build the extension will not abort the build
312 process, but instead simply not install the failing extension.
313 (Contributed by Georg Brandl; :issue:`5583`.)
315 * New method: the :class:`Decimal` class gained a
316 :meth:`from_float` class method that performs an exact conversion
317 of a floating-point number to a :class:`Decimal`.
318 Note that this is an **exact** conversion that strives for the
319 closest decimal approximation to the floating-point representation's value;
320 the resulting decimal value will therefore still include the inaccuracy,
322 For example, ``Decimal.from_float(0.1)`` returns
323 ``Decimal('0.1000000000000000055511151231257827021181583404541015625')``.
324 (Implemented by Raymond Hettinger; :issue:`4796`.)
326 * The :class:`Fraction` class will now accept two rational numbers
327 as arguments to its constructor.
328 (Implemented by Mark Dickinson; :issue:`5812`.)
330 * New function: the :mod:`gc` module's :func:`is_tracked` returns
331 true if a given instance is tracked by the garbage collector, false
332 otherwise. (Contributed by Antoine Pitrou; :issue:`4688`.)
334 * The :mod:`gzip` module's :class:`GzipFile` now supports the context
335 management protocol, so you can write ``with gzip.GzipFile(...) as f: ...``.
336 (Contributed by Hagen Fuerstenau; :issue:`3860`.)
337 It's now possible to override the modification time
338 recorded in a gzipped file by providing an optional timestamp to
339 the constructor. (Contributed by Jacques Frechet; :issue:`4272`.)
341 * The :class:`io.FileIO` class now raises an :exc:`OSError` when passed
342 an invalid file descriptor. (Implemented by Benjamin Peterson;
345 * New function: ``itertools.compress(*data*, *selectors*)`` takes two
346 iterators. Elements of *data* are returned if the corresponding
347 value in *selectors* is true::
349 itertools.compress('ABCDEF', [1,0,1,0,1,1]) =>
352 New function: ``itertools.combinations_with_replacement(*iter*, *r*)``
353 returns all the possible *r*-length combinations of elements from the
354 iterable *iter*. Unlike :func:`combinations`, individual elements
355 can be repeated in the generated combinations::
357 itertools.combinations_with_replacement('abc', 2) =>
358 ('a', 'a'), ('a', 'b'), ('a', 'c'),
359 ('b', 'b'), ('b', 'c'), ('c', 'c')
361 Note that elements are treated as unique depending on their position
362 in the input, not their actual values.
364 The :class:`itertools.count` function now has a *step* argument that
365 allows incrementing by values other than 1. :func:`count` also
366 now allows keyword arguments, and using non-integer values such as
367 floats or :class:`Decimal` instances. (Implemented by Raymond
368 Hettinger; :issue:`5032`.)
370 :func:`itertools.combinations` and :func:`itertools.product` were
371 previously raising :exc:`ValueError` for values of *r* larger than
372 the input iterable. This was deemed a specification error, so they
373 now return an empty iterator. (Fixed by Raymond Hettinger; :issue:`4816`.)
375 * The :mod:`json` module was upgraded to version 2.0.9 of the
376 simplejson package, which includes a C extension that makes
377 encoding and decoding faster.
378 (Contributed by Bob Ippolito; :issue:`4136`.)
380 To support the new :class:`OrderedDict` type, :func:`json.load`
381 now has an optional *object_pairs_hook* parameter that will be called
382 with any object literal that decodes to a list of pairs.
383 (Contributed by Raymond Hettinger; :issue:`5381`.)
385 * The :mod:`multiprocessing` module's :class:`Manager*` classes
386 can now be passed a callable that will be called whenever
387 a subprocess is started, along with a set of arguments that will be
388 passed to the callable.
389 (Contributed by lekma; :issue:`5585`.)
391 * The :mod:`pydoc` module now has help for the various symbols that Python
392 uses. You can now do ``help('<<')`` or ``help('@')``, for example.
393 (Contributed by David Laban; :issue:`4739`.)
395 * The :mod:`re` module's :func:`split`, :func:`sub`, and :func:`subn`
396 now accept an optional *flags* argument, for consistency with the
397 other functions in the module. (Added by Gregory P. Smith.)
399 * New function: the :mod:`subprocess` module's
400 :func:`check_output` runs a command with a specified set of arguments
401 and returns the command's output as a string when the command runs without
402 error, or raises a :exc:`CalledProcessError` exception otherwise.
406 >>> subprocess.check_output(['df', '-h', '.'])
407 'Filesystem Size Used Avail Capacity Mounted on\n
408 /dev/disk0s2 52G 49G 3.0G 94% /\n'
410 >>> subprocess.check_output(['df', '-h', '/bogus'])
412 subprocess.CalledProcessError: Command '['df', '-h', '/bogus']' returned non-zero exit status 1
414 (Contributed by Gregory P. Smith.)
416 * New function: :func:`is_declared_global` in the :mod:`symtable` module
417 returns true for variables that are explicitly declared to be global,
418 false for ones that are implicitly global.
419 (Contributed by Jeremy Hylton.)
421 * The ``sys.version_info`` value is now a named tuple, with attributes
422 named ``major``, ``minor``, ``micro``, ``releaselevel``, and ``serial``.
423 (Contributed by Ross Light; :issue:`4285`.)
425 * The :mod:`threading` module's :meth:`Event.wait` method now returns
426 the internal flag on exit. This means the method will usually
427 return true because :meth:`wait` is supposed to block until the
428 internal flag becomes true. The return value will only be false if
429 a timeout was provided and the operation timed out.
430 (Contributed by XXX; :issue:`1674032`.)
432 * The :mod:`unittest` module was enhanced in several ways.
433 The progress messages will now show 'x' for expected failures
434 and 'u' for unexpected successes when run in verbose mode.
435 (Contributed by Benjamin Peterson.)
436 Test cases can raise the :exc:`SkipTest` exception to skip a test.
439 The error messages for :meth:`assertEqual`,
440 :meth:`assertTrue`, and :meth:`assertFalse`
441 failures now provide more information. If you set the
442 :attr:`longMessage` attribute of your :class:`TestCase` classes to
443 true, both the standard error message and any additional message you
444 provide will be printed for failures. (Added by Michael Foord; :issue:`5663`.)
446 The :meth:`assertRaises` and :meth:`failUnlessRaises` methods now
447 return a context handler when called without providing a callable
448 object to run. For example, you can write this::
450 with self.assertRaises(KeyError):
453 (Implemented by Antoine Pitrou; :issue:`4444`.)
455 The methods :meth:`addCleanup` and :meth:`doCleanups` were added.
456 :meth:`addCleanup` allows you to add cleanup functions that
457 will be called unconditionally (after :meth:`setUp` if
458 :meth:`setUp` fails, otherwise after :meth:`tearDown`). This allows
459 for much simpler resource allocation and deallocation during tests.
462 A number of new methods were added that provide more specialized
463 tests. Many of these methods were written by Google engineers
464 for use in their test suites; Gregory P. Smith, Michael Foord, and
465 GvR worked on merging them into Python's version of :mod:`unittest`.
467 * :meth:`assertIsNone` and :meth:`assertIsNotNone` take one
468 expression and verify that the result is or is not ``None``.
470 * :meth:`assertIs` and :meth:`assertIsNot` take two values and check
471 whether the two values evaluate to the same object or not.
472 (Added by Michael Foord; :issue:`2578`.)
474 * :meth:`assertGreater`, :meth:`assertGreaterEqual`,
475 :meth:`assertLess`, and :meth:`assertLessEqual` compare
478 * :meth:`assertMultiLineEqual` compares two strings, and if they're
479 not equal, displays a helpful comparison that highlights the
480 differences in the two strings.
482 * :meth:`assertRegexpMatches` checks whether its first argument is a
483 string matching a regular expression provided as its second argument.
485 * :meth:`assertRaisesRegexp` checks whether a particular exception
486 is raised, and then also checks that the string representation of
487 the exception matches the provided regular expression.
489 * :meth:`assertIn` and :meth:`assertNotIn` tests whether
490 *first* is or is not in *second*.
492 * :meth:`assertSameElements` tests whether two provided sequences
493 contain the same elements.
495 * :meth:`assertSetEqual` compares whether two sets are equal, and
496 only reports the differences between the sets in case of error.
498 * Similarly, :meth:`assertListEqual` and :meth:`assertTupleEqual`
499 compare the specified types and explain the differences.
500 More generally, :meth:`assertSequenceEqual` compares two sequences
501 and can optionally check whether both sequences are of a
504 * :meth:`assertDictEqual` compares two dictionaries and reports the
505 differences. :meth:`assertDictContainsSubset` checks whether
506 all of the key/value pairs in *first* are found in *second*.
508 * A new hook, :meth:`addTypeEqualityFunc` takes a type object and a
509 function. The :meth:`assertEqual` method will use the function
510 when both of the objects being compared are of the specified type.
511 This function should compare the two objects and raise an
512 exception if they don't match; it's a good idea for the function
513 to provide additional information about why the two objects are
514 matching, much as the new sequence comparison methods do.
516 :func:`unittest.main` now takes an optional ``exit`` argument.
517 If False ``main`` doesn't call :func:`sys.exit` allowing it to
518 be used from the interactive interpreter. :issue:`3379`.
520 :class:`TestResult` has new :meth:`startTestRun` and
521 :meth:`stopTestRun` methods; called immediately before
522 and after a test run. :issue:`5728` by Robert Collins.
524 * The :func:`is_zipfile` function in the :mod:`zipfile` module will now
525 accept a file object, in addition to the path names accepted in earlier
526 versions. (Contributed by Gabriel Genellina; :issue:`4756`.)
528 :mod:`zipfile` now supports archiving empty directories and
529 extracts them correctly. (Fixed by Kuba Wieczorek; :issue:`4710`.)
531 .. ======================================================================
532 .. whole new modules get described in subsections here
534 importlib: Importing Modules
535 ------------------------------
537 Python 3.1 includes the :mod:`importlib` package, a re-implementation
538 of the logic underlying Python's :keyword:`import` statement.
539 :mod:`importlib` is useful for implementors of Python interpreters and
540 to user who wish to write new importers that can participate in the
541 import process. Python 2.7 doesn't contain the complete
542 :mod:`importlib` package, but instead has a tiny subset that contains
543 a single function, :func:`import_module`.
545 ``import_module(*name*, *package*=None)`` imports a module. *name* is
546 a string containing the module or package's name. It's possible to do
547 relative imports by providing a string that begins with a ``.``
548 character, such as ``..utils.errors``. For relative imports, the
549 *package* argument must be provided and is the name of the package that
550 will be used as the anchor for
551 the relative import. :func:`import_module` both inserts the imported
552 module into ``sys.modules`` and returns the module object.
554 Here are some examples::
556 >>> from importlib import import_module
557 >>> anydbm = import_module('anydbm') # Standard absolute import
559 <module 'anydbm' from '/p/python/Lib/anydbm.py'>
560 >>> # Relative import
561 >>> sysconfig = import_module('..sysconfig', 'distutils.command')
563 <module 'distutils.sysconfig' from '/p/python/Lib/distutils/sysconfig.pyc'>
565 :mod:`importlib` was implemented by Brett Cannon and introduced in
569 ttk: Themed Widgets for Tk
570 --------------------------
572 Tcl/Tk 8.5 includes a set of themed widgets that re-implement basic Tk
573 widgets but have a more customizable appearance and can therefore more
574 closely resemble the native platform's widgets. This widget
575 set was originally called Tile, but was renamed to Ttk (for "themed Tk")
576 on being added to Tcl/Tck release 8.5.
578 XXX write a brief discussion and an example here.
580 The :mod:`ttk` module was written by Guilherme Polo and added in
581 :issue:`2983`. An alternate version called ``Tile.py``, written by
582 Martin Franklin and maintained by Kevin Walzer, was proposed for
583 inclusion in :issue:`2618`, but the authors argued that Guilherme
584 Polo's work was more comprehensive.
586 .. ======================================================================
589 Build and C API Changes
590 =======================
592 Changes to Python's build process and to the C API include:
594 * If you use the :file:`.gdbinit` file provided with Python,
595 the "pyo" macro in the 2.7 version will now work when the thread being
596 debugged doesn't hold the GIL; the macro will now acquire it before printing.
597 (Contributed by Victor Stinner; :issue:`3632`.)
599 * :cfunc:`Py_AddPendingCall` is now thread-safe, letting any
600 worker thread submit notifications to the main Python thread. This
601 is particularly useful for asynchronous IO operations.
602 (Contributed by Kristjan Valur Jonsson; :issue:`4293`.)
604 * Global symbols defined by the :mod:`ctypes` module are now prefixed
605 with ``Py`, or with ``_ctypes``. (Implemented by Thomas
606 Heller; :issue:`3102`.)
608 * The :program:`configure` script now checks for floating-point rounding bugs
609 on certain 32-bit Intel chips and defines a :cmacro:`X87_DOUBLE_ROUNDING`
610 preprocessor definition. No code currently uses this definition,
611 but it's available if anyone wishes to use it.
612 (Added by Mark Dickinson; :issue:`2937`.)
614 .. ======================================================================
616 Port-Specific Changes: Windows
617 -----------------------------------
619 * The :mod:`msvcrt` module now contains some constants from
620 the :file:`crtassem.h` header file:
621 :data:`CRT_ASSEMBLY_VERSION`,
622 :data:`VC_ASSEMBLY_PUBLICKEYTOKEN`,
623 and :data:`LIBRARIES_ASSEMBLY_NAME_PREFIX`.
624 (Contributed by David Cournapeau; :issue:`4365`.)
626 * The new :cfunc:`_beginthreadex` API is used to start threads, and
627 the native thread-local storage functions are now used.
628 (Contributed by Kristjan Valur Jonsson; :issue:`3582`.)
630 .. ======================================================================
632 Port-Specific Changes: Mac OS X
633 -----------------------------------
635 * The ``/Library/Python/2.7/site-packages`` is now appended to
636 ``sys.path``, in order to share added packages between the system
637 installation and a user-installed copy of the same version.
638 (Changed by Ronald Oussoren; :issue:`4865`.)
641 Other Changes and Fixes
642 =======================
644 * When importing a module from a :file:`.pyc` or :file:`.pyo` file
645 with an existing :file:`.py` counterpart, the :attr:`co_filename`
646 attributes of the resulting code objects are overwritten when the
647 original filename is obsolete. This can happen if the file has been
648 renamed, moved, or is accessed through different paths. (Patch by
649 Ziga Seilnacht and Jean-Paul Calderone; :issue:`1180193`.)
651 * The :file:`regrtest.py` script now takes a :option:`--randseed=`
652 switch that takes an integer that will be used as the random seed
653 for the :option:`-r` option that executes tests in random order.
654 The :option:`-r` option also now reports the seed that was used
655 (Added by Collin Winter.)
657 * The :file:`regrtest.py` script now takes a :option:`-j` switch
658 that takes an integer specifying how many tests run in parallel. This
659 allows to shorten the total runtime on multi-core machines.
660 This option is compatible with several other options, including the
661 :option:`-R` switch which is known to produce long runtimes.
662 (Added by Antoine Pitrou, :issue:`6152`.)
664 .. ======================================================================
666 Porting to Python 2.7
667 =====================
669 This section lists previously described changes and other bugfixes
670 that may require changes to your code:
672 * Because of an optimization for the :keyword:`with` statement, the special
673 methods :meth:`__enter__` and :meth:`__exit__` must belong to the object's
674 type, and cannot be directly attached to the object's instance. This
675 affects new-style classes (derived from :class:`object`) and C extension
676 types. (:issue:`6101`.)
678 .. ======================================================================
686 The author would like to thank the following people for offering
687 suggestions, corrections and assistance with various drafts of this