3
3
# svn diff http://svn.python.org/projects/python/tags/r32rc1 http://svn.python.org/projects/python/branches/release32-maint | filterdiff --exclude=Lib/pstats.py --exclude=Lib/profile.py --exclude=.*ignore --addoldprefix=a/ --addnewprefix=b/ --remove-timestamps
4
4
# svn diff http://svn.python.org/projects/python/tags/r32rc1 http://svn.python.org/projects/python/branches/py3k | filterdiff --exclude=Lib/pstats.py --exclude=Lib/profile.py --exclude=.*ignore --addoldprefix=a/ --addnewprefix=b/ --remove-timestamps
6
Index: Include/patchlevel.h
7
===================================================================
8
--- a/Include/patchlevel.h
9
+++ b/Include/patchlevel.h
11
#define PY_RELEASE_SERIAL 1
13
/* Version as a string */
14
-#define PY_VERSION "3.2rc1"
15
+#define PY_VERSION "3.2rc1+"
18
/* Subversion Revision number of this file (not of the repository) */
19
Index: Objects/typeobject.c
20
===================================================================
21
--- a/Objects/typeobject.c
22
+++ b/Objects/typeobject.c
23
@@ -2945,10 +2945,7 @@
25
PyObject *slots_a, *slots_b;
27
- if (base != b->tp_base)
29
- if (equiv_structs(a, base) && equiv_structs(b, base))
31
+ assert(base == b->tp_base);
32
size = base->tp_basicsize;
33
if (a->tp_dictoffset == size && b->tp_dictoffset == size)
34
size += sizeof(PyObject *);
35
Index: Objects/rangeobject.c
36
===================================================================
37
--- a/Objects/rangeobject.c
38
+++ b/Objects/rangeobject.c
40
* Result indicates whether or not the slice is empty
41
* (-1 = error, 0 = empty slice, 1 = slice contains elements)
45
compute_slice_indices(rangeobject *r, PySliceObject *slice,
46
PyObject **start, PyObject **stop, PyObject **step)
48
Index: Objects/memoryobject.c
49
===================================================================
50
--- a/Objects/memoryobject.c
51
+++ b/Objects/memoryobject.c
55
CHECK_RELEASED_INT(self);
56
- /* XXX for whatever reason fixing the flags seems necessary */
57
- if (self->view.readonly)
58
- flags &= ~PyBUF_WRITABLE;
59
if (self->view.obj != NULL)
60
res = PyObject_GetBuffer(self->view.obj, view, flags);
62
Index: Misc/README.klocwork
63
===================================================================
64
--- a/Misc/README.klocwork
65
+++ b/Misc/README.klocwork
68
-Klocwork has a static analysis tool (K7) which is similar to Coverity.
69
-They will run their tool on the Python source code on demand.
70
-The results are available at:
72
- https://opensource.klocwork.com/
74
-Currently, only Neal Norwitz has access to the analysis reports. Other
75
-people can be added by request.
77
-K7 was first run on the Python 2.5 source code in mid-July 2006.
78
-This is after Coverity had been making their results available.
79
-There were originally 175 defects reported. Most of these
80
-were false positives. However, there were numerous real issues
83
-Each warning has a unique id and comments that can be made on it.
84
-When checking in changes due to a K7 report, the unique id
85
-as reported by the tool was added to the SVN commit message.
86
-A comment was added to the K7 warning indicating the SVN revision
87
-in addition to any analysis.
89
-False positives were also annotated so that the comments can
90
-be reviewed and reversed if the analysis was incorrect.
92
-A second run was performed on 10-Aug-2006. The tool was tuned to remove
93
-some false positives and perform some additional checks. ~150 new
94
-warnings were produced, primarily related to dereferencing NULL pointers.
96
-Contact python-dev@python.org for more information.
97
Index: Misc/PURIFY.README
98
===================================================================
99
--- a/Misc/PURIFY.README
100
+++ b/Misc/PURIFY.README
102
-Purify (tm) and Quantify (tm) are commercial software quality
103
-assurance tools available from IBM <http://www.ibm.com/software/rational/>.
104
-Purify is essentially a memory access
105
-verifier and leak detector; Quantify is a C level profiler. The rest
106
-of this file assumes you generally know how to use Purify and
107
-Quantify, and that you have installed valid licenses for these
108
-products. If you haven't installed such licenses, you can ignore the
109
-following since it won't help you a bit!
111
-You can easily build a Purify or Quantify instrumented version of the
112
-Python interpreter by passing the PURIFY variable to the make command
113
-at the top of the Python tree:
117
-This assumes that the `purify' program is on your $PATH. Note that
118
-you cannot both Purify and Quantify the Python interpreter (or any
119
-program for that matter) at the same time. If you want to build a
120
-Quantify'd interpreter, do this:
122
- make PURIFY=quantify
124
-Starting with Python 2.3, pymalloc is enabled by default. This
125
-will cause many supurious warnings. Modify Objects/obmalloc.c
126
-and enable Py_USING_MEMORY_DEBUGGER by uncommenting it.
127
-README.valgrind has more details about why this is necessary.
128
-See below about setting up suppressions. Some tests may not
129
-run well with Purify due to heavy memory or CPU usage. These
130
-tests may include: test_largefile, test_import, and test_long.
132
-Please report any findings (problems or no warnings) to python-dev@python.org.
133
-It may be useful to submit a bug report for any problems.
135
-When running the regression test (make test), I have found it useful
136
-to set my PURIFYOPTIONS environment variable using the following
137
-(bash) shell function. Check out the Purify documentation for
141
- chainlen='-chain-length=12'
142
- ignoresigs='-ignore-signals="SIGHUP,SIGINT,SIGQUIT,SIGILL,SIGTRAP,SIGAVRT,SIGEMT,SIGFPE,SIGKILL,SIGBUS,SIGSEGV,SIGPIPE,SIGTERM,SIGUSR1,SIGUSR2,SIGPOLL,SIGXCPU,SIGXFSZ,SIGFREEZE,SIGTHAW,SIGRTMIN,SIGRTMAX"'
143
- followchild='-follow-child-processes=yes'
144
- threads='-max-threads=50'
145
- export PURIFYOPTIONS="$chainlen $ignoresigs $followchild $threads"
146
- echo $PURIFYOPTIONS
149
-Note that you may want to crank -chain-length up even further. A
150
-value of 20 should get you the entire stack up into the Python C code
153
-With the regression test on a fatly configured interpreter
154
-(i.e. including as many modules as possible in your Modules/Setup
155
-file), you'll probably get a gabillion UMR errors, and a few MLK
156
-errors. I think most of these can be safely suppressed by putting the
157
-following in your .purify file:
159
- suppress umr ...; "socketmodule.c"
160
- suppress umr ...; time_strftime
161
- suppress umr ...; "_dbmmodule.c"
162
- suppress umr ...; "_gdbmmodule.c"
163
- suppress umr ...; "grpmodule.c"
164
- suppress umr ...; "nismodule.c"
165
- suppress umr ...; "pwdmodule.c"
167
-Note: this list is very old and may not be accurate any longer.
168
-It's possible some of these no longer need to be suppressed.
169
-You will also need to suppress warnings (at least umr)
170
-from Py_ADDRESS_IN_RANGE.
172
-This will still leave you with just a few UMR, mostly in the readline
173
-library, which you can safely ignore. A lot of work has gone into
174
-Python 1.5 to plug as many leaks as possible.
176
-Using Purify or Quantify in this way will give you coarse grained
177
-reports on the whole Python interpreter. You can actually get more
178
-fine grained control over both by linking with the optional `pure'
179
-module, which exports (most of) the Purify and Quantify C API's into
180
-Python. To link in this module (it must be statically linked), edit
181
-your Modules/Setup file for your site, and rebuild the interpreter.
182
-You might want to check out the comments in the Modules/puremodule.c
183
-file for some idiosyncrasies.
185
-Using this module, you can actually profile or leak test a small
186
-section of code, instead of the whole interpreter. Using this in
187
-conjuction with pdb.py, dbx, or the profiler.py module really gives
188
-you quite a bit of introspective power.
190
-Naturally there are a couple of caveats. This has only been tested
191
-with Purify 4.0.1 and Quantify 2.1-beta on Solaris 2.5. Purify 4.0.1
192
-does not work with Solaris 2.6, but Purify 4.1 which reportedly will,
193
-is currently in beta test. There are funky problems when Purify'ing a
194
-Python interpreter build with threads. I've had a lot of problems
195
-getting this to work, so I generally don't build with threads when I'm
196
-Purify'ing. If you get this to work, let us know!
198
--Barry Warsaw <bwarsaw@cnri.reston.va.us>
199
Index: Misc/README.gdb
200
===================================================================
201
--- a/Misc/README.gdb
202
+++ b/Misc/README.gdb
204
+gdb Support for Python
205
+======================
209
+In gdb 7, support for extending gdb with Python was added. When CPython is
210
+built you will notice a python-gdb.py file in the root directory of your
211
+checkout. Read the module docstring for details on how to use the file to
212
+enhance gdb for easier debugging of a CPython process.
217
+The file at ``Misc/gdbinit`` contains a gdb configuration file which provides
218
+extra commands when working with a CPython process. To use the file, either
219
+copy the commands to your personal gdb configuration file or symlink
220
+``~/.gdbinit`` to ``Misc/gdbinit``.
222
===================================================================
229
+What's New in Python 3.2 Release Candidate 2?
230
+=============================================
232
+*Release date: XX-Jan-2011*
237
+- Issue #10451: memoryview objects could allow to mutate a readable buffer.
238
+ Initial patch by Ross Lagerwall.
244
What's New in Python 3.2 Release Candidate 1
245
============================================
251
+- Issue #10889: range indexing and slicing now works correctly on ranges with
252
+ a length that exceeds sys.maxsize.
254
- Issue #10892: Don't segfault when trying to delete __abstractmethods__ from a
257
- Issue #8020: Avoid a crash where the small objects allocator would read
258
- non-Python managed memory while it is being modified by another thread.
259
- Patch by Matt Bandy.
260
+ non-Python managed memory while it is being modified by another thread. Patch
263
- all io.FileIO objects (to not translate newlines, \r\n <=> \n). The Python
264
- parser translates newlines (\r\n => \n).
265
+- Issue #10841: On Windows, set the binary mode on stdin, stdout, stderr and all
266
+ io.FileIO objects (to not translate newlines, \r\n <=> \n). The Python parser
267
+ translates newlines (\r\n => \n).
269
- Remove buffer API from stable ABI for now, see #10181.
275
- length and a non-zero offset, and an attempt to read past the end of file
276
- is made (IndexError is raised instead). Patch by Ross Lagerwall.
277
+- Issue #10916: mmap should not segfault when a file is mapped using 0 as length
278
+ and a non-zero offset, and an attempt to read past the end of file is made
279
+ (IndexError is raised instead). Patch by Ross Lagerwall.
281
- rather than the currently problematic Apple-supplied one, when running
282
- with the 64-/32-bit installer variant.
283
+- Issue #10907: Warn OS X 10.6 IDLE users to use ActiveState Tcl/Tk 8.5, rather
284
+ than the currently problematic Apple-supplied one, when running with the
285
+ 64-/32-bit installer variant.
287
- Issue #4953: cgi.FieldStorage and cgi.parse() parse the request as bytes, not
288
as unicode, and accept binary files. Add encoding and errors attributes to
289
cgi.FieldStorage. Patch written by Pierre Quentel (with many inputs by Glenn
292
+- Add encoding and errors arguments to urllib.parse_qs() and urllib.parse_qsl().
294
- Removed function type annotations from _pyio.py.
295
+- Issue #10899: No function type annotations in the standard library. Removed
296
+ function type annotations from _pyio.py.
298
- Issue #10875: Update Regular Expression HOWTO; patch by 'SilentGhost'.
300
- Issue #10872: The repr() of TextIOWrapper objects now includes the mode
304
+- Issue #10869: Fixed bug where ast.increment_lineno modified the root node
307
- Issue #5871: email.header.Header.encode now raises an error if any
308
- continuation line in the formatted value has no leading white space
309
- and looks like a header. Since Generator uses Header to format all
310
- headers, this check is made for all headers in any serialized message
311
- at serialization time. This provides protection against header
313
+ continuation line in the formatted value has no leading white space and looks
314
+ like a header. Since Generator uses Header to format all headers, this check
315
+ is made for all headers in any serialized message at serialization time. This
316
+ provides protection against header injection attacks.
318
- Issue #10859: Make ``contextlib.GeneratorContextManager`` officially
319
private by renaming it to ``_GeneratorContextManager``.
321
comparisons that could lead to infinite recursion.
323
- Issue #10686: the email package now :rfc:`2047`\ -encodes headers with
324
- non-ASCII bytes (parsed by a Bytes Parser) when doing conversion to
325
- 7bit-clean presentation, instead of replacing them with ?s.
326
+ non-ASCII bytes (parsed by a Bytes Parser) when doing conversion to 7bit-clean
327
+ presentation, instead of replacing them with ?s.
329
- email.header.Header was incorrectly encoding folding white space when
330
- rfc2047-encoding header values with embedded newlines, leaving them
331
- without folding whitespace. It now uses the continuation_ws, as it
332
- does for continuation lines that it creates itself.
333
+ rfc2047-encoding header values with embedded newlines, leaving them without
334
+ folding whitespace. It now uses the continuation_ws, as it does for
335
+ continuation lines that it creates itself.
337
- Issue #1777412, #10827: Changed the rules for 2-digit years. The
338
time.asctime(), time.ctime() and time.strftime() functions will now format
339
@@ -125,12 +142,12 @@
340
the input buffer length doesn't fit into an unsigned int (length bigger than
343
- to avoid a potential rare deadlock or crash on some platforms.
344
+- Issue #6643: Reinitialize locks held within the threading module after fork to
345
+ avoid a potential rare deadlock or crash on some platforms.
347
- file descriptors (0, 1, 2) are closed in the parent process. Initial
348
- patch by Ross Lagerwall.
349
+- Issue #10806, issue #9905: Fix subprocess pipes when some of the standard file
350
+ descriptors (0, 1, 2) are closed in the parent process. Initial patch by Ross
353
- `unittest.TestCase` can be instantiated without a method name; for simpler
354
exploration from the interactive interpreter.
355
@@ -141,32 +158,32 @@
356
- Issue #10807: Remove base64, bz2, hex, quopri, rot13, uu and zlib codecs from
357
the codec aliases. They are still accessible via codecs.lookup().
360
+- Issue #10801: In zipfile, support different encodings for the header and the
363
- Issue #6285: IDLE no longer crashes on missing help file; patch by Scott
366
- subclasses that define __missing__().
367
+- Fix collections.OrderedDict.setdefault() so that it works in subclasses that
368
+ define __missing__().
370
- import time. `sys.stderr` now looked up at instantiation time. Fix
371
- contributed by Mark Roddy.
372
+- Issue #10786: unittest.TextTestRunner default stream no longer bound at import
373
+ time. `sys.stderr` now looked up at instantiation time. Fix contributed by
376
- variable won't be quoted when the URI is constructed by the wsgiref.util 's
377
- request_uri method. According to RFC 3986, these characters can be a part of
378
- params in PATH component of URI and need not be quoted.
379
+- Issue #10753: Characters ';','=' and ',' in the PATH_INFO environment variable
380
+ won't be quoted when the URI is constructed by the wsgiref.util 's request_uri
381
+ method. According to RFC 3986, these characters can be a part of params in
382
+ PATH component of URI and need not be quoted.
384
- Issue #10738: Fix webbrowser.Opera.raise_opts.
386
- Issue #9824: SimpleCookie now encodes , and ; in values to cater to how
387
browsers actually parse cookies.
389
- The function now raises OSError on Windows >=6.0 when the user is unable
390
- to create symbolic links. XP and 2003 still raise NotImplementedError.
391
+- Issue #9333: os.symlink now available regardless of user privileges. The
392
+ function now raises OSError on Windows >=6.0 when the user is unable to create
393
+ symbolic links. XP and 2003 still raise NotImplementedError.
395
- Issue #10783: struct.pack() no longer implicitly encodes unicode to UTF-8.
397
@@ -209,16 +226,15 @@
398
- Issue #10913: Deprecate misleading functions PyEval_AcquireLock() and
399
PyEval_ReleaseLock(). The thread-state aware APIs should be used instead.
402
+- Issue #10333: Remove ancient GC API, which has been deprecated since Python
408
- 32-bit installer builds: bzip2 1.0.6, readline 6.1.2, SQLite 3.7.4
409
- (with FTS3/FTS4 and RTREE enabled), and ncursesw 5.5 (wide-char
411
+- Issue #10843: Update third-party library versions used in OS X 32-bit
412
+ installer builds: bzip2 1.0.6, readline 6.1.2, SQLite 3.7.4 (with FTS3/FTS4
413
+ and RTREE enabled), and ncursesw 5.5 (wide-char support enabled).
415
- Issue #10820: Fix OS X framework installs to support version-specific
417
@@ -240,17 +256,17 @@
421
- Extras (/Applications/Python 3.n/Extras/) where the Demo directory
422
- had previous been installed.
423
+- Issue #10843: Install the Tools directory on OS X in the applications Extras
424
+ (/Applications/Python 3.n/Extras/) where the Demo directory had previous been
427
- Issue #7962: The Demo directory is gone. Most of the old and unmaintained
428
demos have been removed, others integrated in documentation or a new
429
Tools/demo subdirectory.
431
- Issue #10502: Addition of the unittestgui tool. Originally by Steve Purcell.
432
- Updated for test discovery by Mark Roddy and Python 3 compatibility by
434
+ Updated for test discovery by Mark Roddy and Python 3 compatibility by Brian
440
- Issue #5485: Add tests for the UseForeignDTD method of expat parser objects.
441
Patch by Jean-Paul Calderone and Sandro Tosi.
443
- in whole runs and enabled selectively using ``--header`` when running an
444
- explicit list of tests. Original patch by Collin Winter.
445
+- Issue #6293: Have regrtest.py echo back sys.flags. This is done by default in
446
+ whole runs and enabled selectively using ``--header`` when running an explicit
447
+ list of tests. Original patch by Collin Winter.
450
What's New in Python 3.2 Beta 2?
451
Index: Tools/msi/msi.py
452
===================================================================
453
--- a/Tools/msi/msi.py
454
+++ b/Tools/msi/msi.py
455
@@ -1025,6 +1025,7 @@
458
lib.glob("cfgparser.*")
459
+ lib.add_file("zip_cp437_header.zip")
460
lib.add_file("zipdir.zip")
463
@@ -1035,8 +1036,6 @@
464
if dir=='xmltestdata':
466
lib.add_file("test.xml.out")
467
- if dir=='subprocessdata':
471
if dir=='sndhdrdata':
472
Index: Doc/whatsnew/3.2.rst
473
===================================================================
474
--- a/Doc/whatsnew/3.2.rst
475
+++ b/Doc/whatsnew/3.2.rst
478
:pep:`392` - Python 3.2 Release Schedule
481
PEP 384: Defining a Stable ABI
482
==============================
485
:pep:`384` - Defining a Stable ABI
486
PEP written by Martin von Löwis.
489
PEP 389: Argparse Command Line Parsing Module
490
=============================================
493
positional arguments (not just options), subcommands, required options and other
494
common patterns of specifying and validating options.
496
-This module has already has wide-spread success in the community as a
497
+This module has already has widespread success in the community as a
498
third-party module. Being more fully featured than its predecessor, the
499
:mod:`argparse` module is now the preferred module for command-line processing.
500
The older module is still being kept available because of the substantial amount
501
@@ -101,14 +103,14 @@
502
description = 'Manage servers', # main description for help
503
epilog = 'Tested on Solaris and Linux') # displayed after help
504
parser.add_argument('action', # argument name
505
- choices = ['deploy', 'start', 'stop'], # one of four allowed values
506
+ choices = ['deploy', 'start', 'stop'], # three allowed values
507
help = 'action on each target') # help msg
508
parser.add_argument('targets',
509
metavar = 'HOSTNAME', # var name used in help msg
510
- nargs = '+', # require 1 or more targets
511
+ nargs = '+', # require one or more targets
512
help = 'url for target machines') # help msg explanation
513
parser.add_argument('-u', '--user', # -u or --user option
514
- required = True, # make this a required argument
515
+ required = True, # make it a required argument
516
help = 'login as user')
518
Example of calling the parser on a command string::
520
If that dictionary is stored in a file called :file:`conf.json`, it can be
521
loaded and called with code like this::
523
- >>> import logging.config
524
- >>> logging.config.dictConfig(json.load(open('conf.json', 'rb')))
525
+ >>> import json, logging.config
526
+ >>> with open('conf.json', 'rb') as f:
527
+ conf = json.load(f)
528
+ >>> logging.config.dictConfig(conf)
529
>>> logging.info("Transaction completed normally")
530
>>> logging.critical("Abnormal termination")
532
@@ -218,16 +222,17 @@
533
:pep:`391` - Dictionary Based Configuration for Logging
534
PEP written by Vinay Sajip.
537
PEP 3148: The ``concurrent.futures`` module
538
============================================
540
-Code for creating and managing concurrency is being collected in a new toplevel
541
+Code for creating and managing concurrency is being collected in a new top-level
542
namespace, *concurrent*. Its first member is a *futures* package which provides
543
-a uniform high level interface for managing threads and processes.
544
+a uniform high-level interface for managing threads and processes.
546
The design for :mod:`concurrent.futures` was inspired by
547
*java.util.concurrent.package*. In that model, a running call and its result
548
-are represented by a :class:`~concurrent.futures.Future` object which abstracts
549
+are represented by a :class:`~concurrent.futures.Future` object that abstracts
550
features common to threads, processes, and remote procedure calls. That object
551
supports status checks (running or done), timeouts, cancellations, adding
552
callbacks, and access to results or exceptions.
554
returning a :class:`~concurrent.futures.Future` object;
555
:meth:`~concurrent.futures.Executor.map` for scheduling many asynchronous calls
556
at a time, and :meth:`~concurrent.futures.Executor.shutdown` for freeing
557
-resources. The class is a :term:`context manager` and can be used within a
558
+resources. The class is a :term:`context manager` and can be used in a
559
:keyword:`with` statement to assure that resources are automatically released
560
when currently pending futures are done executing.
563
:class:`~concurrent.futures.ProcessPoolExecutor`.
567
PEP 3147: PYC Repository Directories
568
=====================================
571
* The :mod:`py_compile` and :mod:`compileall` modules have been updated to
572
reflect the new naming convention and target directory.
574
+* The :mod:`importlib.abc` module has been updated with new :term:`abstract base
575
+ classes <abstract base class>` for the loading bytecode files. The obsolete
576
+ ABCs, :class:`~importlib.abc.PyLoader` and
577
+ :class:`~importlib.abc.PyPycLoader`, have been deprecated (instructions on how
578
+ to stay Python 3.1 compatible are included with the documentation).
582
:pep:`3147` - PYC Repository Directories
584
:pep:`3149` - ABI Version Tagged .so Files
585
PEP written by Barry Warsaw.
588
PEP 3333: Python Web Server Gateway Interface v1.0.1
589
=====================================================
592
the bodies of requests and responses.
594
The *native strings* are always of type :class:`str` but are restricted to code
595
-points between *u0000* through *u00FF* which are translatable to bytes using
596
+points between *U+0000* through *U+00FF* which are translatable to bytes using
597
*Latin-1* encoding. These strings are used for the keys and values in the
598
environ dictionary and for response headers and statuses in the
599
:func:`start_response` function. They must follow :rfc:`2616` with respect to
602
For server implementers writing CGI-to-WSGI pathways or other CGI-style
603
protocols, the users must to be able access the environment using native strings
604
-eventhough the underlying platform may have a different convention. To bridge
605
+even though the underlying platform may have a different convention. To bridge
606
this gap, the :mod:`wsgiref` module has a new function,
607
:func:`wsgiref.handlers.read_environ` for transcoding CGI variables from
608
:attr:`os.environ` into native strings and returning a new dictionary.
610
:pep:`3333` - Python Web Server Gateway Interface v1.0.1
611
PEP written by Phillip Eby.
614
Other Language Changes
615
======================
617
@@ -476,24 +488,24 @@
618
* Previously it was illegal to delete a name from the local namespace if it
619
occurs as a free variable in a nested block::
632
This is now allowed. Remember that the target of an :keyword:`except` clause
633
is cleared, so this code which used to work with Python 2.6, raised a
634
:exc:`SyntaxError` with Python 3.1 and now works again::
637
- ... def print_error():
641
- ... except Exception as e:
643
- ... # implicit "del e" here
649
+ except Exception as e:
651
+ # implicit "del e" here
655
@@ -501,21 +513,20 @@
656
This means that C structures like those returned by :func:`os.stat`,
657
:func:`time.gmtime`, and :func:`sys.version_info` now work like a
658
:term:`named tuple` and now work with functions and methods that
659
- expect a tuple as an argument. The is a big step forward in making the C
660
+ expect a tuple as an argument. This is a big step forward in making the C
661
structures as flexible as their pure Python counterparts.
663
(Suggested by Arfrever Frehtes Taifersar Arahesis and implemented
664
by Benjamin Peterson in :issue:`8413`.)
666
-* Warnings are now easier to control. A :envvar:`PYTHONWARNINGS` environment
667
- variable is now available as an alternative to using ``-W`` at the command
669
+* Warnings are now easier to control using the :envvar:`PYTHONWARNINGS`
670
+ environment variable as an alternative to using ``-W`` at the command line.
672
(Suggested by Barry Warsaw and implemented by Philip Jenvey in :issue:`7301`.)
674
* A new warning category, :exc:`ResourceWarning`, has been added. It is
675
emitted when potential issues with resource consumption or cleanup
676
- are detected. It is silenced by default in normal release builds, but
677
+ are detected. It is silenced by default in normal release builds but
678
can be enabled through the means provided by the :mod:`warnings`
679
module, or on the command line.
682
of an effort to make more objects fully implement the
683
:class:`collections.Sequence` :term:`abstract base class`. As a result, the
684
language will have a more uniform API. In addition, :class:`range` objects
685
- now support slicing and negative indices. This makes *range* more
686
- interoperable with lists::
687
+ now support slicing and negative indices, even with values larger than
688
+ :attr:`sys.maxsize`. This makes *range* more interoperable with lists::
690
>>> range(0, 100, 2).count(10)
693
>>> range(0, 100, 2)[0:5]
696
- (Contributed by Daniel Stutzbach in :issue:`9213` and by Alexander Belopolsky
698
+ (Contributed by Daniel Stutzbach in :issue:`9213`, by Alexander Belopolsky
699
+ in :issue:`2690`, and by Nick Coghlan in :issue:`10889`.)
701
* The :func:`callable` builtin function from Py2.x was resurrected. It provides
702
a concise, readable alternative to using an :term:`abstract base class` in an
705
(See :issue:`10518`.)
707
-* Python's import mechanism can now load module installed in directories with
708
+* Python's import mechanism can now load modules installed in directories with
709
non-ASCII characters in the path name.
711
(Required extensive work by Victor Stinner in :issue:`9425`.)
712
@@ -586,13 +597,13 @@
713
Throughout the standard library, there has been more careful attention to
714
encodings and text versus bytes issues. In particular, interactions with the
715
operating system are now better able to pass non-ASCII data using the Windows
716
-mcbs encoding, locale-aware encodings, or UTF-8.
717
+MBCS encoding, locale-aware encodings, or UTF-8.
719
Another significant win is the addition of substantially better support for
720
*SSL* connections and security certificates.
722
In addition, more classes now implement a :term:`context manager` to support
723
-convenient and reliable resource clean-up using the :keyword:`with`-statement.
724
+convenient and reliable resource clean-up using a :keyword:`with` statement.
728
@@ -676,16 +687,16 @@
729
resource whenever the results are expected to be the same.
731
For example, adding a caching decorator to a database query function can save
732
- database accesses for popular searches::
733
+ database accesses for popular searches:
735
- @functools.lru_cache(maxsize=300)
736
- def get_phone_number(name):
738
- c.execute('SELECT phonenumber FROM phonelist WHERE name=?', (name,))
739
- return c.fetchone()[0]
740
+ >>> @functools.lru_cache(maxsize=300)
741
+ >>> def get_phone_number(name):
743
+ c.execute('SELECT phonenumber FROM phonelist WHERE name=?', (name,))
744
+ return c.fetchone()[0]
746
>>> for name in user_requests:
747
- ... get_phone_number(name) # cached lookup
748
+ get_phone_number(name) # cached lookup
750
To help with choosing an effective cache size, the wrapped function is
751
instrumented for tracking cache statistics:
752
@@ -787,25 +798,27 @@
754
* The :class:`collections.OrderedDict` class has a new method
755
:meth:`~collections.OrderedDict.move_to_end` which takes an existing key and
756
- moves it to either the beginning or end of an ordered sequence. When the
757
- dictionary sequence is being used as a queue, these operations correspond to
758
- "move to the front of the line" or "move to the back of the line":
759
+ moves it to either the first or last position in the ordered sequence.
761
+ The default is to move an item to the last position. This is equivalent of
762
+ renewing an entry with ``od[k] = od.pop(k)``.
764
+ A fast move-to-end operation is useful for resequencing entries. For example,
765
+ an ordered dictionary can being used to track access order by aging entries
766
+ from oldest to most recently accessed.
768
>>> d = OrderedDict.fromkeys(['a', 'b', 'X', 'd', 'e'])
770
['a', 'b', 'X', 'd', 'e']
771
- >>> d.move_to_end('X', last=True)
772
+ >>> d.move_to_end('X')
774
['a', 'b', 'd', 'e', 'X']
775
- >>> d.move_to_end('X', last=False)
777
- ['X', 'a', 'b', 'd', 'e']
779
(Contributed by Raymond Hettinger.)
781
-* The :class:`collections.deque` grew two new methods :meth:`~collections.deque.count`
782
- and :meth:`collections.deque.reverse` that make them more substitutable for
783
- :class:`list` when needed:
784
+* The :class:`collections.deque` class grew two new methods
785
+ :meth:`~collections.deque.count` and :meth:`~collections.deque.reverse` that
786
+ make them more substitutable for :class:`list` objects:
788
>>> d = deque('simsalabim')
790
@@ -829,14 +842,11 @@
791
of a `Rendezvous <http://en.wikipedia.org/wiki/Synchronous_rendezvous>`_ which
792
is defined for only two threads.
794
-The barrier is designed to be cyclic, making it reusable once all of the
795
-waiting threads are released.
796
+Implemented as a two-phase cyclic barrier, :class:`~threading.Barrier` objects
797
+are suitable for use in loops. The separate *filling* and *draining* phases
798
+assure that all threads get released (drained) before any one of them can loop
799
+back and re-enter the barrier. The barrier fully resets after each cycle.
801
-If any of the predecessor tasks can hang or be delayed, a barrier can be created
802
-with an optional *timeout* parameter. Then if the timeout period elapses before
803
-all the predecessor tasks reach the barrier point, all waiting threads are
804
-released and a :exc:`~threading.BrokenBarrierError` exception is raised.
806
Example of using barriers::
810
and continue to do work (summarizing ballots) after the barrier point is
813
+If any of the predecessor tasks can hang or be delayed, a barrier can be created
814
+with an optional *timeout* parameter. Then if the timeout period elapses before
815
+all the predecessor tasks reach the barrier point, all waiting threads are
816
+released and a :exc:`~threading.BrokenBarrierError` exception is raised::
818
+ def get_votes(site):
819
+ ballots = conduct_election(site)
821
+ all_polls_closed.wait(timeout = midnight - time.now())
822
+ except BrokenBarrierError:
823
+ lockbox = seal_ballots(ballots)
826
+ totals = summarize(ballots)
827
+ publish(site, totals)
829
+In this example, the barrier enforces a more robust rule. If some election
830
+sites do not finish before midnight, the barrier times-out and the ballots are
831
+sealed and deposited in a queue for later handling.
833
See `Barrier Synchronization Patterns
834
<http://parlab.eecs.berkeley.edu/wiki/_media/patterns/paraplop_g1_3.pdf>`_ for
835
more examples of how barriers can be used in parallel computing. Also, there is
837
:class:`float` and divided by :class:`float` and :class:`int` objects.
838
And :class:`~datetime.timedelta` objects can now divide one another.
840
-* The :class:`~datetime.datetime` class and the :meth:`datetime.date.strftime`
841
- method are no longer restricted to years after 1900. The new supported year
842
- range is from 1000 to 9999 inclusive.
843
+* The :meth:`datetime.date.strftime` method is no longer restricted to years
844
+ after 1900. The new supported year range is from 1000 to 9999 inclusive.
846
* The rules for two-digit years in time tuples have changed. Now, the
847
:func:`time.asctime` and :func:`time.strftime` functions will format any year
848
@@ -901,10 +930,18 @@
849
The :mod:`abc` module now supports :func:`~abc.abstractclassmethod` and
850
:func:`~abc.abstractstaticmethod`.
852
-These tools make it possible to define an :term:`Abstract Base Class` that
853
+These tools make it possible to define an :term:`abstract base class` that
854
requires a particular :func:`classmethod` or :func:`staticmethod` to be
858
+ class Temperature(metaclass=ABCMeta):
859
+ @abc.abstractclassmethod
860
+ def from_farenheit(self, t):
862
+ @abc.abstractclassmethod
863
+ def from_celsium(self, t):
866
(Patch submitted by Daniel Urban; :issue:`5867`.)
871
The basic idea is that both context managers and function decorators can be used
872
for pre-action and post-action wrappers. Context managers wrap a group of
873
-statements using the :keyword:`with`-statement, and function decorators wrap a
874
+statements using a :keyword:`with` statement, and function decorators wrap a
875
group of statements enclosed in a function. So, occasionally there is a need to
876
write a pre-action or post-action wrapper that can be used in either role.
878
@@ -928,32 +965,32 @@
879
with a logger that can track the time of entry and time of exit. Rather than
880
writing both a function decorator and a context manager for the task, the
881
:func:`~contextlib.contextmanager` provides both capabilities in a single
886
->>> logging.basicConfig(level=logging.INFO)
888
-... def track_entry_and_exit(name):
889
-... logging.info('Entering: {}'.format(name))
891
-... logging.info('Exiting: {}'.format(name))
893
+ logging.basicConfig(level=logging.INFO)
895
+ def track_entry_and_exit(name):
896
+ logging.info('Entering: {}'.format(name))
898
+ logging.info('Exiting: {}'.format(name))
900
-Formerly, this would have only been usable as a context manager:
901
+Formerly, this would have only been usable as a context manager::
903
->>> with track_entry_and_exit('widget loader'):
904
-... print('Some time consuming activity goes here')
906
+ with track_entry_and_exit('widget loader'):
907
+ print('Some time consuming activity goes here')
910
-Now, it can be used as a decorator as well:
911
+Now, it can be used as a decorator as well::
913
->>> @track_entry_and_exit('widget loader')
915
-... print('Some time consuming activity goes here')
917
+ @track_entry_and_exit('widget loader')
919
+ print('Some time consuming activity goes here')
922
Trying to fulfill two roles at once places some limitations on the technique.
923
Context managers normally have the flexibility to return an argument usable by
924
-the :keyword:`with`-statement, but there is no parallel for function decorators.
925
+a :keyword:`with` statement, but there is no parallel for function decorators.
927
In the above example, there is not a clean way for the *track_entry_and_exit*
928
context manager to return a logging instance for use in the body of enclosed
929
@@ -968,11 +1005,11 @@
930
different numeric datatypes will have the same hash value whenever their actual
931
values are equal (:issue:`8188`)::
933
- >>> assert hash(Fraction(3, 2)) == hash(1.5) == \
934
- hash(Decimal("1.5")) == hash(complex(1.5, 0))
935
+ assert hash(Fraction(3, 2)) == hash(1.5) == \
936
+ hash(Decimal("1.5")) == hash(complex(1.5, 0))
938
An early decision to limit the inter-operability of various numeric types has
939
-been relaxed. It is still unsupported (and ill-advised) to to have implicit
940
+been relaxed. It is still unsupported (and ill-advised) to have implicit
941
mixing in arithmetic expressions such as ``Decimal('1.1') + float('1.1')``
942
because the latter loses information in the process of constructing the binary
943
float. However, since existing floating point value can be converted losslessly
944
@@ -1031,11 +1068,17 @@
945
(Contributed by Tarek Ziadé and Giampaolo Rodolà in :issue:`4972`, and
946
by Georg Brandl in :issue:`8046` and :issue:`1286`.)
948
+The :class:`~ftplib.FTP_TLS` class now accepts a *context* parameter, which is a
949
+:class:`ssl.SSLContext` object allowing bundling SSL configuration options,
950
+certificates and private keys into a single (potentially long-lived) structure.
952
+(Contributed by Giampaolo Rodolà; :issue:`8806`.)
957
The :func:`os.popen` and :func:`subprocess.Popen` functions now support
958
-the :keyword:`with` statement for auto-closing of the file descriptors.
959
+:keyword:`with` statements for auto-closing of the file descriptors.
963
@@ -1071,19 +1114,19 @@
964
also solves an issue where interleaved calls to *read* and *readline* gave the
967
-(Patch submitted by by Nir Aides in :issue:`7610`.)
968
+(Patch submitted by Nir Aides in :issue:`7610`.)
973
The :func:`shutil.copytree` function has two new options:
975
- * *ignore_dangling_symlinks*: when ``symlinks=False`` so that the function
976
- copies the file pointed to by the symlink, not the symlink itself. This
977
- option will silence the error raised if the file doesn't exist.
978
+* *ignore_dangling_symlinks*: when ``symlinks=False`` so that the function
979
+ copies a file pointed to by a symlink, not the symlink itself. This option
980
+ will silence the error raised if the file doesn't exist.
982
- * *copy_function*: is a callable that will be used to copy files.
983
- :func:`shutil.copy2` is used by default.
984
+* *copy_function*: is a callable that will be used to copy files.
985
+ :func:`shutil.copy2` is used by default.
987
(Contributed by Tarek Ziadé.)
989
@@ -1120,45 +1163,45 @@
993
-* The :mod:`ssl` module has a new class, :class:`~ssl.SSLContext` which serves
994
- as a container for various persistent SSL data, such as protocol settings,
995
- certificates, private keys, and various other options. The
996
- :meth:`~ssl.SSLContext.wrap_socket` method allows to create an SSL socket from
997
- such an SSL context. (Added by Antoine Pitrou; :issue:`8550`.)
998
+The :mod:`ssl` module added a number of features to satisfy common requirements
999
+for secure (encrypted, authenticated) internet connections:
1001
-* A new function, :func:`ssl.match_hostname`, helps implement server identity
1002
- verification for higher-level protocols by implementing the rules of
1003
- HTTPS (from :rfc:`2818`), which are also suitable for other protocols.
1004
- (Added by Antoine Pitrou, :issue:`1589`).
1005
+* A new class, :class:`~ssl.SSLContext`, serves as a container for persistent
1006
+ SSL data, such as protocol settings, certificates, private keys, and various
1007
+ other options. It includes a :meth:`~ssl.SSLContext.wrap_socket` for creating
1008
+ an SSL socket from an SSL context.
1010
+* A new function, :func:`ssl.match_hostname`, supports server identity
1011
+ verification for higher-level protocols by implementing the rules of HTTPS
1012
+ (from :rfc:`2818`) which are also suitable for other protocols.
1014
* The :func:`ssl.wrap_socket` constructor function now takes a *ciphers*
1015
- argument that's a string listing the encryption algorithms to be allowed; the
1016
- format of the string is described `in the OpenSSL documentation
1017
- <http://www.openssl.org/docs/apps/ciphers.html#CIPHER_LIST_FORMAT>`__. (Added
1018
- by Antoine Pitrou; :issue:`8322`.)
1019
+ argument. The *ciphers* string lists the allowed encryption algorithms using
1020
+ the format described in the `OpenSSL documentation
1021
+ <http://www.openssl.org/docs/apps/ciphers.html#CIPHER_LIST_FORMAT>`__.
1023
-* When linked against a recent enough version of OpenSSL, the :mod:`ssl`
1024
- module now supports the Server Name Indication extension to the TLS
1025
- protocol, allowing for several "virtual hosts" using different certificates
1026
- on a single IP/port. This extension is only supported in client mode,
1027
- and is activated by passing the *server_hostname* argument to
1028
- :meth:`SSLContext.wrap_socket`.
1029
- (Added by Antoine Pitrou, :issue:`5639`.)
1030
+* When linked against recent versions of OpenSSL, the :mod:`ssl` module now
1031
+ supports the Server Name Indication extension to the TLS protocol, allowing
1032
+ multiple "virtual hosts" using different certificates on a single IP port.
1033
+ This extension is only supported in client mode, and is activated by passing
1034
+ the *server_hostname* argument to :meth:`ssl.SSLContext.wrap_socket`.
1036
* Various options have been added to the :mod:`ssl` module, such as
1037
- :data:`~ssl.OP_NO_SSLv2` which allows to force disabling of the insecure and
1038
- obsolete SSLv2 protocol. (Added by Antoine Pitrou; :issue:`4870`.)
1039
+ :data:`~ssl.OP_NO_SSLv2` which disables the insecure and obsolete SSLv2
1042
-* Another change makes the extension load all of OpenSSL's ciphers and digest
1043
- algorithms so that they're all available. Some SSL certificates couldn't be
1044
- verified, reporting an "unknown algorithm" error. (Reported by Beda Kosata,
1045
- and fixed by Antoine Pitrou; :issue:`8484`.)
1046
+* The extension now loads all the OpenSSL ciphers and digest algorithms. If
1047
+ some SSL certificates cannot be verified, they are reported as an "unknown
1050
-* The version of OpenSSL being used is now available as the module attributes
1051
- :data:`ssl.OPENSSL_VERSION` (a string), :data:`ssl.OPENSSL_VERSION_INFO` (a
1052
- 5-tuple), and :data:`ssl.OPENSSL_VERSION_NUMBER` (an integer). (Added by
1053
- Antoine Pitrou; :issue:`8321`.)
1054
+* The version of OpenSSL being used is now accessible using the module
1055
+ attributes :data:`ssl.OPENSSL_VERSION` (a string),
1056
+ :data:`ssl.OPENSSL_VERSION_INFO` (a 5-tuple), and
1057
+ :data:`ssl.OPENSSL_VERSION_NUMBER` (an integer).
1059
+(Contributed by Antoine Pitrou in :issue:`8850`, :issue:`1589`, :issue:`8322`,
1060
+:issue:`5639`, :issue:`4870`, :issue:`8484`, and :issue:`8321`.)
1065
@@ -1167,8 +1210,12 @@
1066
compatibility with the nntplib version in Python 3.1, which was partly
1067
dysfunctional in itself.
1069
-(Contributed by Antoine Pitrou in :issue:`9360`)
1070
+Support for secure connections through both implicit (using
1071
+:class:`nntplib.NNTP_SSL`) and explicit (using :meth:`nntplib.NNTP.starttls`)
1072
+TLS has also been added.
1074
+(Contributed by Antoine Pitrou in :issue:`9360` and Andrew Vant in :issue:`1926`.)
1079
@@ -1179,6 +1226,14 @@
1081
(Added by Antoine Pitrou, :issue:`9003`.)
1086
+Support for explicit TLS on standard IMAP4 connections has been added through
1087
+the new :mod:`imaplib.IMAP4.starttls` method.
1089
+(Contributed by Lorenzo M. Catucci and Antoine Pitrou, :issue:`4471`.)
1094
@@ -1190,7 +1245,7 @@
1095
* The command-line call ``python -m unittest`` can now accept file paths
1096
instead of module names for running specific tests (:issue:`10620`). The new
1097
test discovery can find tests within packages, locating any test importable
1098
- from the top level directory. The top level directory can be specified with
1099
+ from the top-level directory. The top-level directory can be specified with
1100
the `-t` option, a pattern for matching files with ``-p``, and a directory to
1101
start discovery with ``-s``::
1103
@@ -1209,12 +1264,12 @@
1104
* The :mod:`unittest` module has two new methods,
1105
:meth:`~unittest.TestCase.assertWarns` and
1106
:meth:`~unittest.TestCase.assertWarnsRegex` to verify that a given warning type
1107
- is triggered by the code under test:
1108
+ is triggered by the code under test::
1110
- >>> with self.assertWarns(DeprecationWarning):
1111
- ... legacy_function('XYZ')
1112
+ with self.assertWarns(DeprecationWarning):
1113
+ legacy_function('XYZ')
1115
- (Contributed by Michael Foord and Ezio Melotti.)
1116
+ (Contributed by Antoine Pitrou, :issue:`9754`.)
1118
Another new method, :meth:`~unittest.TestCase.assertCountEqual` is used to
1119
compare two iterables to determine if their element counts are equal (whether
1120
@@ -1261,7 +1316,7 @@
1121
(Contributed by Ezio Melotti; :issue:`9424`.)
1123
* The :meth:`~unittest.TestCase.assertDictContainsSubset` method was deprecated
1124
- because it was mis-implemented with the arguments in the wrong order. This
1125
+ because it was misimplemented with the arguments in the wrong order. This
1126
created hard-to-debug optical illusions where tests like
1127
``TestCase().assertDictContainsSubset({'a':1, 'b':2}, {'a':1})`` would fail.
1129
@@ -1273,7 +1328,7 @@
1130
The integer methods in the :mod:`random` module now do a better job of producing
1131
uniform distributions. Previously, they computed selections with
1132
``int(n*random())`` which had a slight bias whenever *n* was not a power of two.
1133
-Now, multiple selections are made from a range upto the next power of two and a
1134
+Now, multiple selections are made from a range up to the next power of two and a
1135
selection is kept only when it falls within the range ``0 <= x < n``. The
1136
functions and methods affected are :func:`~random.randrange`,
1137
:func:`~random.randint`, :func:`~random.choice`, :func:`~random.shuffle` and
1138
@@ -1305,10 +1360,10 @@
1140
The :mod:`tempfile` module has a new context manager,
1141
:class:`~tempfile.TemporaryDirectory` which provides easy deterministic
1142
-cleanup of temporary directories:
1143
+cleanup of temporary directories::
1145
->>> with tempfile.TemporaryDirectory() as tmpdirname:
1146
-... print('created temporary dir:', tmpdirname)
1147
+ with tempfile.TemporaryDirectory() as tmpdirname:
1148
+ print('created temporary dir:', tmpdirname)
1150
(Contributed by Neil Schemenauer and Nick Coghlan; :issue:`5178`.)
1152
@@ -1323,13 +1378,13 @@
1154
* To support lookups without the possibility of activating a dynamic attribute,
1155
the :mod:`inspect` module has a new function, :func:`~inspect.getattr_static`.
1156
- Unlike, :func:`hasattr`, this is a true read-only search, guaranteed not to
1157
+ Unlike :func:`hasattr`, this is a true read-only search, guaranteed not to
1158
change state while it is searching. (Contributed by Michael Foord.)
1163
-The :mod:`pydoc` module now provides a much improved Web server interface,
1164
+The :mod:`pydoc` module now provides a much-improved Web server interface,
1165
as well as a new command-line option to automatically open a browser
1166
window to display that server.
1168
@@ -1428,55 +1483,62 @@
1170
Config parsers gained a new API based on the mapping protocol::
1172
- >>> parser = ConfigParser()
1173
- >>> parser.read_string("""
1175
- ... monty = python
1179
- ... full = metal jacket
1181
- >>> parser['phrases']['full']
1183
- >>> section = parser['phrases']
1184
- >>> section['the']
1186
- >>> section['british'] = '%(the)s %(full)s %(monty)s!'
1187
- >>> parser['phrases']['british']
1188
- 'who metal jacket python!'
1189
- >>> 'british' in section
1191
+ >>> parser = ConfigParser()
1192
+ >>> parser.read_string("""
1194
+ location = upper left
1199
-The new API is implemented on top of the classical API so custom parser
1207
+ >>> parser['main']['color']
1209
+ >>> parser['main']['editable']
1211
+ >>> section = parser['options']
1212
+ >>> section['title']
1214
+ >>> section['title'] = 'Options (editable: %(editable)s)'
1215
+ >>> section['title']
1216
+ 'Options (editable: no)'
1218
+The new API is implemented on top of the classical API, so custom parser
1219
subclasses should be able to use it without modifications.
1221
The INI file structure accepted by config parsers can now be customized. Users
1222
can specify alternative option/value delimiters and comment prefixes, change the
1223
-name of the *DEFAULT* section or switch the interpolation syntax. Along with
1224
-support for pluggable interpolation, an additional interpolation handler
1225
-:class:`~configparser.ExtendedInterpolation` was introduced::
1226
+name of the *DEFAULT* section or switch the interpolation syntax.
1228
+There is support for pluggable interpolation including an additional interpolation
1229
+handler :class:`~configparser.ExtendedInterpolation`::
1231
>>> parser = ConfigParser(interpolation=ExtendedInterpolation())
1232
>>> parser.read_dict({'buildout': {'directory': '/home/ambv/zope9'},
1233
- ... 'custom': {'prefix': '/usr/local'}})
1234
+ 'custom': {'prefix': '/usr/local'}})
1235
>>> parser.read_string("""
1241
- ... ${buildout:directory}/downloads/dist
1244
- ... recipe = plone.recipe.zope9install
1245
- ... location = /opt/zope
1248
- ... recipe = plone.recipe.zope9instance
1249
- ... zope9-location = ${zope9:location}
1250
- ... zope-conf = ${custom:prefix}/etc/zope.conf
1257
+ ${buildout:directory}/downloads/dist
1260
+ recipe = plone.recipe.zope9install
1261
+ location = /opt/zope
1264
+ recipe = plone.recipe.zope9instance
1265
+ zope9-location = ${zope9:location}
1266
+ zope-conf = ${custom:prefix}/etc/zope.conf
1268
>>> parser['buildout']['find-links']
1269
'\n/home/ambv/zope9/downloads/dist'
1270
>>> parser['instance']['zope-conf']
1271
@@ -1507,13 +1569,13 @@
1274
* The mechanism for serializing execution of concurrently running Python threads
1275
- (generally known as the GIL or Global Interpreter Lock) has been rewritten.
1276
- Among the objectives were more predictable switching intervals and reduced
1277
- overhead due to lock contention and the number of ensuing system calls. The
1278
- notion of a "check interval" to allow thread switches has been abandoned and
1279
- replaced by an absolute duration expressed in seconds. This parameter is
1280
- tunable through :func:`sys.setswitchinterval()`. It currently defaults to 5
1282
+ (generally known as the :term:`GIL` or :term:`Global Interpreter Lock`) has
1283
+ been rewritten. Among the objectives were more predictable switching
1284
+ intervals and reduced overhead due to lock contention and the number of
1285
+ ensuing system calls. The notion of a "check interval" to allow thread
1286
+ switches has been abandoned and replaced by an absolute duration expressed in
1287
+ seconds. This parameter is tunable through :func:`sys.setswitchinterval()`.
1288
+ It currently defaults to 5 milliseconds.
1290
Additional details about the implementation can be read from a `python-dev
1291
mailing-list message
1292
@@ -1524,13 +1586,14 @@
1293
(Contributed by Antoine Pitrou.)
1295
* Regular and recursive locks now accept an optional *timeout* argument to their
1296
- :meth:`acquire` method. (Contributed by Antoine Pitrou; :issue:`7316`.)
1297
+ :meth:`~threading.Lock.acquire` method. (Contributed by Antoine Pitrou;
1300
* Similarly, :meth:`threading.Semaphore.acquire` also gained a *timeout*
1301
argument. (Contributed by Torsten Landschoff; :issue:`850728`.)
1303
* Regular and recursive lock acquisitions can now be interrupted by signals on
1304
- platforms using pthreads. This means that Python programs that deadlock while
1305
+ platforms using Pthreads. This means that Python programs that deadlock while
1306
acquiring locks can be successfully killed by repeatedly sending SIGINT to the
1307
process (by pressing :kbd:`Ctrl+C` in most shells).
1308
(Contributed by Reid Kleckner; :issue:`8844`.)
1309
@@ -1553,7 +1616,7 @@
1310
if extension in {'xml', 'html', 'xhtml', 'css'}:
1313
- (Patch and additional tests by Dave Malcolm; :issue:`6690`).
1314
+ (Patch and additional tests contributed by Dave Malcolm; :issue:`6690`).
1316
* Serializing and unserializing data using the :mod:`pickle` module is now
1317
several times faster.
1318
@@ -1566,9 +1629,8 @@
1319
when called with a :term:`key function`. Previously, every element of
1320
a list was wrapped with a temporary object that remembered the key value
1321
associated with each element. Now, two arrays of keys and values are
1322
- sorted in parallel. This save the memory consumed by the sort wrappers,
1323
- and it saves time lost during comparisons which were delegated by the
1325
+ sorted in parallel. This saves the memory consumed by the sort wrappers,
1326
+ and it saves time lost to delegating comparisons.
1328
(Patch by Daniel Stutzbach in :issue:`9915`.)
1330
@@ -1638,11 +1700,11 @@
1331
:data:`os.environ`, :func:`os.getenvb` function and
1332
:data:`os.supports_bytes_environ` constant.
1334
-``'mbcs'`` encoding doesn't ignore the error handler argument any more. By
1335
+MBCS encoding doesn't ignore the error handler argument any more. By
1336
default (strict mode), it raises an UnicodeDecodeError on undecodable byte
1337
-sequence and UnicodeEncodeError on unencodable character. To get the ``'mbcs'``
1338
+sequence and UnicodeEncodeError on unencodable character. To get the MBCS
1339
encoding of Python 3.1, use ``'ignore'`` error handler to decode and
1340
-``'replace'`` error handler to encode. ``'mbcs'`` supports ``'strict'`` and
1341
+``'replace'`` error handler to encode. The MBCS codec supports ``'strict'`` and
1342
``'ignore'`` error handlers for decoding, and ``'strict'`` and ``'replace'``
1345
@@ -1754,7 +1816,7 @@
1346
detection of cases where the conversion won't fit (:issue:`7767`).
1348
* The :c:func:`PyUnicode_CompareWithASCIIString` now returns *not equal*
1349
- if the Python string in *NUL* terminated.
1350
+ if the Python string is *NUL* terminated.
1352
* There is a new function :c:func:`PyErr_NewExceptionWithDoc` that is
1353
like :c:func:`PyErr_NewException` but allows a docstring to be specified.
1354
@@ -1782,7 +1844,7 @@
1355
* The :mod:`configparser` module has a number of clean-ups. The major change is
1356
to replace the old :class:`ConfigParser` class with long-standing preferred
1357
alternative :class:`SafeConfigParser`. In addition there are a number of
1358
- smaller incompatibilites:
1359
+ smaller incompatibilities:
1361
* The interpolation syntax is now validated on
1362
:meth:`~configparser.ConfigParser.get` and
1363
@@ -1850,10 +1912,10 @@
1364
and it does a better job finalizing multiple context managers when one of them
1365
raises an exception::
1367
- >>> with open('mylog.txt') as infile, open('a.out', 'w') as outfile:
1368
- ... for line in infile:
1369
- ... if '<critical>' in line:
1370
- ... outfile.write(line)
1371
+ with open('mylog.txt') as infile, open('a.out', 'w') as outfile:
1372
+ for line in infile:
1373
+ if '<critical>' in line:
1374
+ outfile.write(line)
1376
(Contributed by Georg Brandl and Mattias Brändström;
1377
`appspot issue 53094 <http://codereview.appspot.com/53094>`_.)
1378
@@ -1875,3 +1937,26 @@
1380
* The new, longer :func:`str` value on floats may break doctests which rely on
1381
the old output format.
1383
+* In :class:`subprocess.Popen`, the default value for *close_fds* is now
1384
+ ``True`` under Unix; under Windows, it is ``True`` if the three standard
1385
+ streams are set to ``None``, ``False`` otherwise. Previously, *close_fds*
1386
+ was always ``False`` by default, which produced difficult to solve bugs
1387
+ or race conditions when open file descriptors would leak into the child
1390
+* Support for legacy HTTP 0.9 has been removed from :mod:`urllib.request`
1391
+ and :mod:`http.client`. Such support is still present on the server side
1392
+ (in :mod:`http.server`).
1394
+ (Contributed by Antoine Pitrou, :issue:`10711`.)
1396
+* SSL sockets in timeout mode now raise :exc:`socket.timeout` when a timeout
1397
+ occurs, rather than a generic :exc:`~ssl.SSLError`.
1399
+ (Contributed by Antoine Pitrou, :issue:`10272`.)
1401
+* The misleading functions :c:func:`PyEval_AcquireLock()` and
1402
+ :c:func:`PyEval_ReleaseLock()` have been officially deprecated. The
1403
+ thread-state aware APIs (such as :c:func:`PyEval_SaveThread()`
1404
+ and :c:func:`PyEval_RestoreThread()`) should be used instead.
1405
Index: Lib/threading.py
1406
===================================================================
1407
--- a/Lib/threading.py
1408
+++ b/Lib/threading.py
1412
# Debug support (adapted from ihooks.py).
1413
-# All the major classes here derive from _Verbose. We force that to
1414
-# be a new-style class so that all the major classes here are new-style.
1415
-# This helps debugging (type(instance) is more revealing for instances
1416
-# of new-style classes).
1420
Index: Lib/test/test_getargs2.py
1421
===================================================================
1422
--- a/Lib/test/test_getargs2.py
1423
+++ b/Lib/test/test_getargs2.py
1424
@@ -381,8 +381,10 @@
1425
self.assertRaises(TypeError, getargs_w_star, 'abc\xe9')
1426
self.assertRaises(TypeError, getargs_w_star, b'bytes')
1427
self.assertRaises(TypeError, getargs_w_star, b'nul:\0')
1428
+ self.assertRaises(TypeError, getargs_w_star, memoryview(b'bytes'))
1429
self.assertEqual(getargs_w_star(bytearray(b'bytearray')), b'[ytearra]')
1430
- self.assertEqual(getargs_w_star(memoryview(b'memoryview')), b'[emoryvie]')
1431
+ self.assertEqual(getargs_w_star(memoryview(bytearray(b'memoryview'))),
1433
self.assertRaises(TypeError, getargs_w_star, None)
1436
Index: Lib/test/test_memoryview.py
1437
===================================================================
1438
--- a/Lib/test/test_memoryview.py
1439
+++ b/Lib/test/test_memoryview.py
1447
class AbstractMemoryTests:
1448
@@ -271,6 +272,17 @@
1450
self._check_released(m, tp)
1452
+ def test_writable_readonly(self):
1453
+ # Issue #10451: memoryview incorrectly exposes a readonly
1454
+ # buffer as writable causing a segfault if using mmap
1458
+ b = tp(self._source)
1460
+ i = io.BytesIO(b'ZZZZ')
1461
+ self.assertRaises(TypeError, i.readinto, m)
1463
# Variations on source objects for the buffer: bytes-like objects, then arrays
1464
# with itemsize > 1.
1465
# NOTE: support for multi-dimensional objects is unimplemented.