2265 lines
270 KiB
HTML
2265 lines
270 KiB
HTML
|
||
<!DOCTYPE html>
|
||
|
||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||
<head>
|
||
<meta charset="utf-8" />
|
||
<title>What’s New In Python 3.6 — Python 3.7.4 documentation</title>
|
||
<link rel="stylesheet" href="../_static/pydoctheme.css" type="text/css" />
|
||
<link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
|
||
|
||
<script type="text/javascript" id="documentation_options" data-url_root="../" src="../_static/documentation_options.js"></script>
|
||
<script type="text/javascript" src="../_static/jquery.js"></script>
|
||
<script type="text/javascript" src="../_static/underscore.js"></script>
|
||
<script type="text/javascript" src="../_static/doctools.js"></script>
|
||
<script type="text/javascript" src="../_static/language_data.js"></script>
|
||
|
||
<script type="text/javascript" src="../_static/sidebar.js"></script>
|
||
|
||
<link rel="search" type="application/opensearchdescription+xml"
|
||
title="Search within Python 3.7.4 documentation"
|
||
href="../_static/opensearch.xml"/>
|
||
<link rel="author" title="About these documents" href="../about.html" />
|
||
<link rel="index" title="Index" href="../genindex.html" />
|
||
<link rel="search" title="Search" href="../search.html" />
|
||
<link rel="copyright" title="Copyright" href="../copyright.html" />
|
||
<link rel="next" title="What’s New In Python 3.5" href="3.5.html" />
|
||
<link rel="prev" title="What’s New In Python 3.7" href="3.7.html" />
|
||
<link rel="shortcut icon" type="image/png" href="../_static/py.png" />
|
||
<link rel="canonical" href="https://docs.python.org/3/whatsnew/3.6.html" />
|
||
|
||
<script type="text/javascript" src="../_static/copybutton.js"></script>
|
||
<script type="text/javascript" src="../_static/switchers.js"></script>
|
||
|
||
|
||
|
||
<style>
|
||
@media only screen {
|
||
table.full-width-table {
|
||
width: 100%;
|
||
}
|
||
}
|
||
</style>
|
||
|
||
|
||
</head><body>
|
||
|
||
<div class="related" role="navigation" aria-label="related navigation">
|
||
<h3>Navigation</h3>
|
||
<ul>
|
||
<li class="right" style="margin-right: 10px">
|
||
<a href="../genindex.html" title="General Index"
|
||
accesskey="I">index</a></li>
|
||
<li class="right" >
|
||
<a href="../py-modindex.html" title="Python Module Index"
|
||
>modules</a> |</li>
|
||
<li class="right" >
|
||
<a href="3.5.html" title="What’s New In Python 3.5"
|
||
accesskey="N">next</a> |</li>
|
||
<li class="right" >
|
||
<a href="3.7.html" title="What’s New In Python 3.7"
|
||
accesskey="P">previous</a> |</li>
|
||
<li><img src="../_static/py.png" alt=""
|
||
style="vertical-align: middle; margin-top: -1px"/></li>
|
||
<li><a href="https://www.python.org/">Python</a> »</li>
|
||
<li>
|
||
<span class="language_switcher_placeholder">en</span>
|
||
<span class="version_switcher_placeholder">3.7.4</span>
|
||
<a href="../index.html">Documentation </a> »
|
||
</li>
|
||
|
||
<li class="nav-item nav-item-1"><a href="index.html" accesskey="U">What’s New in Python</a> »</li>
|
||
<li class="right">
|
||
|
||
|
||
<div class="inline-search" style="display: none" role="search">
|
||
<form class="inline-search" action="../search.html" method="get">
|
||
<input placeholder="Quick search" type="text" name="q" />
|
||
<input type="submit" value="Go" />
|
||
<input type="hidden" name="check_keywords" value="yes" />
|
||
<input type="hidden" name="area" value="default" />
|
||
</form>
|
||
</div>
|
||
<script type="text/javascript">$('.inline-search').show(0);</script>
|
||
|
|
||
</li>
|
||
|
||
</ul>
|
||
</div>
|
||
|
||
<div class="document">
|
||
<div class="documentwrapper">
|
||
<div class="bodywrapper">
|
||
<div class="body" role="main">
|
||
|
||
<div class="section" id="what-s-new-in-python-3-6">
|
||
<h1>What’s New In Python 3.6<a class="headerlink" href="#what-s-new-in-python-3-6" title="Permalink to this headline">¶</a></h1>
|
||
<dl class="field-list simple">
|
||
<dt class="field-odd">Editors</dt>
|
||
<dd class="field-odd"><p>Elvis Pranskevichus <<a class="reference external" href="mailto:elvis%40magic.io">elvis<span>@</span>magic<span>.</span>io</a>>, Yury Selivanov <<a class="reference external" href="mailto:yury%40magic.io">yury<span>@</span>magic<span>.</span>io</a>></p>
|
||
</dd>
|
||
</dl>
|
||
<p>This article explains the new features in Python 3.6, compared to 3.5.
|
||
Python 3.6 was released on December 23, 2016. See the
|
||
<a class="reference external" href="https://docs.python.org/3.6/whatsnew/changelog.html">changelog</a> for a full
|
||
list of changes.</p>
|
||
<div class="admonition seealso">
|
||
<p class="admonition-title">See also</p>
|
||
<p><span class="target" id="index-0"></span><a class="pep reference external" href="https://www.python.org/dev/peps/pep-0494"><strong>PEP 494</strong></a> - Python 3.6 Release Schedule</p>
|
||
</div>
|
||
<div class="section" id="summary-release-highlights">
|
||
<h2>Summary – Release highlights<a class="headerlink" href="#summary-release-highlights" title="Permalink to this headline">¶</a></h2>
|
||
<p>New syntax features:</p>
|
||
<ul class="simple">
|
||
<li><p><a class="reference internal" href="#whatsnew36-pep498"><span class="std std-ref">PEP 498</span></a>, formatted string literals.</p></li>
|
||
<li><p><a class="reference internal" href="#whatsnew36-pep515"><span class="std std-ref">PEP 515</span></a>, underscores in numeric literals.</p></li>
|
||
<li><p><a class="reference internal" href="#whatsnew36-pep526"><span class="std std-ref">PEP 526</span></a>, syntax for variable annotations.</p></li>
|
||
<li><p><a class="reference internal" href="#whatsnew36-pep525"><span class="std std-ref">PEP 525</span></a>, asynchronous generators.</p></li>
|
||
<li><p><a class="reference internal" href="#whatsnew36-pep530"><span class="std std-ref">PEP 530</span></a>: asynchronous comprehensions.</p></li>
|
||
</ul>
|
||
<p>New library modules:</p>
|
||
<ul class="simple">
|
||
<li><p><a class="reference internal" href="../library/secrets.html#module-secrets" title="secrets: Generate secure random numbers for managing secrets."><code class="xref py py-mod docutils literal notranslate"><span class="pre">secrets</span></code></a>: <a class="reference internal" href="#whatsnew36-pep506"><span class="std std-ref">PEP 506 – Adding A Secrets Module To The Standard Library</span></a>.</p></li>
|
||
</ul>
|
||
<p>CPython implementation improvements:</p>
|
||
<ul class="simple">
|
||
<li><p>The <a class="reference internal" href="../library/stdtypes.html#typesmapping"><span class="std std-ref">dict</span></a> type has been reimplemented to use
|
||
a <a class="reference internal" href="#whatsnew36-compactdict"><span class="std std-ref">more compact representation</span></a>
|
||
based on <a class="reference external" href="https://mail.python.org/pipermail/python-dev/2012-December/123028.html">a proposal by Raymond Hettinger</a>
|
||
and similar to the <a class="reference external" href="https://morepypy.blogspot.com/2015/01/faster-more-memory-efficient-and-more.html">PyPy dict implementation</a>. This resulted in dictionaries
|
||
using 20% to 25% less memory when compared to Python 3.5.</p></li>
|
||
<li><p>Customization of class creation has been simplified with the
|
||
<a class="reference internal" href="#whatsnew36-pep487"><span class="std std-ref">new protocol</span></a>.</p></li>
|
||
<li><p>The class attribute definition order is
|
||
<a class="reference internal" href="#whatsnew36-pep520"><span class="std std-ref">now preserved</span></a>.</p></li>
|
||
<li><p>The order of elements in <code class="docutils literal notranslate"><span class="pre">**kwargs</span></code> now
|
||
<a class="reference internal" href="#whatsnew36-pep468"><span class="std std-ref">corresponds to the order</span></a> in which keyword
|
||
arguments were passed to the function.</p></li>
|
||
<li><p>DTrace and SystemTap <a class="reference internal" href="#whatsnew36-tracing"><span class="std std-ref">probing support</span></a> has
|
||
been added.</p></li>
|
||
<li><p>The new <a class="reference internal" href="#whatsnew36-pythonmalloc"><span class="std std-ref">PYTHONMALLOC</span></a> environment variable
|
||
can now be used to debug the interpreter memory allocation and access
|
||
errors.</p></li>
|
||
</ul>
|
||
<p>Significant improvements in the standard library:</p>
|
||
<ul class="simple">
|
||
<li><p>The <a class="reference internal" href="../library/asyncio.html#module-asyncio" title="asyncio: Asynchronous I/O."><code class="xref py py-mod docutils literal notranslate"><span class="pre">asyncio</span></code></a> module has received new features, significant
|
||
usability and performance improvements, and a fair amount of bug fixes.
|
||
Starting with Python 3.6 the <code class="docutils literal notranslate"><span class="pre">asyncio</span></code> module is no longer provisional
|
||
and its API is considered stable.</p></li>
|
||
<li><p>A new <a class="reference internal" href="#whatsnew36-pep519"><span class="std std-ref">file system path protocol</span></a> has been
|
||
implemented to support <a class="reference internal" href="../glossary.html#term-path-like-object"><span class="xref std std-term">path-like objects</span></a>.
|
||
All standard library functions operating on paths have been updated to
|
||
work with the new protocol.</p></li>
|
||
<li><p>The <a class="reference internal" href="../library/datetime.html#module-datetime" title="datetime: Basic date and time types."><code class="xref py py-mod docutils literal notranslate"><span class="pre">datetime</span></code></a> module has gained support for
|
||
<a class="reference internal" href="#whatsnew36-pep495"><span class="std std-ref">Local Time Disambiguation</span></a>.</p></li>
|
||
<li><p>The <a class="reference internal" href="../library/typing.html#module-typing" title="typing: Support for type hints (see PEP 484)."><code class="xref py py-mod docutils literal notranslate"><span class="pre">typing</span></code></a> module received a number of
|
||
<a class="reference internal" href="#whatsnew36-typing"><span class="std std-ref">improvements</span></a>.</p></li>
|
||
<li><p>The <a class="reference internal" href="../library/tracemalloc.html#module-tracemalloc" title="tracemalloc: Trace memory allocations."><code class="xref py py-mod docutils literal notranslate"><span class="pre">tracemalloc</span></code></a> module has been significantly reworked
|
||
and is now used to provide better output for <a class="reference internal" href="../library/exceptions.html#ResourceWarning" title="ResourceWarning"><code class="xref py py-exc docutils literal notranslate"><span class="pre">ResourceWarning</span></code></a>
|
||
as well as provide better diagnostics for memory allocation errors.
|
||
See the <a class="reference internal" href="#whatsnew36-pythonmalloc"><span class="std std-ref">PYTHONMALLOC section</span></a> for more
|
||
information.</p></li>
|
||
</ul>
|
||
<p>Security improvements:</p>
|
||
<ul class="simple">
|
||
<li><p>The new <a class="reference internal" href="../library/secrets.html#module-secrets" title="secrets: Generate secure random numbers for managing secrets."><code class="xref py py-mod docutils literal notranslate"><span class="pre">secrets</span></code></a> module has been added to simplify the generation of
|
||
cryptographically strong pseudo-random numbers suitable for
|
||
managing secrets such as account authentication, tokens, and similar.</p></li>
|
||
<li><p>On Linux, <a class="reference internal" href="../library/os.html#os.urandom" title="os.urandom"><code class="xref py py-func docutils literal notranslate"><span class="pre">os.urandom()</span></code></a> now blocks until the system urandom entropy
|
||
pool is initialized to increase the security. See the <span class="target" id="index-1"></span><a class="pep reference external" href="https://www.python.org/dev/peps/pep-0524"><strong>PEP 524</strong></a> for the
|
||
rationale.</p></li>
|
||
<li><p>The <a class="reference internal" href="../library/hashlib.html#module-hashlib" title="hashlib: Secure hash and message digest algorithms."><code class="xref py py-mod docutils literal notranslate"><span class="pre">hashlib</span></code></a> and <a class="reference internal" href="../library/ssl.html#module-ssl" title="ssl: TLS/SSL wrapper for socket objects"><code class="xref py py-mod docutils literal notranslate"><span class="pre">ssl</span></code></a> modules now support OpenSSL 1.1.0.</p></li>
|
||
<li><p>The default settings and feature set of the <a class="reference internal" href="../library/ssl.html#module-ssl" title="ssl: TLS/SSL wrapper for socket objects"><code class="xref py py-mod docutils literal notranslate"><span class="pre">ssl</span></code></a> module have been
|
||
improved.</p></li>
|
||
<li><p>The <a class="reference internal" href="../library/hashlib.html#module-hashlib" title="hashlib: Secure hash and message digest algorithms."><code class="xref py py-mod docutils literal notranslate"><span class="pre">hashlib</span></code></a> module received support for the BLAKE2, SHA-3 and SHAKE
|
||
hash algorithms and the <a class="reference internal" href="../library/hashlib.html#hashlib.scrypt" title="hashlib.scrypt"><code class="xref py py-func docutils literal notranslate"><span class="pre">scrypt()</span></code></a> key derivation function.</p></li>
|
||
</ul>
|
||
<p>Windows improvements:</p>
|
||
<ul class="simple">
|
||
<li><p><a class="reference internal" href="#whatsnew36-pep528"><span class="std std-ref">PEP 528</span></a> and <a class="reference internal" href="#whatsnew36-pep529"><span class="std std-ref">PEP 529</span></a>,
|
||
Windows filesystem and console encoding changed to UTF-8.</p></li>
|
||
<li><p>The <code class="docutils literal notranslate"><span class="pre">py.exe</span></code> launcher, when used interactively, no longer prefers
|
||
Python 2 over Python 3 when the user doesn’t specify a version (via
|
||
command line arguments or a config file). Handling of shebang lines
|
||
remains unchanged - “python” refers to Python 2 in that case.</p></li>
|
||
<li><p><code class="docutils literal notranslate"><span class="pre">python.exe</span></code> and <code class="docutils literal notranslate"><span class="pre">pythonw.exe</span></code> have been marked as long-path aware,
|
||
which means that the 260 character path limit may no longer apply.
|
||
See <a class="reference internal" href="../using/windows.html#max-path"><span class="std std-ref">removing the MAX_PATH limitation</span></a> for details.</p></li>
|
||
<li><p>A <code class="docutils literal notranslate"><span class="pre">._pth</span></code> file can be added to force isolated mode and fully specify
|
||
all search paths to avoid registry and environment lookup. See
|
||
<a class="reference internal" href="../using/windows.html#finding-modules"><span class="std std-ref">the documentation</span></a> for more information.</p></li>
|
||
<li><p>A <code class="docutils literal notranslate"><span class="pre">python36.zip</span></code> file now works as a landmark to infer
|
||
<span class="target" id="index-2"></span><a class="reference internal" href="../using/cmdline.html#envvar-PYTHONHOME"><code class="xref std std-envvar docutils literal notranslate"><span class="pre">PYTHONHOME</span></code></a>. See <a class="reference internal" href="../using/windows.html#finding-modules"><span class="std std-ref">the documentation</span></a> for
|
||
more information.</p></li>
|
||
</ul>
|
||
</div>
|
||
<div class="section" id="new-features">
|
||
<h2>New Features<a class="headerlink" href="#new-features" title="Permalink to this headline">¶</a></h2>
|
||
<div class="section" id="pep-498-formatted-string-literals">
|
||
<span id="whatsnew36-pep498"></span><h3>PEP 498: Formatted string literals<a class="headerlink" href="#pep-498-formatted-string-literals" title="Permalink to this headline">¶</a></h3>
|
||
<p><span class="target" id="index-3"></span><a class="pep reference external" href="https://www.python.org/dev/peps/pep-0498"><strong>PEP 498</strong></a> introduces a new kind of string literals: <em>f-strings</em>, or
|
||
<a class="reference internal" href="../reference/lexical_analysis.html#f-strings"><span class="std std-ref">formatted string literals</span></a>.</p>
|
||
<p>Formatted string literals are prefixed with <code class="docutils literal notranslate"><span class="pre">'f'</span></code> and are similar to
|
||
the format strings accepted by <a class="reference internal" href="../library/stdtypes.html#str.format" title="str.format"><code class="xref py py-meth docutils literal notranslate"><span class="pre">str.format()</span></code></a>. They contain replacement
|
||
fields surrounded by curly braces. The replacement fields are expressions,
|
||
which are evaluated at run time, and then formatted using the
|
||
<a class="reference internal" href="../library/functions.html#format" title="format"><code class="xref py py-func docutils literal notranslate"><span class="pre">format()</span></code></a> protocol:</p>
|
||
<div class="highlight-python3 notranslate"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">name</span> <span class="o">=</span> <span class="s2">"Fred"</span>
|
||
<span class="gp">>>> </span><span class="n">f</span><span class="s2">"He said his name is </span><span class="si">{name}</span><span class="s2">."</span>
|
||
<span class="go">'He said his name is Fred.'</span>
|
||
<span class="gp">>>> </span><span class="n">width</span> <span class="o">=</span> <span class="mi">10</span>
|
||
<span class="gp">>>> </span><span class="n">precision</span> <span class="o">=</span> <span class="mi">4</span>
|
||
<span class="gp">>>> </span><span class="n">value</span> <span class="o">=</span> <span class="n">decimal</span><span class="o">.</span><span class="n">Decimal</span><span class="p">(</span><span class="s2">"12.34567"</span><span class="p">)</span>
|
||
<span class="gp">>>> </span><span class="n">f</span><span class="s2">"result: {value:</span><span class="si">{width}</span><span class="s2">.</span><span class="si">{precision}</span><span class="s2">}"</span> <span class="c1"># nested fields</span>
|
||
<span class="go">'result: 12.35'</span>
|
||
</pre></div>
|
||
</div>
|
||
<div class="admonition seealso">
|
||
<p class="admonition-title">See also</p>
|
||
<dl class="simple">
|
||
<dt><span class="target" id="index-4"></span><a class="pep reference external" href="https://www.python.org/dev/peps/pep-0498"><strong>PEP 498</strong></a> – Literal String Interpolation.</dt><dd><p>PEP written and implemented by Eric V. Smith.</p>
|
||
</dd>
|
||
</dl>
|
||
<p><a class="reference internal" href="../reference/lexical_analysis.html#f-strings"><span class="std std-ref">Feature documentation</span></a>.</p>
|
||
</div>
|
||
</div>
|
||
<div class="section" id="pep-526-syntax-for-variable-annotations">
|
||
<span id="whatsnew36-pep526"></span><h3>PEP 526: Syntax for variable annotations<a class="headerlink" href="#pep-526-syntax-for-variable-annotations" title="Permalink to this headline">¶</a></h3>
|
||
<p><span class="target" id="index-5"></span><a class="pep reference external" href="https://www.python.org/dev/peps/pep-0484"><strong>PEP 484</strong></a> introduced the standard for type annotations of function
|
||
parameters, a.k.a. type hints. This PEP adds syntax to Python for annotating
|
||
the types of variables including class variables and instance variables:</p>
|
||
<div class="highlight-python3 notranslate"><div class="highlight"><pre><span></span><span class="n">primes</span><span class="p">:</span> <span class="n">List</span><span class="p">[</span><span class="nb">int</span><span class="p">]</span> <span class="o">=</span> <span class="p">[]</span>
|
||
|
||
<span class="n">captain</span><span class="p">:</span> <span class="nb">str</span> <span class="c1"># Note: no initial value!</span>
|
||
|
||
<span class="k">class</span> <span class="nc">Starship</span><span class="p">:</span>
|
||
<span class="n">stats</span><span class="p">:</span> <span class="n">Dict</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="nb">int</span><span class="p">]</span> <span class="o">=</span> <span class="p">{}</span>
|
||
</pre></div>
|
||
</div>
|
||
<p>Just as for function annotations, the Python interpreter does not attach any
|
||
particular meaning to variable annotations and only stores them in the
|
||
<code class="docutils literal notranslate"><span class="pre">__annotations__</span></code> attribute of a class or module.</p>
|
||
<p>In contrast to variable declarations in statically typed languages,
|
||
the goal of annotation syntax is to provide an easy way to specify structured
|
||
type metadata for third party tools and libraries via the abstract syntax tree
|
||
and the <code class="docutils literal notranslate"><span class="pre">__annotations__</span></code> attribute.</p>
|
||
<div class="admonition seealso">
|
||
<p class="admonition-title">See also</p>
|
||
<dl class="simple">
|
||
<dt><span class="target" id="index-6"></span><a class="pep reference external" href="https://www.python.org/dev/peps/pep-0526"><strong>PEP 526</strong></a> – Syntax for variable annotations.</dt><dd><p>PEP written by Ryan Gonzalez, Philip House, Ivan Levkivskyi, Lisa Roach,
|
||
and Guido van Rossum. Implemented by Ivan Levkivskyi.</p>
|
||
</dd>
|
||
</dl>
|
||
<p>Tools that use or will use the new syntax:
|
||
<a class="reference external" href="http://www.mypy-lang.org/">mypy</a>,
|
||
<a class="reference external" href="https://github.com/google/pytype">pytype</a>, PyCharm, etc.</p>
|
||
</div>
|
||
</div>
|
||
<div class="section" id="pep-515-underscores-in-numeric-literals">
|
||
<span id="whatsnew36-pep515"></span><h3>PEP 515: Underscores in Numeric Literals<a class="headerlink" href="#pep-515-underscores-in-numeric-literals" title="Permalink to this headline">¶</a></h3>
|
||
<p><span class="target" id="index-7"></span><a class="pep reference external" href="https://www.python.org/dev/peps/pep-0515"><strong>PEP 515</strong></a> adds the ability to use underscores in numeric literals for
|
||
improved readability. For example:</p>
|
||
<div class="highlight-python3 notranslate"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="mi">1_000_000_000_000_000</span>
|
||
<span class="go">1000000000000000</span>
|
||
<span class="gp">>>> </span><span class="mh">0x_FF_FF_FF_FF</span>
|
||
<span class="go">4294967295</span>
|
||
</pre></div>
|
||
</div>
|
||
<p>Single underscores are allowed between digits and after any base
|
||
specifier. Leading, trailing, or multiple underscores in a row are not
|
||
allowed.</p>
|
||
<p>The <a class="reference internal" href="../library/string.html#formatspec"><span class="std std-ref">string formatting</span></a> language also now has support
|
||
for the <code class="docutils literal notranslate"><span class="pre">'_'</span></code> option to signal the use of an underscore for a thousands
|
||
separator for floating point presentation types and for integer
|
||
presentation type <code class="docutils literal notranslate"><span class="pre">'d'</span></code>. For integer presentation types <code class="docutils literal notranslate"><span class="pre">'b'</span></code>,
|
||
<code class="docutils literal notranslate"><span class="pre">'o'</span></code>, <code class="docutils literal notranslate"><span class="pre">'x'</span></code>, and <code class="docutils literal notranslate"><span class="pre">'X'</span></code>, underscores will be inserted every 4
|
||
digits:</p>
|
||
<div class="highlight-python3 notranslate"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="s1">'{:_}'</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="mi">1000000</span><span class="p">)</span>
|
||
<span class="go">'1_000_000'</span>
|
||
<span class="gp">>>> </span><span class="s1">'{:_x}'</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="mh">0xFFFFFFFF</span><span class="p">)</span>
|
||
<span class="go">'ffff_ffff'</span>
|
||
</pre></div>
|
||
</div>
|
||
<div class="admonition seealso">
|
||
<p class="admonition-title">See also</p>
|
||
<dl class="simple">
|
||
<dt><span class="target" id="index-8"></span><a class="pep reference external" href="https://www.python.org/dev/peps/pep-0515"><strong>PEP 515</strong></a> – Underscores in Numeric Literals</dt><dd><p>PEP written by Georg Brandl and Serhiy Storchaka.</p>
|
||
</dd>
|
||
</dl>
|
||
</div>
|
||
</div>
|
||
<div class="section" id="pep-525-asynchronous-generators">
|
||
<span id="whatsnew36-pep525"></span><h3>PEP 525: Asynchronous Generators<a class="headerlink" href="#pep-525-asynchronous-generators" title="Permalink to this headline">¶</a></h3>
|
||
<p><span class="target" id="index-9"></span><a class="pep reference external" href="https://www.python.org/dev/peps/pep-0492"><strong>PEP 492</strong></a> introduced support for native coroutines and <code class="docutils literal notranslate"><span class="pre">async</span></code> / <code class="docutils literal notranslate"><span class="pre">await</span></code>
|
||
syntax to Python 3.5. A notable limitation of the Python 3.5 implementation
|
||
is that it was not possible to use <code class="docutils literal notranslate"><span class="pre">await</span></code> and <code class="docutils literal notranslate"><span class="pre">yield</span></code> in the same
|
||
function body. In Python 3.6 this restriction has been lifted, making it
|
||
possible to define <em>asynchronous generators</em>:</p>
|
||
<div class="highlight-python3 notranslate"><div class="highlight"><pre><span></span><span class="k">async</span> <span class="k">def</span> <span class="nf">ticker</span><span class="p">(</span><span class="n">delay</span><span class="p">,</span> <span class="n">to</span><span class="p">):</span>
|
||
<span class="sd">"""Yield numbers from 0 to *to* every *delay* seconds."""</span>
|
||
<span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="n">to</span><span class="p">):</span>
|
||
<span class="k">yield</span> <span class="n">i</span>
|
||
<span class="k">await</span> <span class="n">asyncio</span><span class="o">.</span><span class="n">sleep</span><span class="p">(</span><span class="n">delay</span><span class="p">)</span>
|
||
</pre></div>
|
||
</div>
|
||
<p>The new syntax allows for faster and more concise code.</p>
|
||
<div class="admonition seealso">
|
||
<p class="admonition-title">See also</p>
|
||
<dl class="simple">
|
||
<dt><span class="target" id="index-10"></span><a class="pep reference external" href="https://www.python.org/dev/peps/pep-0525"><strong>PEP 525</strong></a> – Asynchronous Generators</dt><dd><p>PEP written and implemented by Yury Selivanov.</p>
|
||
</dd>
|
||
</dl>
|
||
</div>
|
||
</div>
|
||
<div class="section" id="pep-530-asynchronous-comprehensions">
|
||
<span id="whatsnew36-pep530"></span><h3>PEP 530: Asynchronous Comprehensions<a class="headerlink" href="#pep-530-asynchronous-comprehensions" title="Permalink to this headline">¶</a></h3>
|
||
<p><span class="target" id="index-11"></span><a class="pep reference external" href="https://www.python.org/dev/peps/pep-0530"><strong>PEP 530</strong></a> adds support for using <code class="docutils literal notranslate"><span class="pre">async</span> <span class="pre">for</span></code> in list, set, dict
|
||
comprehensions and generator expressions:</p>
|
||
<div class="highlight-python3 notranslate"><div class="highlight"><pre><span></span><span class="n">result</span> <span class="o">=</span> <span class="p">[</span><span class="n">i</span> <span class="k">async</span> <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="n">aiter</span><span class="p">()</span> <span class="k">if</span> <span class="n">i</span> <span class="o">%</span> <span class="mi">2</span><span class="p">]</span>
|
||
</pre></div>
|
||
</div>
|
||
<p>Additionally, <code class="docutils literal notranslate"><span class="pre">await</span></code> expressions are supported in all kinds
|
||
of comprehensions:</p>
|
||
<div class="highlight-python3 notranslate"><div class="highlight"><pre><span></span><span class="n">result</span> <span class="o">=</span> <span class="p">[</span><span class="k">await</span> <span class="n">fun</span><span class="p">()</span> <span class="k">for</span> <span class="n">fun</span> <span class="ow">in</span> <span class="n">funcs</span> <span class="k">if</span> <span class="k">await</span> <span class="n">condition</span><span class="p">()]</span>
|
||
</pre></div>
|
||
</div>
|
||
<div class="admonition seealso">
|
||
<p class="admonition-title">See also</p>
|
||
<dl class="simple">
|
||
<dt><span class="target" id="index-12"></span><a class="pep reference external" href="https://www.python.org/dev/peps/pep-0530"><strong>PEP 530</strong></a> – Asynchronous Comprehensions</dt><dd><p>PEP written and implemented by Yury Selivanov.</p>
|
||
</dd>
|
||
</dl>
|
||
</div>
|
||
</div>
|
||
<div class="section" id="pep-487-simpler-customization-of-class-creation">
|
||
<span id="whatsnew36-pep487"></span><h3>PEP 487: Simpler customization of class creation<a class="headerlink" href="#pep-487-simpler-customization-of-class-creation" title="Permalink to this headline">¶</a></h3>
|
||
<p>It is now possible to customize subclass creation without using a metaclass.
|
||
The new <code class="docutils literal notranslate"><span class="pre">__init_subclass__</span></code> classmethod will be called on the base class
|
||
whenever a new subclass is created:</p>
|
||
<div class="highlight-python3 notranslate"><div class="highlight"><pre><span></span><span class="k">class</span> <span class="nc">PluginBase</span><span class="p">:</span>
|
||
<span class="n">subclasses</span> <span class="o">=</span> <span class="p">[]</span>
|
||
|
||
<span class="k">def</span> <span class="nf">__init_subclass__</span><span class="p">(</span><span class="bp">cls</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
|
||
<span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">__init_subclass__</span><span class="p">(</span><span class="o">**</span><span class="n">kwargs</span><span class="p">)</span>
|
||
<span class="bp">cls</span><span class="o">.</span><span class="n">subclasses</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="bp">cls</span><span class="p">)</span>
|
||
|
||
<span class="k">class</span> <span class="nc">Plugin1</span><span class="p">(</span><span class="n">PluginBase</span><span class="p">):</span>
|
||
<span class="k">pass</span>
|
||
|
||
<span class="k">class</span> <span class="nc">Plugin2</span><span class="p">(</span><span class="n">PluginBase</span><span class="p">):</span>
|
||
<span class="k">pass</span>
|
||
</pre></div>
|
||
</div>
|
||
<p>In order to allow zero-argument <a class="reference internal" href="../library/functions.html#super" title="super"><code class="xref py py-func docutils literal notranslate"><span class="pre">super()</span></code></a> calls to work correctly from
|
||
<a class="reference internal" href="../reference/datamodel.html#object.__init_subclass__" title="object.__init_subclass__"><code class="xref py py-meth docutils literal notranslate"><span class="pre">__init_subclass__()</span></code></a> implementations, custom metaclasses must
|
||
ensure that the new <code class="docutils literal notranslate"><span class="pre">__classcell__</span></code> namespace entry is propagated to
|
||
<code class="docutils literal notranslate"><span class="pre">type.__new__</span></code> (as described in <a class="reference internal" href="../reference/datamodel.html#class-object-creation"><span class="std std-ref">Creating the class object</span></a>).</p>
|
||
<div class="admonition seealso">
|
||
<p class="admonition-title">See also</p>
|
||
<dl class="simple">
|
||
<dt><span class="target" id="index-13"></span><a class="pep reference external" href="https://www.python.org/dev/peps/pep-0487"><strong>PEP 487</strong></a> – Simpler customization of class creation</dt><dd><p>PEP written and implemented by Martin Teichmann.</p>
|
||
</dd>
|
||
</dl>
|
||
<p><a class="reference internal" href="../reference/datamodel.html#class-customization"><span class="std std-ref">Feature documentation</span></a></p>
|
||
</div>
|
||
</div>
|
||
<div class="section" id="pep-487-descriptor-protocol-enhancements">
|
||
<span id="whatsnew36-pep487-descriptors"></span><h3>PEP 487: Descriptor Protocol Enhancements<a class="headerlink" href="#pep-487-descriptor-protocol-enhancements" title="Permalink to this headline">¶</a></h3>
|
||
<p><span class="target" id="index-14"></span><a class="pep reference external" href="https://www.python.org/dev/peps/pep-0487"><strong>PEP 487</strong></a> extends the descriptor protocol to include the new optional
|
||
<a class="reference internal" href="../reference/datamodel.html#object.__set_name__" title="object.__set_name__"><code class="xref py py-meth docutils literal notranslate"><span class="pre">__set_name__()</span></code></a> method. Whenever a new class is defined, the new
|
||
method will be called on all descriptors included in the definition, providing
|
||
them with a reference to the class being defined and the name given to the
|
||
descriptor within the class namespace. In other words, instances of
|
||
descriptors can now know the attribute name of the descriptor in the
|
||
owner class:</p>
|
||
<div class="highlight-python3 notranslate"><div class="highlight"><pre><span></span><span class="k">class</span> <span class="nc">IntField</span><span class="p">:</span>
|
||
<span class="k">def</span> <span class="nf">__get__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">instance</span><span class="p">,</span> <span class="n">owner</span><span class="p">):</span>
|
||
<span class="k">return</span> <span class="n">instance</span><span class="o">.</span><span class="vm">__dict__</span><span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">name</span><span class="p">]</span>
|
||
|
||
<span class="k">def</span> <span class="nf">__set__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">instance</span><span class="p">,</span> <span class="n">value</span><span class="p">):</span>
|
||
<span class="k">if</span> <span class="ow">not</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">value</span><span class="p">,</span> <span class="nb">int</span><span class="p">):</span>
|
||
<span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="n">f</span><span class="s1">'expecting integer in </span><span class="si">{self.name}</span><span class="s1">'</span><span class="p">)</span>
|
||
<span class="n">instance</span><span class="o">.</span><span class="vm">__dict__</span><span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">name</span><span class="p">]</span> <span class="o">=</span> <span class="n">value</span>
|
||
|
||
<span class="c1"># this is the new initializer:</span>
|
||
<span class="k">def</span> <span class="nf">__set_name__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">owner</span><span class="p">,</span> <span class="n">name</span><span class="p">):</span>
|
||
<span class="bp">self</span><span class="o">.</span><span class="n">name</span> <span class="o">=</span> <span class="n">name</span>
|
||
|
||
<span class="k">class</span> <span class="nc">Model</span><span class="p">:</span>
|
||
<span class="n">int_field</span> <span class="o">=</span> <span class="n">IntField</span><span class="p">()</span>
|
||
</pre></div>
|
||
</div>
|
||
<div class="admonition seealso">
|
||
<p class="admonition-title">See also</p>
|
||
<dl class="simple">
|
||
<dt><span class="target" id="index-15"></span><a class="pep reference external" href="https://www.python.org/dev/peps/pep-0487"><strong>PEP 487</strong></a> – Simpler customization of class creation</dt><dd><p>PEP written and implemented by Martin Teichmann.</p>
|
||
</dd>
|
||
</dl>
|
||
<p><a class="reference internal" href="../reference/datamodel.html#descriptors"><span class="std std-ref">Feature documentation</span></a></p>
|
||
</div>
|
||
</div>
|
||
<div class="section" id="pep-519-adding-a-file-system-path-protocol">
|
||
<span id="whatsnew36-pep519"></span><h3>PEP 519: Adding a file system path protocol<a class="headerlink" href="#pep-519-adding-a-file-system-path-protocol" title="Permalink to this headline">¶</a></h3>
|
||
<p>File system paths have historically been represented as <a class="reference internal" href="../library/stdtypes.html#str" title="str"><code class="xref py py-class docutils literal notranslate"><span class="pre">str</span></code></a>
|
||
or <a class="reference internal" href="../library/stdtypes.html#bytes" title="bytes"><code class="xref py py-class docutils literal notranslate"><span class="pre">bytes</span></code></a> objects. This has led to people who write code which
|
||
operate on file system paths to assume that such objects are only one
|
||
of those two types (an <a class="reference internal" href="../library/functions.html#int" title="int"><code class="xref py py-class docutils literal notranslate"><span class="pre">int</span></code></a> representing a file descriptor
|
||
does not count as that is not a file path). Unfortunately that
|
||
assumption prevents alternative object representations of file system
|
||
paths like <a class="reference internal" href="../library/pathlib.html#module-pathlib" title="pathlib: Object-oriented filesystem paths"><code class="xref py py-mod docutils literal notranslate"><span class="pre">pathlib</span></code></a> from working with pre-existing code,
|
||
including Python’s standard library.</p>
|
||
<p>To fix this situation, a new interface represented by
|
||
<a class="reference internal" href="../library/os.html#os.PathLike" title="os.PathLike"><code class="xref py py-class docutils literal notranslate"><span class="pre">os.PathLike</span></code></a> has been defined. By implementing the
|
||
<a class="reference internal" href="../library/os.html#os.PathLike.__fspath__" title="os.PathLike.__fspath__"><code class="xref py py-meth docutils literal notranslate"><span class="pre">__fspath__()</span></code></a> method, an object signals that it
|
||
represents a path. An object can then provide a low-level
|
||
representation of a file system path as a <a class="reference internal" href="../library/stdtypes.html#str" title="str"><code class="xref py py-class docutils literal notranslate"><span class="pre">str</span></code></a> or
|
||
<a class="reference internal" href="../library/stdtypes.html#bytes" title="bytes"><code class="xref py py-class docutils literal notranslate"><span class="pre">bytes</span></code></a> object. This means an object is considered
|
||
<a class="reference internal" href="../glossary.html#term-path-like-object"><span class="xref std std-term">path-like</span></a> if it implements
|
||
<a class="reference internal" href="../library/os.html#os.PathLike" title="os.PathLike"><code class="xref py py-class docutils literal notranslate"><span class="pre">os.PathLike</span></code></a> or is a <a class="reference internal" href="../library/stdtypes.html#str" title="str"><code class="xref py py-class docutils literal notranslate"><span class="pre">str</span></code></a> or <a class="reference internal" href="../library/stdtypes.html#bytes" title="bytes"><code class="xref py py-class docutils literal notranslate"><span class="pre">bytes</span></code></a> object
|
||
which represents a file system path. Code can use <a class="reference internal" href="../library/os.html#os.fspath" title="os.fspath"><code class="xref py py-func docutils literal notranslate"><span class="pre">os.fspath()</span></code></a>,
|
||
<a class="reference internal" href="../library/os.html#os.fsdecode" title="os.fsdecode"><code class="xref py py-func docutils literal notranslate"><span class="pre">os.fsdecode()</span></code></a>, or <a class="reference internal" href="../library/os.html#os.fsencode" title="os.fsencode"><code class="xref py py-func docutils literal notranslate"><span class="pre">os.fsencode()</span></code></a> to explicitly get a
|
||
<a class="reference internal" href="../library/stdtypes.html#str" title="str"><code class="xref py py-class docutils literal notranslate"><span class="pre">str</span></code></a> and/or <a class="reference internal" href="../library/stdtypes.html#bytes" title="bytes"><code class="xref py py-class docutils literal notranslate"><span class="pre">bytes</span></code></a> representation of a path-like
|
||
object.</p>
|
||
<p>The built-in <a class="reference internal" href="../library/functions.html#open" title="open"><code class="xref py py-func docutils literal notranslate"><span class="pre">open()</span></code></a> function has been updated to accept
|
||
<a class="reference internal" href="../library/os.html#os.PathLike" title="os.PathLike"><code class="xref py py-class docutils literal notranslate"><span class="pre">os.PathLike</span></code></a> objects, as have all relevant functions in the
|
||
<a class="reference internal" href="../library/os.html#module-os" title="os: Miscellaneous operating system interfaces."><code class="xref py py-mod docutils literal notranslate"><span class="pre">os</span></code></a> and <a class="reference internal" href="../library/os.path.html#module-os.path" title="os.path: Operations on pathnames."><code class="xref py py-mod docutils literal notranslate"><span class="pre">os.path</span></code></a> modules, and most other functions and
|
||
classes in the standard library. The <a class="reference internal" href="../library/os.html#os.DirEntry" title="os.DirEntry"><code class="xref py py-class docutils literal notranslate"><span class="pre">os.DirEntry</span></code></a> class
|
||
and relevant classes in <a class="reference internal" href="../library/pathlib.html#module-pathlib" title="pathlib: Object-oriented filesystem paths"><code class="xref py py-mod docutils literal notranslate"><span class="pre">pathlib</span></code></a> have also been updated to
|
||
implement <a class="reference internal" href="../library/os.html#os.PathLike" title="os.PathLike"><code class="xref py py-class docutils literal notranslate"><span class="pre">os.PathLike</span></code></a>.</p>
|
||
<p>The hope is that updating the fundamental functions for operating
|
||
on file system paths will lead to third-party code to implicitly
|
||
support all <a class="reference internal" href="../glossary.html#term-path-like-object"><span class="xref std std-term">path-like objects</span></a> without any
|
||
code changes, or at least very minimal ones (e.g. calling
|
||
<a class="reference internal" href="../library/os.html#os.fspath" title="os.fspath"><code class="xref py py-func docutils literal notranslate"><span class="pre">os.fspath()</span></code></a> at the beginning of code before operating on a
|
||
path-like object).</p>
|
||
<p>Here are some examples of how the new interface allows for
|
||
<a class="reference internal" href="../library/pathlib.html#pathlib.Path" title="pathlib.Path"><code class="xref py py-class docutils literal notranslate"><span class="pre">pathlib.Path</span></code></a> to be used more easily and transparently with
|
||
pre-existing code:</p>
|
||
<div class="highlight-python3 notranslate"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="kn">import</span> <span class="nn">pathlib</span>
|
||
<span class="gp">>>> </span><span class="k">with</span> <span class="nb">open</span><span class="p">(</span><span class="n">pathlib</span><span class="o">.</span><span class="n">Path</span><span class="p">(</span><span class="s2">"README"</span><span class="p">))</span> <span class="k">as</span> <span class="n">f</span><span class="p">:</span>
|
||
<span class="gp">... </span> <span class="n">contents</span> <span class="o">=</span> <span class="n">f</span><span class="o">.</span><span class="n">read</span><span class="p">()</span>
|
||
<span class="gp">...</span>
|
||
<span class="gp">>>> </span><span class="kn">import</span> <span class="nn">os.path</span>
|
||
<span class="gp">>>> </span><span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">splitext</span><span class="p">(</span><span class="n">pathlib</span><span class="o">.</span><span class="n">Path</span><span class="p">(</span><span class="s2">"some_file.txt"</span><span class="p">))</span>
|
||
<span class="go">('some_file', '.txt')</span>
|
||
<span class="gp">>>> </span><span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="s2">"/a/b"</span><span class="p">,</span> <span class="n">pathlib</span><span class="o">.</span><span class="n">Path</span><span class="p">(</span><span class="s2">"c"</span><span class="p">))</span>
|
||
<span class="go">'/a/b/c'</span>
|
||
<span class="gp">>>> </span><span class="kn">import</span> <span class="nn">os</span>
|
||
<span class="gp">>>> </span><span class="n">os</span><span class="o">.</span><span class="n">fspath</span><span class="p">(</span><span class="n">pathlib</span><span class="o">.</span><span class="n">Path</span><span class="p">(</span><span class="s2">"some_file.txt"</span><span class="p">))</span>
|
||
<span class="go">'some_file.txt'</span>
|
||
</pre></div>
|
||
</div>
|
||
<p>(Implemented by Brett Cannon, Ethan Furman, Dusty Phillips, and Jelle Zijlstra.)</p>
|
||
<div class="admonition seealso">
|
||
<p class="admonition-title">See also</p>
|
||
<dl class="simple">
|
||
<dt><span class="target" id="index-16"></span><a class="pep reference external" href="https://www.python.org/dev/peps/pep-0519"><strong>PEP 519</strong></a> – Adding a file system path protocol</dt><dd><p>PEP written by Brett Cannon and Koos Zevenhoven.</p>
|
||
</dd>
|
||
</dl>
|
||
</div>
|
||
</div>
|
||
<div class="section" id="pep-495-local-time-disambiguation">
|
||
<span id="whatsnew36-pep495"></span><h3>PEP 495: Local Time Disambiguation<a class="headerlink" href="#pep-495-local-time-disambiguation" title="Permalink to this headline">¶</a></h3>
|
||
<p>In most world locations, there have been and will be times when local clocks
|
||
are moved back. In those times, intervals are introduced in which local
|
||
clocks show the same time twice in the same day. In these situations, the
|
||
information displayed on a local clock (or stored in a Python datetime
|
||
instance) is insufficient to identify a particular moment in time.</p>
|
||
<p><span class="target" id="index-17"></span><a class="pep reference external" href="https://www.python.org/dev/peps/pep-0495"><strong>PEP 495</strong></a> adds the new <em>fold</em> attribute to instances of
|
||
<a class="reference internal" href="../library/datetime.html#datetime.datetime" title="datetime.datetime"><code class="xref py py-class docutils literal notranslate"><span class="pre">datetime.datetime</span></code></a> and <a class="reference internal" href="../library/datetime.html#datetime.time" title="datetime.time"><code class="xref py py-class docutils literal notranslate"><span class="pre">datetime.time</span></code></a> classes to differentiate
|
||
between two moments in time for which local times are the same:</p>
|
||
<div class="highlight-python3 notranslate"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">u0</span> <span class="o">=</span> <span class="n">datetime</span><span class="p">(</span><span class="mi">2016</span><span class="p">,</span> <span class="mi">11</span><span class="p">,</span> <span class="mi">6</span><span class="p">,</span> <span class="mi">4</span><span class="p">,</span> <span class="n">tzinfo</span><span class="o">=</span><span class="n">timezone</span><span class="o">.</span><span class="n">utc</span><span class="p">)</span>
|
||
<span class="gp">>>> </span><span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="mi">4</span><span class="p">):</span>
|
||
<span class="gp">... </span> <span class="n">u</span> <span class="o">=</span> <span class="n">u0</span> <span class="o">+</span> <span class="n">i</span><span class="o">*</span><span class="n">HOUR</span>
|
||
<span class="gp">... </span> <span class="n">t</span> <span class="o">=</span> <span class="n">u</span><span class="o">.</span><span class="n">astimezone</span><span class="p">(</span><span class="n">Eastern</span><span class="p">)</span>
|
||
<span class="gp">... </span> <span class="nb">print</span><span class="p">(</span><span class="n">u</span><span class="o">.</span><span class="n">time</span><span class="p">(),</span> <span class="s1">'UTC ='</span><span class="p">,</span> <span class="n">t</span><span class="o">.</span><span class="n">time</span><span class="p">(),</span> <span class="n">t</span><span class="o">.</span><span class="n">tzname</span><span class="p">(),</span> <span class="n">t</span><span class="o">.</span><span class="n">fold</span><span class="p">)</span>
|
||
<span class="gp">...</span>
|
||
<span class="go">04:00:00 UTC = 00:00:00 EDT 0</span>
|
||
<span class="go">05:00:00 UTC = 01:00:00 EDT 0</span>
|
||
<span class="go">06:00:00 UTC = 01:00:00 EST 1</span>
|
||
<span class="go">07:00:00 UTC = 02:00:00 EST 0</span>
|
||
</pre></div>
|
||
</div>
|
||
<p>The values of the <a class="reference internal" href="../library/datetime.html#datetime.datetime.fold" title="datetime.datetime.fold"><code class="xref py py-attr docutils literal notranslate"><span class="pre">fold</span></code></a> attribute have the
|
||
value <code class="docutils literal notranslate"><span class="pre">0</span></code> for all instances except those that represent the second
|
||
(chronologically) moment in time in an ambiguous case.</p>
|
||
<div class="admonition seealso">
|
||
<p class="admonition-title">See also</p>
|
||
<dl class="simple">
|
||
<dt><span class="target" id="index-18"></span><a class="pep reference external" href="https://www.python.org/dev/peps/pep-0495"><strong>PEP 495</strong></a> – Local Time Disambiguation</dt><dd><p>PEP written by Alexander Belopolsky and Tim Peters, implementation
|
||
by Alexander Belopolsky.</p>
|
||
</dd>
|
||
</dl>
|
||
</div>
|
||
</div>
|
||
<div class="section" id="pep-529-change-windows-filesystem-encoding-to-utf-8">
|
||
<span id="whatsnew36-pep529"></span><h3>PEP 529: Change Windows filesystem encoding to UTF-8<a class="headerlink" href="#pep-529-change-windows-filesystem-encoding-to-utf-8" title="Permalink to this headline">¶</a></h3>
|
||
<p>Representing filesystem paths is best performed with str (Unicode) rather than
|
||
bytes. However, there are some situations where using bytes is sufficient and
|
||
correct.</p>
|
||
<p>Prior to Python 3.6, data loss could result when using bytes paths on Windows.
|
||
With this change, using bytes to represent paths is now supported on Windows,
|
||
provided those bytes are encoded with the encoding returned by
|
||
<a class="reference internal" href="../library/sys.html#sys.getfilesystemencoding" title="sys.getfilesystemencoding"><code class="xref py py-func docutils literal notranslate"><span class="pre">sys.getfilesystemencoding()</span></code></a>, which now defaults to <code class="docutils literal notranslate"><span class="pre">'utf-8'</span></code>.</p>
|
||
<p>Applications that do not use str to represent paths should use
|
||
<a class="reference internal" href="../library/os.html#os.fsencode" title="os.fsencode"><code class="xref py py-func docutils literal notranslate"><span class="pre">os.fsencode()</span></code></a> and <a class="reference internal" href="../library/os.html#os.fsdecode" title="os.fsdecode"><code class="xref py py-func docutils literal notranslate"><span class="pre">os.fsdecode()</span></code></a> to ensure their bytes are
|
||
correctly encoded. To revert to the previous behaviour, set
|
||
<span class="target" id="index-19"></span><a class="reference internal" href="../using/cmdline.html#envvar-PYTHONLEGACYWINDOWSFSENCODING"><code class="xref std std-envvar docutils literal notranslate"><span class="pre">PYTHONLEGACYWINDOWSFSENCODING</span></code></a> or call
|
||
<a class="reference internal" href="../library/sys.html#sys._enablelegacywindowsfsencoding" title="sys._enablelegacywindowsfsencoding"><code class="xref py py-func docutils literal notranslate"><span class="pre">sys._enablelegacywindowsfsencoding()</span></code></a>.</p>
|
||
<p>See <span class="target" id="index-20"></span><a class="pep reference external" href="https://www.python.org/dev/peps/pep-0529"><strong>PEP 529</strong></a> for more information and discussion of code modifications that
|
||
may be required.</p>
|
||
</div>
|
||
<div class="section" id="pep-528-change-windows-console-encoding-to-utf-8">
|
||
<span id="whatsnew36-pep528"></span><h3>PEP 528: Change Windows console encoding to UTF-8<a class="headerlink" href="#pep-528-change-windows-console-encoding-to-utf-8" title="Permalink to this headline">¶</a></h3>
|
||
<p>The default console on Windows will now accept all Unicode characters and
|
||
provide correctly read str objects to Python code. <code class="docutils literal notranslate"><span class="pre">sys.stdin</span></code>,
|
||
<code class="docutils literal notranslate"><span class="pre">sys.stdout</span></code> and <code class="docutils literal notranslate"><span class="pre">sys.stderr</span></code> now default to utf-8 encoding.</p>
|
||
<p>This change only applies when using an interactive console, and not when
|
||
redirecting files or pipes. To revert to the previous behaviour for interactive
|
||
console use, set <span class="target" id="index-21"></span><a class="reference internal" href="../using/cmdline.html#envvar-PYTHONLEGACYWINDOWSSTDIO"><code class="xref std std-envvar docutils literal notranslate"><span class="pre">PYTHONLEGACYWINDOWSSTDIO</span></code></a>.</p>
|
||
<div class="admonition seealso">
|
||
<p class="admonition-title">See also</p>
|
||
<dl class="simple">
|
||
<dt><span class="target" id="index-22"></span><a class="pep reference external" href="https://www.python.org/dev/peps/pep-0528"><strong>PEP 528</strong></a> – Change Windows console encoding to UTF-8</dt><dd><p>PEP written and implemented by Steve Dower.</p>
|
||
</dd>
|
||
</dl>
|
||
</div>
|
||
</div>
|
||
<div class="section" id="pep-520-preserving-class-attribute-definition-order">
|
||
<span id="whatsnew36-pep520"></span><h3>PEP 520: Preserving Class Attribute Definition Order<a class="headerlink" href="#pep-520-preserving-class-attribute-definition-order" title="Permalink to this headline">¶</a></h3>
|
||
<p>Attributes in a class definition body have a natural ordering: the same
|
||
order in which the names appear in the source. This order is now
|
||
preserved in the new class’s <a class="reference internal" href="../library/stdtypes.html#object.__dict__" title="object.__dict__"><code class="xref py py-attr docutils literal notranslate"><span class="pre">__dict__</span></code></a> attribute.</p>
|
||
<p>Also, the effective default class <em>execution</em> namespace (returned from
|
||
<a class="reference internal" href="../reference/datamodel.html#prepare"><span class="std std-ref">type.__prepare__()</span></a>) is now an insertion-order-preserving
|
||
mapping.</p>
|
||
<div class="admonition seealso">
|
||
<p class="admonition-title">See also</p>
|
||
<dl class="simple">
|
||
<dt><span class="target" id="index-23"></span><a class="pep reference external" href="https://www.python.org/dev/peps/pep-0520"><strong>PEP 520</strong></a> – Preserving Class Attribute Definition Order</dt><dd><p>PEP written and implemented by Eric Snow.</p>
|
||
</dd>
|
||
</dl>
|
||
</div>
|
||
</div>
|
||
<div class="section" id="pep-468-preserving-keyword-argument-order">
|
||
<span id="whatsnew36-pep468"></span><h3>PEP 468: Preserving Keyword Argument Order<a class="headerlink" href="#pep-468-preserving-keyword-argument-order" title="Permalink to this headline">¶</a></h3>
|
||
<p><code class="docutils literal notranslate"><span class="pre">**kwargs</span></code> in a function signature is now guaranteed to be an
|
||
insertion-order-preserving mapping.</p>
|
||
<div class="admonition seealso">
|
||
<p class="admonition-title">See also</p>
|
||
<dl class="simple">
|
||
<dt><span class="target" id="index-24"></span><a class="pep reference external" href="https://www.python.org/dev/peps/pep-0468"><strong>PEP 468</strong></a> – Preserving Keyword Argument Order</dt><dd><p>PEP written and implemented by Eric Snow.</p>
|
||
</dd>
|
||
</dl>
|
||
</div>
|
||
</div>
|
||
<div class="section" id="new-dict-implementation">
|
||
<span id="whatsnew36-compactdict"></span><h3>New <a class="reference internal" href="../library/stdtypes.html#typesmapping"><span class="std std-ref">dict</span></a> implementation<a class="headerlink" href="#new-dict-implementation" title="Permalink to this headline">¶</a></h3>
|
||
<p>The <a class="reference internal" href="../library/stdtypes.html#typesmapping"><span class="std std-ref">dict</span></a> type now uses a “compact” representation
|
||
based on <a class="reference external" href="https://mail.python.org/pipermail/python-dev/2012-December/123028.html">a proposal by Raymond Hettinger</a>
|
||
which was <a class="reference external" href="https://morepypy.blogspot.com/2015/01/faster-more-memory-efficient-and-more.html">first implemented by PyPy</a>.
|
||
The memory usage of the new <a class="reference internal" href="../library/stdtypes.html#dict" title="dict"><code class="xref py py-func docutils literal notranslate"><span class="pre">dict()</span></code></a> is between 20% and 25% smaller
|
||
compared to Python 3.5.</p>
|
||
<p>The order-preserving aspect of this new implementation is considered an
|
||
implementation detail and should not be relied upon (this may change in
|
||
the future, but it is desired to have this new dict implementation in
|
||
the language for a few releases before changing the language spec to mandate
|
||
order-preserving semantics for all current and future Python
|
||
implementations; this also helps preserve backwards-compatibility
|
||
with older versions of the language where random iteration order is
|
||
still in effect, e.g. Python 3.5).</p>
|
||
<p>(Contributed by INADA Naoki in <a class="reference external" href="https://bugs.python.org/issue27350">bpo-27350</a>. Idea
|
||
<a class="reference external" href="https://mail.python.org/pipermail/python-dev/2012-December/123028.html">originally suggested by Raymond Hettinger</a>.)</p>
|
||
</div>
|
||
<div class="section" id="pep-523-adding-a-frame-evaluation-api-to-cpython">
|
||
<span id="whatsnew36-pep523"></span><h3>PEP 523: Adding a frame evaluation API to CPython<a class="headerlink" href="#pep-523-adding-a-frame-evaluation-api-to-cpython" title="Permalink to this headline">¶</a></h3>
|
||
<p>While Python provides extensive support to customize how code
|
||
executes, one place it has not done so is in the evaluation of frame
|
||
objects. If you wanted some way to intercept frame evaluation in
|
||
Python there really wasn’t any way without directly manipulating
|
||
function pointers for defined functions.</p>
|
||
<p><span class="target" id="index-25"></span><a class="pep reference external" href="https://www.python.org/dev/peps/pep-0523"><strong>PEP 523</strong></a> changes this by providing an API to make frame
|
||
evaluation pluggable at the C level. This will allow for tools such
|
||
as debuggers and JITs to intercept frame evaluation before the
|
||
execution of Python code begins. This enables the use of alternative
|
||
evaluation implementations for Python code, tracking frame
|
||
evaluation, etc.</p>
|
||
<p>This API is not part of the limited C API and is marked as private to
|
||
signal that usage of this API is expected to be limited and only
|
||
applicable to very select, low-level use-cases. Semantics of the
|
||
API will change with Python as necessary.</p>
|
||
<div class="admonition seealso">
|
||
<p class="admonition-title">See also</p>
|
||
<dl class="simple">
|
||
<dt><span class="target" id="index-26"></span><a class="pep reference external" href="https://www.python.org/dev/peps/pep-0523"><strong>PEP 523</strong></a> – Adding a frame evaluation API to CPython</dt><dd><p>PEP written by Brett Cannon and Dino Viehland.</p>
|
||
</dd>
|
||
</dl>
|
||
</div>
|
||
</div>
|
||
<div class="section" id="pythonmalloc-environment-variable">
|
||
<span id="whatsnew36-pythonmalloc"></span><h3>PYTHONMALLOC environment variable<a class="headerlink" href="#pythonmalloc-environment-variable" title="Permalink to this headline">¶</a></h3>
|
||
<p>The new <span class="target" id="index-27"></span><a class="reference internal" href="../using/cmdline.html#envvar-PYTHONMALLOC"><code class="xref std std-envvar docutils literal notranslate"><span class="pre">PYTHONMALLOC</span></code></a> environment variable allows setting the Python
|
||
memory allocators and installing debug hooks.</p>
|
||
<p>It is now possible to install debug hooks on Python memory allocators on Python
|
||
compiled in release mode using <code class="docutils literal notranslate"><span class="pre">PYTHONMALLOC=debug</span></code>. Effects of debug hooks:</p>
|
||
<ul class="simple">
|
||
<li><p>Newly allocated memory is filled with the byte <code class="docutils literal notranslate"><span class="pre">0xCB</span></code></p></li>
|
||
<li><p>Freed memory is filled with the byte <code class="docutils literal notranslate"><span class="pre">0xDB</span></code></p></li>
|
||
<li><p>Detect violations of the Python memory allocator API. For example,
|
||
<a class="reference internal" href="../c-api/memory.html#c.PyObject_Free" title="PyObject_Free"><code class="xref c c-func docutils literal notranslate"><span class="pre">PyObject_Free()</span></code></a> called on a memory block allocated by
|
||
<a class="reference internal" href="../c-api/memory.html#c.PyMem_Malloc" title="PyMem_Malloc"><code class="xref c c-func docutils literal notranslate"><span class="pre">PyMem_Malloc()</span></code></a>.</p></li>
|
||
<li><p>Detect writes before the start of a buffer (buffer underflows)</p></li>
|
||
<li><p>Detect writes after the end of a buffer (buffer overflows)</p></li>
|
||
<li><p>Check that the <a class="reference internal" href="../glossary.html#term-global-interpreter-lock"><span class="xref std std-term">GIL</span></a> is held when allocator
|
||
functions of <a class="reference internal" href="../c-api/memory.html#c.PYMEM_DOMAIN_OBJ" title="PYMEM_DOMAIN_OBJ"><code class="xref c c-data docutils literal notranslate"><span class="pre">PYMEM_DOMAIN_OBJ</span></code></a> (ex: <a class="reference internal" href="../c-api/memory.html#c.PyObject_Malloc" title="PyObject_Malloc"><code class="xref c c-func docutils literal notranslate"><span class="pre">PyObject_Malloc()</span></code></a>) and
|
||
<a class="reference internal" href="../c-api/memory.html#c.PYMEM_DOMAIN_MEM" title="PYMEM_DOMAIN_MEM"><code class="xref c c-data docutils literal notranslate"><span class="pre">PYMEM_DOMAIN_MEM</span></code></a> (ex: <a class="reference internal" href="../c-api/memory.html#c.PyMem_Malloc" title="PyMem_Malloc"><code class="xref c c-func docutils literal notranslate"><span class="pre">PyMem_Malloc()</span></code></a>) domains are called.</p></li>
|
||
</ul>
|
||
<p>Checking if the GIL is held is also a new feature of Python 3.6.</p>
|
||
<p>See the <a class="reference internal" href="../c-api/memory.html#c.PyMem_SetupDebugHooks" title="PyMem_SetupDebugHooks"><code class="xref c c-func docutils literal notranslate"><span class="pre">PyMem_SetupDebugHooks()</span></code></a> function for debug hooks on Python
|
||
memory allocators.</p>
|
||
<p>It is now also possible to force the usage of the <code class="xref c c-func docutils literal notranslate"><span class="pre">malloc()</span></code> allocator of
|
||
the C library for all Python memory allocations using <code class="docutils literal notranslate"><span class="pre">PYTHONMALLOC=malloc</span></code>.
|
||
This is helpful when using external memory debuggers like Valgrind on
|
||
a Python compiled in release mode.</p>
|
||
<p>On error, the debug hooks on Python memory allocators now use the
|
||
<a class="reference internal" href="../library/tracemalloc.html#module-tracemalloc" title="tracemalloc: Trace memory allocations."><code class="xref py py-mod docutils literal notranslate"><span class="pre">tracemalloc</span></code></a> module to get the traceback where a memory block was
|
||
allocated.</p>
|
||
<p>Example of fatal error on buffer overflow using
|
||
<code class="docutils literal notranslate"><span class="pre">python3.6</span> <span class="pre">-X</span> <span class="pre">tracemalloc=5</span></code> (store 5 frames in traces):</p>
|
||
<div class="highlight-python3 notranslate"><div class="highlight"><pre><span></span><span class="n">Debug</span> <span class="n">memory</span> <span class="n">block</span> <span class="n">at</span> <span class="n">address</span> <span class="n">p</span><span class="o">=</span><span class="mh">0x7fbcd41666f8</span><span class="p">:</span> <span class="n">API</span> <span class="s1">'o'</span>
|
||
<span class="mi">4</span> <span class="nb">bytes</span> <span class="n">originally</span> <span class="n">requested</span>
|
||
<span class="n">The</span> <span class="mi">7</span> <span class="n">pad</span> <span class="nb">bytes</span> <span class="n">at</span> <span class="n">p</span><span class="o">-</span><span class="mi">7</span> <span class="n">are</span> <span class="n">FORBIDDENBYTE</span><span class="p">,</span> <span class="k">as</span> <span class="n">expected</span><span class="o">.</span>
|
||
<span class="n">The</span> <span class="mi">8</span> <span class="n">pad</span> <span class="nb">bytes</span> <span class="n">at</span> <span class="n">tail</span><span class="o">=</span><span class="mh">0x7fbcd41666fc</span> <span class="n">are</span> <span class="ow">not</span> <span class="nb">all</span> <span class="n">FORBIDDENBYTE</span> <span class="p">(</span><span class="mh">0xfb</span><span class="p">):</span>
|
||
<span class="n">at</span> <span class="n">tail</span><span class="o">+</span><span class="mi">0</span><span class="p">:</span> <span class="mh">0x02</span> <span class="o">***</span> <span class="n">OUCH</span>
|
||
<span class="n">at</span> <span class="n">tail</span><span class="o">+</span><span class="mi">1</span><span class="p">:</span> <span class="mh">0xfb</span>
|
||
<span class="n">at</span> <span class="n">tail</span><span class="o">+</span><span class="mi">2</span><span class="p">:</span> <span class="mh">0xfb</span>
|
||
<span class="n">at</span> <span class="n">tail</span><span class="o">+</span><span class="mi">3</span><span class="p">:</span> <span class="mh">0xfb</span>
|
||
<span class="n">at</span> <span class="n">tail</span><span class="o">+</span><span class="mi">4</span><span class="p">:</span> <span class="mh">0xfb</span>
|
||
<span class="n">at</span> <span class="n">tail</span><span class="o">+</span><span class="mi">5</span><span class="p">:</span> <span class="mh">0xfb</span>
|
||
<span class="n">at</span> <span class="n">tail</span><span class="o">+</span><span class="mi">6</span><span class="p">:</span> <span class="mh">0xfb</span>
|
||
<span class="n">at</span> <span class="n">tail</span><span class="o">+</span><span class="mi">7</span><span class="p">:</span> <span class="mh">0xfb</span>
|
||
<span class="n">The</span> <span class="n">block</span> <span class="n">was</span> <span class="n">made</span> <span class="n">by</span> <span class="n">call</span> <span class="c1">#1233329 to debug malloc/realloc.</span>
|
||
<span class="n">Data</span> <span class="n">at</span> <span class="n">p</span><span class="p">:</span> <span class="mi">1</span><span class="n">a</span> <span class="mi">2</span><span class="n">b</span> <span class="mi">30</span> <span class="mi">00</span>
|
||
|
||
<span class="n">Memory</span> <span class="n">block</span> <span class="n">allocated</span> <span class="n">at</span> <span class="p">(</span><span class="n">most</span> <span class="n">recent</span> <span class="n">call</span> <span class="n">first</span><span class="p">):</span>
|
||
<span class="n">File</span> <span class="s2">"test/test_bytes.py"</span><span class="p">,</span> <span class="n">line</span> <span class="mi">323</span>
|
||
<span class="n">File</span> <span class="s2">"unittest/case.py"</span><span class="p">,</span> <span class="n">line</span> <span class="mi">600</span>
|
||
<span class="n">File</span> <span class="s2">"unittest/case.py"</span><span class="p">,</span> <span class="n">line</span> <span class="mi">648</span>
|
||
<span class="n">File</span> <span class="s2">"unittest/suite.py"</span><span class="p">,</span> <span class="n">line</span> <span class="mi">122</span>
|
||
<span class="n">File</span> <span class="s2">"unittest/suite.py"</span><span class="p">,</span> <span class="n">line</span> <span class="mi">84</span>
|
||
|
||
<span class="n">Fatal</span> <span class="n">Python</span> <span class="n">error</span><span class="p">:</span> <span class="n">bad</span> <span class="n">trailing</span> <span class="n">pad</span> <span class="n">byte</span>
|
||
|
||
<span class="n">Current</span> <span class="n">thread</span> <span class="mh">0x00007fbcdbd32700</span> <span class="p">(</span><span class="n">most</span> <span class="n">recent</span> <span class="n">call</span> <span class="n">first</span><span class="p">):</span>
|
||
<span class="n">File</span> <span class="s2">"test/test_bytes.py"</span><span class="p">,</span> <span class="n">line</span> <span class="mi">323</span> <span class="ow">in</span> <span class="n">test_hex</span>
|
||
<span class="n">File</span> <span class="s2">"unittest/case.py"</span><span class="p">,</span> <span class="n">line</span> <span class="mi">600</span> <span class="ow">in</span> <span class="n">run</span>
|
||
<span class="n">File</span> <span class="s2">"unittest/case.py"</span><span class="p">,</span> <span class="n">line</span> <span class="mi">648</span> <span class="ow">in</span> <span class="fm">__call__</span>
|
||
<span class="n">File</span> <span class="s2">"unittest/suite.py"</span><span class="p">,</span> <span class="n">line</span> <span class="mi">122</span> <span class="ow">in</span> <span class="n">run</span>
|
||
<span class="n">File</span> <span class="s2">"unittest/suite.py"</span><span class="p">,</span> <span class="n">line</span> <span class="mi">84</span> <span class="ow">in</span> <span class="fm">__call__</span>
|
||
<span class="n">File</span> <span class="s2">"unittest/suite.py"</span><span class="p">,</span> <span class="n">line</span> <span class="mi">122</span> <span class="ow">in</span> <span class="n">run</span>
|
||
<span class="n">File</span> <span class="s2">"unittest/suite.py"</span><span class="p">,</span> <span class="n">line</span> <span class="mi">84</span> <span class="ow">in</span> <span class="fm">__call__</span>
|
||
<span class="o">...</span>
|
||
</pre></div>
|
||
</div>
|
||
<p>(Contributed by Victor Stinner in <a class="reference external" href="https://bugs.python.org/issue26516">bpo-26516</a> and <a class="reference external" href="https://bugs.python.org/issue26564">bpo-26564</a>.)</p>
|
||
</div>
|
||
<div class="section" id="dtrace-and-systemtap-probing-support">
|
||
<span id="whatsnew36-tracing"></span><h3>DTrace and SystemTap probing support<a class="headerlink" href="#dtrace-and-systemtap-probing-support" title="Permalink to this headline">¶</a></h3>
|
||
<p>Python can now be built <code class="docutils literal notranslate"><span class="pre">--with-dtrace</span></code> which enables static markers
|
||
for the following events in the interpreter:</p>
|
||
<ul class="simple">
|
||
<li><p>function call/return</p></li>
|
||
<li><p>garbage collection started/finished</p></li>
|
||
<li><p>line of code executed.</p></li>
|
||
</ul>
|
||
<p>This can be used to instrument running interpreters in production,
|
||
without the need to recompile specific debug builds or providing
|
||
application-specific profiling/debugging code.</p>
|
||
<p>More details in <a class="reference internal" href="../howto/instrumentation.html#instrumentation"><span class="std std-ref">Instrumenting CPython with DTrace and SystemTap</span></a>.</p>
|
||
<p>The current implementation is tested on Linux and macOS. Additional
|
||
markers may be added in the future.</p>
|
||
<p>(Contributed by Łukasz Langa in <a class="reference external" href="https://bugs.python.org/issue21590">bpo-21590</a>, based on patches by
|
||
Jesús Cea Avión, David Malcolm, and Nikhil Benesch.)</p>
|
||
</div>
|
||
</div>
|
||
<div class="section" id="other-language-changes">
|
||
<h2>Other Language Changes<a class="headerlink" href="#other-language-changes" title="Permalink to this headline">¶</a></h2>
|
||
<p>Some smaller changes made to the core Python language are:</p>
|
||
<ul class="simple">
|
||
<li><p>A <code class="docutils literal notranslate"><span class="pre">global</span></code> or <code class="docutils literal notranslate"><span class="pre">nonlocal</span></code> statement must now textually appear
|
||
before the first use of the affected name in the same scope.
|
||
Previously this was a <a class="reference internal" href="../library/exceptions.html#SyntaxWarning" title="SyntaxWarning"><code class="xref py py-exc docutils literal notranslate"><span class="pre">SyntaxWarning</span></code></a>.</p></li>
|
||
<li><p>It is now possible to set a <a class="reference internal" href="../reference/datamodel.html#specialnames"><span class="std std-ref">special method</span></a> to
|
||
<code class="docutils literal notranslate"><span class="pre">None</span></code> to indicate that the corresponding operation is not available.
|
||
For example, if a class sets <a class="reference internal" href="../reference/datamodel.html#object.__iter__" title="object.__iter__"><code class="xref py py-meth docutils literal notranslate"><span class="pre">__iter__()</span></code></a> to <code class="docutils literal notranslate"><span class="pre">None</span></code>, the class
|
||
is not iterable.
|
||
(Contributed by Andrew Barnert and Ivan Levkivskyi in <a class="reference external" href="https://bugs.python.org/issue25958">bpo-25958</a>.)</p></li>
|
||
<li><p>Long sequences of repeated traceback lines are now abbreviated as
|
||
<code class="docutils literal notranslate"><span class="pre">"[Previous</span> <span class="pre">line</span> <span class="pre">repeated</span> <span class="pre">{count}</span> <span class="pre">more</span> <span class="pre">times]"</span></code> (see
|
||
<a class="reference internal" href="#whatsnew36-traceback"><span class="std std-ref">traceback</span></a> for an example).
|
||
(Contributed by Emanuel Barry in <a class="reference external" href="https://bugs.python.org/issue26823">bpo-26823</a>.)</p></li>
|
||
<li><p>Import now raises the new exception <a class="reference internal" href="../library/exceptions.html#ModuleNotFoundError" title="ModuleNotFoundError"><code class="xref py py-exc docutils literal notranslate"><span class="pre">ModuleNotFoundError</span></code></a>
|
||
(subclass of <a class="reference internal" href="../library/exceptions.html#ImportError" title="ImportError"><code class="xref py py-exc docutils literal notranslate"><span class="pre">ImportError</span></code></a>) when it cannot find a module. Code
|
||
that currently checks for ImportError (in try-except) will still work.
|
||
(Contributed by Eric Snow in <a class="reference external" href="https://bugs.python.org/issue15767">bpo-15767</a>.)</p></li>
|
||
<li><p>Class methods relying on zero-argument <code class="docutils literal notranslate"><span class="pre">super()</span></code> will now work correctly
|
||
when called from metaclass methods during class creation.
|
||
(Contributed by Martin Teichmann in <a class="reference external" href="https://bugs.python.org/issue23722">bpo-23722</a>.)</p></li>
|
||
</ul>
|
||
</div>
|
||
<div class="section" id="new-modules">
|
||
<h2>New Modules<a class="headerlink" href="#new-modules" title="Permalink to this headline">¶</a></h2>
|
||
<div class="section" id="secrets">
|
||
<span id="whatsnew36-pep506"></span><h3>secrets<a class="headerlink" href="#secrets" title="Permalink to this headline">¶</a></h3>
|
||
<p>The main purpose of the new <a class="reference internal" href="../library/secrets.html#module-secrets" title="secrets: Generate secure random numbers for managing secrets."><code class="xref py py-mod docutils literal notranslate"><span class="pre">secrets</span></code></a> module is to provide an obvious way
|
||
to reliably generate cryptographically strong pseudo-random values suitable
|
||
for managing secrets, such as account authentication, tokens, and similar.</p>
|
||
<div class="admonition warning">
|
||
<p class="admonition-title">Warning</p>
|
||
<p>Note that the pseudo-random generators in the <a class="reference internal" href="../library/random.html#module-random" title="random: Generate pseudo-random numbers with various common distributions."><code class="xref py py-mod docutils literal notranslate"><span class="pre">random</span></code></a> module
|
||
should <em>NOT</em> be used for security purposes. Use <a class="reference internal" href="../library/secrets.html#module-secrets" title="secrets: Generate secure random numbers for managing secrets."><code class="xref py py-mod docutils literal notranslate"><span class="pre">secrets</span></code></a>
|
||
on Python 3.6+ and <a class="reference internal" href="../library/os.html#os.urandom" title="os.urandom"><code class="xref py py-func docutils literal notranslate"><span class="pre">os.urandom()</span></code></a> on Python 3.5 and earlier.</p>
|
||
</div>
|
||
<div class="admonition seealso">
|
||
<p class="admonition-title">See also</p>
|
||
<dl class="simple">
|
||
<dt><span class="target" id="index-28"></span><a class="pep reference external" href="https://www.python.org/dev/peps/pep-0506"><strong>PEP 506</strong></a> – Adding A Secrets Module To The Standard Library</dt><dd><p>PEP written and implemented by Steven D’Aprano.</p>
|
||
</dd>
|
||
</dl>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
<div class="section" id="improved-modules">
|
||
<h2>Improved Modules<a class="headerlink" href="#improved-modules" title="Permalink to this headline">¶</a></h2>
|
||
<div class="section" id="array">
|
||
<h3>array<a class="headerlink" href="#array" title="Permalink to this headline">¶</a></h3>
|
||
<p>Exhausted iterators of <a class="reference internal" href="../library/array.html#array.array" title="array.array"><code class="xref py py-class docutils literal notranslate"><span class="pre">array.array</span></code></a> will now stay exhausted even
|
||
if the iterated array is extended. This is consistent with the behavior
|
||
of other mutable sequences.</p>
|
||
<p>Contributed by Serhiy Storchaka in <a class="reference external" href="https://bugs.python.org/issue26492">bpo-26492</a>.</p>
|
||
</div>
|
||
<div class="section" id="ast">
|
||
<h3>ast<a class="headerlink" href="#ast" title="Permalink to this headline">¶</a></h3>
|
||
<p>The new <code class="xref py py-class docutils literal notranslate"><span class="pre">ast.Constant</span></code> AST node has been added. It can be used
|
||
by external AST optimizers for the purposes of constant folding.</p>
|
||
<p>Contributed by Victor Stinner in <a class="reference external" href="https://bugs.python.org/issue26146">bpo-26146</a>.</p>
|
||
</div>
|
||
<div class="section" id="asyncio">
|
||
<h3>asyncio<a class="headerlink" href="#asyncio" title="Permalink to this headline">¶</a></h3>
|
||
<p>Starting with Python 3.6 the <code class="docutils literal notranslate"><span class="pre">asyncio</span></code> module is no longer provisional and its
|
||
API is considered stable.</p>
|
||
<p>Notable changes in the <a class="reference internal" href="../library/asyncio.html#module-asyncio" title="asyncio: Asynchronous I/O."><code class="xref py py-mod docutils literal notranslate"><span class="pre">asyncio</span></code></a> module since Python 3.5.0
|
||
(all backported to 3.5.x due to the provisional status):</p>
|
||
<ul class="simple">
|
||
<li><p>The <a class="reference internal" href="../library/asyncio-eventloop.html#asyncio.get_event_loop" title="asyncio.get_event_loop"><code class="xref py py-func docutils literal notranslate"><span class="pre">get_event_loop()</span></code></a> function has been changed to
|
||
always return the currently running loop when called from coroutines
|
||
and callbacks.
|
||
(Contributed by Yury Selivanov in <a class="reference external" href="https://bugs.python.org/issue28613">bpo-28613</a>.)</p></li>
|
||
<li><p>The <a class="reference internal" href="../library/asyncio-future.html#asyncio.ensure_future" title="asyncio.ensure_future"><code class="xref py py-func docutils literal notranslate"><span class="pre">ensure_future()</span></code></a> function and all functions that
|
||
use it, such as <a class="reference internal" href="../library/asyncio-eventloop.html#asyncio.loop.run_until_complete" title="asyncio.loop.run_until_complete"><code class="xref py py-meth docutils literal notranslate"><span class="pre">loop.run_until_complete()</span></code></a>,
|
||
now accept all kinds of <a class="reference internal" href="../glossary.html#term-awaitable"><span class="xref std std-term">awaitable objects</span></a>.
|
||
(Contributed by Yury Selivanov.)</p></li>
|
||
<li><p>New <a class="reference internal" href="../library/asyncio-task.html#asyncio.run_coroutine_threadsafe" title="asyncio.run_coroutine_threadsafe"><code class="xref py py-func docutils literal notranslate"><span class="pre">run_coroutine_threadsafe()</span></code></a> function to submit
|
||
coroutines to event loops from other threads.
|
||
(Contributed by Vincent Michel.)</p></li>
|
||
<li><p>New <a class="reference internal" href="../library/asyncio-protocol.html#asyncio.BaseTransport.is_closing" title="asyncio.BaseTransport.is_closing"><code class="xref py py-meth docutils literal notranslate"><span class="pre">Transport.is_closing()</span></code></a>
|
||
method to check if the transport is closing or closed.
|
||
(Contributed by Yury Selivanov.)</p></li>
|
||
<li><p>The <a class="reference internal" href="../library/asyncio-eventloop.html#asyncio.loop.create_server" title="asyncio.loop.create_server"><code class="xref py py-meth docutils literal notranslate"><span class="pre">loop.create_server()</span></code></a>
|
||
method can now accept a list of hosts.
|
||
(Contributed by Yann Sionneau.)</p></li>
|
||
<li><p>New <a class="reference internal" href="../library/asyncio-eventloop.html#asyncio.loop.create_future" title="asyncio.loop.create_future"><code class="xref py py-meth docutils literal notranslate"><span class="pre">loop.create_future()</span></code></a>
|
||
method to create Future objects. This allows alternative event
|
||
loop implementations, such as
|
||
<a class="reference external" href="https://github.com/MagicStack/uvloop">uvloop</a>, to provide a faster
|
||
<a class="reference internal" href="../library/asyncio-future.html#asyncio.Future" title="asyncio.Future"><code class="xref py py-class docutils literal notranslate"><span class="pre">asyncio.Future</span></code></a> implementation.
|
||
(Contributed by Yury Selivanov in <a class="reference external" href="https://bugs.python.org/issue27041">bpo-27041</a>.)</p></li>
|
||
<li><p>New <a class="reference internal" href="../library/asyncio-eventloop.html#asyncio.loop.get_exception_handler" title="asyncio.loop.get_exception_handler"><code class="xref py py-meth docutils literal notranslate"><span class="pre">loop.get_exception_handler()</span></code></a>
|
||
method to get the current exception handler.
|
||
(Contributed by Yury Selivanov in <a class="reference external" href="https://bugs.python.org/issue27040">bpo-27040</a>.)</p></li>
|
||
<li><p>New <a class="reference internal" href="../library/asyncio-stream.html#asyncio.StreamReader.readuntil" title="asyncio.StreamReader.readuntil"><code class="xref py py-meth docutils literal notranslate"><span class="pre">StreamReader.readuntil()</span></code></a>
|
||
method to read data from the stream until a separator bytes
|
||
sequence appears.
|
||
(Contributed by Mark Korenberg.)</p></li>
|
||
<li><p>The performance of <a class="reference internal" href="../library/asyncio-stream.html#asyncio.StreamReader.readexactly" title="asyncio.StreamReader.readexactly"><code class="xref py py-meth docutils literal notranslate"><span class="pre">StreamReader.readexactly()</span></code></a>
|
||
has been improved.
|
||
(Contributed by Mark Korenberg in <a class="reference external" href="https://bugs.python.org/issue28370">bpo-28370</a>.)</p></li>
|
||
<li><p>The <a class="reference internal" href="../library/asyncio-eventloop.html#asyncio.loop.getaddrinfo" title="asyncio.loop.getaddrinfo"><code class="xref py py-meth docutils literal notranslate"><span class="pre">loop.getaddrinfo()</span></code></a>
|
||
method is optimized to avoid calling the system <code class="docutils literal notranslate"><span class="pre">getaddrinfo</span></code>
|
||
function if the address is already resolved.
|
||
(Contributed by A. Jesse Jiryu Davis.)</p></li>
|
||
<li><p>The <a class="reference internal" href="../library/asyncio-eventloop.html#asyncio.loop.stop" title="asyncio.loop.stop"><code class="xref py py-meth docutils literal notranslate"><span class="pre">loop.stop()</span></code></a>
|
||
method has been changed to stop the loop immediately after
|
||
the current iteration. Any new callbacks scheduled as a result
|
||
of the last iteration will be discarded.
|
||
(Contributed by Guido van Rossum in <a class="reference external" href="https://bugs.python.org/issue25593">bpo-25593</a>.)</p></li>
|
||
<li><p><code class="xref py py-meth docutils literal notranslate"><span class="pre">Future.set_exception</span></code>
|
||
will now raise <a class="reference internal" href="../library/exceptions.html#TypeError" title="TypeError"><code class="xref py py-exc docutils literal notranslate"><span class="pre">TypeError</span></code></a> when passed an instance of
|
||
the <a class="reference internal" href="../library/exceptions.html#StopIteration" title="StopIteration"><code class="xref py py-exc docutils literal notranslate"><span class="pre">StopIteration</span></code></a> exception.
|
||
(Contributed by Chris Angelico in <a class="reference external" href="https://bugs.python.org/issue26221">bpo-26221</a>.)</p></li>
|
||
<li><p>New <a class="reference internal" href="../library/asyncio-eventloop.html#asyncio.loop.connect_accepted_socket" title="asyncio.loop.connect_accepted_socket"><code class="xref py py-meth docutils literal notranslate"><span class="pre">loop.connect_accepted_socket()</span></code></a>
|
||
method to be used by servers that accept connections outside of asyncio,
|
||
but that use asyncio to handle them.
|
||
(Contributed by Jim Fulton in <a class="reference external" href="https://bugs.python.org/issue27392">bpo-27392</a>.)</p></li>
|
||
<li><p><code class="docutils literal notranslate"><span class="pre">TCP_NODELAY</span></code> flag is now set for all TCP transports by default.
|
||
(Contributed by Yury Selivanov in <a class="reference external" href="https://bugs.python.org/issue27456">bpo-27456</a>.)</p></li>
|
||
<li><p>New <a class="reference internal" href="../library/asyncio-eventloop.html#asyncio.loop.shutdown_asyncgens" title="asyncio.loop.shutdown_asyncgens"><code class="xref py py-meth docutils literal notranslate"><span class="pre">loop.shutdown_asyncgens()</span></code></a>
|
||
to properly close pending asynchronous generators before closing the
|
||
loop.
|
||
(Contributed by Yury Selivanov in <a class="reference external" href="https://bugs.python.org/issue28003">bpo-28003</a>.)</p></li>
|
||
<li><p><a class="reference internal" href="../library/asyncio-future.html#asyncio.Future" title="asyncio.Future"><code class="xref py py-class docutils literal notranslate"><span class="pre">Future</span></code></a> and <a class="reference internal" href="../library/asyncio-task.html#asyncio.Task" title="asyncio.Task"><code class="xref py py-class docutils literal notranslate"><span class="pre">Task</span></code></a>
|
||
classes now have an optimized C implementation which makes asyncio
|
||
code up to 30% faster.
|
||
(Contributed by Yury Selivanov and INADA Naoki in <a class="reference external" href="https://bugs.python.org/issue26081">bpo-26081</a>
|
||
and <a class="reference external" href="https://bugs.python.org/issue28544">bpo-28544</a>.)</p></li>
|
||
</ul>
|
||
</div>
|
||
<div class="section" id="binascii">
|
||
<h3>binascii<a class="headerlink" href="#binascii" title="Permalink to this headline">¶</a></h3>
|
||
<p>The <a class="reference internal" href="../library/binascii.html#binascii.b2a_base64" title="binascii.b2a_base64"><code class="xref py py-func docutils literal notranslate"><span class="pre">b2a_base64()</span></code></a> function now accepts an optional <em>newline</em>
|
||
keyword argument to control whether the newline character is appended to the
|
||
return value.
|
||
(Contributed by Victor Stinner in <a class="reference external" href="https://bugs.python.org/issue25357">bpo-25357</a>.)</p>
|
||
</div>
|
||
<div class="section" id="cmath">
|
||
<h3>cmath<a class="headerlink" href="#cmath" title="Permalink to this headline">¶</a></h3>
|
||
<p>The new <a class="reference internal" href="../library/cmath.html#cmath.tau" title="cmath.tau"><code class="xref py py-const docutils literal notranslate"><span class="pre">cmath.tau</span></code></a> (<em>τ</em>) constant has been added.
|
||
(Contributed by Lisa Roach in <a class="reference external" href="https://bugs.python.org/issue12345">bpo-12345</a>, see <span class="target" id="index-29"></span><a class="pep reference external" href="https://www.python.org/dev/peps/pep-0628"><strong>PEP 628</strong></a> for details.)</p>
|
||
<p>New constants: <a class="reference internal" href="../library/cmath.html#cmath.inf" title="cmath.inf"><code class="xref py py-const docutils literal notranslate"><span class="pre">cmath.inf</span></code></a> and <a class="reference internal" href="../library/cmath.html#cmath.nan" title="cmath.nan"><code class="xref py py-const docutils literal notranslate"><span class="pre">cmath.nan</span></code></a> to
|
||
match <a class="reference internal" href="../library/math.html#math.inf" title="math.inf"><code class="xref py py-const docutils literal notranslate"><span class="pre">math.inf</span></code></a> and <a class="reference internal" href="../library/math.html#math.nan" title="math.nan"><code class="xref py py-const docutils literal notranslate"><span class="pre">math.nan</span></code></a>, and also <a class="reference internal" href="../library/cmath.html#cmath.infj" title="cmath.infj"><code class="xref py py-const docutils literal notranslate"><span class="pre">cmath.infj</span></code></a>
|
||
and <a class="reference internal" href="../library/cmath.html#cmath.nanj" title="cmath.nanj"><code class="xref py py-const docutils literal notranslate"><span class="pre">cmath.nanj</span></code></a> to match the format used by complex repr.
|
||
(Contributed by Mark Dickinson in <a class="reference external" href="https://bugs.python.org/issue23229">bpo-23229</a>.)</p>
|
||
</div>
|
||
<div class="section" id="collections">
|
||
<h3>collections<a class="headerlink" href="#collections" title="Permalink to this headline">¶</a></h3>
|
||
<p>The new <a class="reference internal" href="../library/collections.abc.html#collections.abc.Collection" title="collections.abc.Collection"><code class="xref py py-class docutils literal notranslate"><span class="pre">Collection</span></code></a> abstract base class has been
|
||
added to represent sized iterable container classes.
|
||
(Contributed by Ivan Levkivskyi, docs by Neil Girdhar in <a class="reference external" href="https://bugs.python.org/issue27598">bpo-27598</a>.)</p>
|
||
<p>The new <a class="reference internal" href="../library/collections.abc.html#collections.abc.Reversible" title="collections.abc.Reversible"><code class="xref py py-class docutils literal notranslate"><span class="pre">Reversible</span></code></a> abstract base class represents
|
||
iterable classes that also provide the <a class="reference internal" href="../reference/datamodel.html#object.__reversed__" title="object.__reversed__"><code class="xref py py-meth docutils literal notranslate"><span class="pre">__reversed__()</span></code></a> method.
|
||
(Contributed by Ivan Levkivskyi in <a class="reference external" href="https://bugs.python.org/issue25987">bpo-25987</a>.)</p>
|
||
<p>The new <a class="reference internal" href="../library/collections.abc.html#collections.abc.AsyncGenerator" title="collections.abc.AsyncGenerator"><code class="xref py py-class docutils literal notranslate"><span class="pre">AsyncGenerator</span></code></a> abstract base class represents
|
||
asynchronous generators.
|
||
(Contributed by Yury Selivanov in <a class="reference external" href="https://bugs.python.org/issue28720">bpo-28720</a>.)</p>
|
||
<p>The <a class="reference internal" href="../library/collections.html#collections.namedtuple" title="collections.namedtuple"><code class="xref py py-func docutils literal notranslate"><span class="pre">namedtuple()</span></code></a> function now accepts an optional
|
||
keyword argument <em>module</em>, which, when specified, is used for
|
||
the <code class="docutils literal notranslate"><span class="pre">__module__</span></code> attribute of the returned named tuple class.
|
||
(Contributed by Raymond Hettinger in <a class="reference external" href="https://bugs.python.org/issue17941">bpo-17941</a>.)</p>
|
||
<p>The <em>verbose</em> and <em>rename</em> arguments for
|
||
<a class="reference internal" href="../library/collections.html#collections.namedtuple" title="collections.namedtuple"><code class="xref py py-func docutils literal notranslate"><span class="pre">namedtuple()</span></code></a> are now keyword-only.
|
||
(Contributed by Raymond Hettinger in <a class="reference external" href="https://bugs.python.org/issue25628">bpo-25628</a>.)</p>
|
||
<p>Recursive <a class="reference internal" href="../library/collections.html#collections.deque" title="collections.deque"><code class="xref py py-class docutils literal notranslate"><span class="pre">collections.deque</span></code></a> instances can now be pickled.
|
||
(Contributed by Serhiy Storchaka in <a class="reference external" href="https://bugs.python.org/issue26482">bpo-26482</a>.)</p>
|
||
</div>
|
||
<div class="section" id="concurrent-futures">
|
||
<h3>concurrent.futures<a class="headerlink" href="#concurrent-futures" title="Permalink to this headline">¶</a></h3>
|
||
<p>The <a class="reference internal" href="../library/concurrent.futures.html#concurrent.futures.ThreadPoolExecutor" title="concurrent.futures.ThreadPoolExecutor"><code class="xref py py-class docutils literal notranslate"><span class="pre">ThreadPoolExecutor</span></code></a>
|
||
class constructor now accepts an optional <em>thread_name_prefix</em> argument
|
||
to make it possible to customize the names of the threads created by the
|
||
pool.
|
||
(Contributed by Gregory P. Smith in <a class="reference external" href="https://bugs.python.org/issue27664">bpo-27664</a>.)</p>
|
||
</div>
|
||
<div class="section" id="contextlib">
|
||
<h3>contextlib<a class="headerlink" href="#contextlib" title="Permalink to this headline">¶</a></h3>
|
||
<p>The <a class="reference internal" href="../library/contextlib.html#contextlib.AbstractContextManager" title="contextlib.AbstractContextManager"><code class="xref py py-class docutils literal notranslate"><span class="pre">contextlib.AbstractContextManager</span></code></a> class has been added to
|
||
provide an abstract base class for context managers. It provides a
|
||
sensible default implementation for <cite>__enter__()</cite> which returns
|
||
<code class="docutils literal notranslate"><span class="pre">self</span></code> and leaves <cite>__exit__()</cite> an abstract method. A matching
|
||
class has been added to the <a class="reference internal" href="../library/typing.html#module-typing" title="typing: Support for type hints (see PEP 484)."><code class="xref py py-mod docutils literal notranslate"><span class="pre">typing</span></code></a> module as
|
||
<a class="reference internal" href="../library/typing.html#typing.ContextManager" title="typing.ContextManager"><code class="xref py py-class docutils literal notranslate"><span class="pre">typing.ContextManager</span></code></a>.
|
||
(Contributed by Brett Cannon in <a class="reference external" href="https://bugs.python.org/issue25609">bpo-25609</a>.)</p>
|
||
</div>
|
||
<div class="section" id="datetime">
|
||
<h3>datetime<a class="headerlink" href="#datetime" title="Permalink to this headline">¶</a></h3>
|
||
<p>The <a class="reference internal" href="../library/datetime.html#datetime.datetime" title="datetime.datetime"><code class="xref py py-class docutils literal notranslate"><span class="pre">datetime</span></code></a> and <a class="reference internal" href="../library/datetime.html#datetime.time" title="datetime.time"><code class="xref py py-class docutils literal notranslate"><span class="pre">time</span></code></a> classes have
|
||
the new <code class="xref py py-attr docutils literal notranslate"><span class="pre">fold</span></code> attribute used to disambiguate local time
|
||
when necessary. Many functions in the <a class="reference internal" href="../library/datetime.html#module-datetime" title="datetime: Basic date and time types."><code class="xref py py-mod docutils literal notranslate"><span class="pre">datetime</span></code></a> have been
|
||
updated to support local time disambiguation.
|
||
See <a class="reference internal" href="#whatsnew36-pep495"><span class="std std-ref">Local Time Disambiguation</span></a> section for more
|
||
information.
|
||
(Contributed by Alexander Belopolsky in <a class="reference external" href="https://bugs.python.org/issue24773">bpo-24773</a>.)</p>
|
||
<p>The <a class="reference internal" href="../library/datetime.html#datetime.datetime.strftime" title="datetime.datetime.strftime"><code class="xref py py-meth docutils literal notranslate"><span class="pre">datetime.strftime()</span></code></a> and
|
||
<a class="reference internal" href="../library/datetime.html#datetime.date.strftime" title="datetime.date.strftime"><code class="xref py py-meth docutils literal notranslate"><span class="pre">date.strftime()</span></code></a> methods now support
|
||
ISO 8601 date directives <code class="docutils literal notranslate"><span class="pre">%G</span></code>, <code class="docutils literal notranslate"><span class="pre">%u</span></code> and <code class="docutils literal notranslate"><span class="pre">%V</span></code>.
|
||
(Contributed by Ashley Anderson in <a class="reference external" href="https://bugs.python.org/issue12006">bpo-12006</a>.)</p>
|
||
<p>The <a class="reference internal" href="../library/datetime.html#datetime.datetime.isoformat" title="datetime.datetime.isoformat"><code class="xref py py-func docutils literal notranslate"><span class="pre">datetime.isoformat()</span></code></a> function
|
||
now accepts an optional <em>timespec</em> argument that specifies the number
|
||
of additional components of the time value to include.
|
||
(Contributed by Alessandro Cucci and Alexander Belopolsky in <a class="reference external" href="https://bugs.python.org/issue19475">bpo-19475</a>.)</p>
|
||
<p>The <a class="reference internal" href="../library/datetime.html#datetime.datetime.combine" title="datetime.datetime.combine"><code class="xref py py-meth docutils literal notranslate"><span class="pre">datetime.combine()</span></code></a> now
|
||
accepts an optional <em>tzinfo</em> argument.
|
||
(Contributed by Alexander Belopolsky in <a class="reference external" href="https://bugs.python.org/issue27661">bpo-27661</a>.)</p>
|
||
</div>
|
||
<div class="section" id="decimal">
|
||
<h3>decimal<a class="headerlink" href="#decimal" title="Permalink to this headline">¶</a></h3>
|
||
<p>New <a class="reference internal" href="../library/decimal.html#decimal.Decimal.as_integer_ratio" title="decimal.Decimal.as_integer_ratio"><code class="xref py py-meth docutils literal notranslate"><span class="pre">Decimal.as_integer_ratio()</span></code></a>
|
||
method that returns a pair <code class="docutils literal notranslate"><span class="pre">(n,</span> <span class="pre">d)</span></code> of integers that represent the given
|
||
<a class="reference internal" href="../library/decimal.html#decimal.Decimal" title="decimal.Decimal"><code class="xref py py-class docutils literal notranslate"><span class="pre">Decimal</span></code></a> instance as a fraction, in lowest terms and
|
||
with a positive denominator:</p>
|
||
<div class="highlight-python3 notranslate"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">Decimal</span><span class="p">(</span><span class="s1">'-3.14'</span><span class="p">)</span><span class="o">.</span><span class="n">as_integer_ratio</span><span class="p">()</span>
|
||
<span class="go">(-157, 50)</span>
|
||
</pre></div>
|
||
</div>
|
||
<p>(Contributed by Stefan Krah amd Mark Dickinson in <a class="reference external" href="https://bugs.python.org/issue25928">bpo-25928</a>.)</p>
|
||
</div>
|
||
<div class="section" id="distutils">
|
||
<h3>distutils<a class="headerlink" href="#distutils" title="Permalink to this headline">¶</a></h3>
|
||
<p>The <code class="docutils literal notranslate"><span class="pre">default_format</span></code> attribute has been removed from
|
||
<code class="xref py py-class docutils literal notranslate"><span class="pre">distutils.command.sdist.sdist</span></code> and the <code class="docutils literal notranslate"><span class="pre">formats</span></code>
|
||
attribute defaults to <code class="docutils literal notranslate"><span class="pre">['gztar']</span></code>. Although not anticipated,
|
||
any code relying on the presence of <code class="docutils literal notranslate"><span class="pre">default_format</span></code> may
|
||
need to be adapted. See <a class="reference external" href="https://bugs.python.org/issue27819">bpo-27819</a> for more details.</p>
|
||
</div>
|
||
<div class="section" id="email">
|
||
<h3>email<a class="headerlink" href="#email" title="Permalink to this headline">¶</a></h3>
|
||
<p>The new email API, enabled via the <em>policy</em> keyword to various constructors, is
|
||
no longer provisional. The <a class="reference internal" href="../library/email.html#module-email" title="email: Package supporting the parsing, manipulating, and generating email messages."><code class="xref py py-mod docutils literal notranslate"><span class="pre">email</span></code></a> documentation has been reorganized and
|
||
rewritten to focus on the new API, while retaining the old documentation for
|
||
the legacy API. (Contributed by R. David Murray in <a class="reference external" href="https://bugs.python.org/issue24277">bpo-24277</a>.)</p>
|
||
<p>The <a class="reference internal" href="../library/email.mime.html#module-email.mime" title="email.mime: Build MIME messages."><code class="xref py py-mod docutils literal notranslate"><span class="pre">email.mime</span></code></a> classes now all accept an optional <em>policy</em> keyword.
|
||
(Contributed by Berker Peksag in <a class="reference external" href="https://bugs.python.org/issue27331">bpo-27331</a>.)</p>
|
||
<p>The <a class="reference internal" href="../library/email.generator.html#email.generator.DecodedGenerator" title="email.generator.DecodedGenerator"><code class="xref py py-class docutils literal notranslate"><span class="pre">DecodedGenerator</span></code></a> now supports the <em>policy</em>
|
||
keyword.</p>
|
||
<p>There is a new <a class="reference internal" href="../library/email.policy.html#module-email.policy" title="email.policy: Controlling the parsing and generating of messages"><code class="xref py py-mod docutils literal notranslate"><span class="pre">policy</span></code></a> attribute,
|
||
<a class="reference internal" href="../library/email.policy.html#email.policy.Policy.message_factory" title="email.policy.Policy.message_factory"><code class="xref py py-attr docutils literal notranslate"><span class="pre">message_factory</span></code></a>, that controls what class is used
|
||
by default when the parser creates new message objects. For the
|
||
<a class="reference internal" href="../library/email.policy.html#email.policy.compat32" title="email.policy.compat32"><code class="xref py py-attr docutils literal notranslate"><span class="pre">email.policy.compat32</span></code></a> policy this is <a class="reference internal" href="../library/email.compat32-message.html#email.message.Message" title="email.message.Message"><code class="xref py py-class docutils literal notranslate"><span class="pre">Message</span></code></a>,
|
||
for the new policies it is <a class="reference internal" href="../library/email.message.html#email.message.EmailMessage" title="email.message.EmailMessage"><code class="xref py py-class docutils literal notranslate"><span class="pre">EmailMessage</span></code></a>.
|
||
(Contributed by R. David Murray in <a class="reference external" href="https://bugs.python.org/issue20476">bpo-20476</a>.)</p>
|
||
</div>
|
||
<div class="section" id="encodings">
|
||
<h3>encodings<a class="headerlink" href="#encodings" title="Permalink to this headline">¶</a></h3>
|
||
<p>On Windows, added the <code class="docutils literal notranslate"><span class="pre">'oem'</span></code> encoding to use <code class="docutils literal notranslate"><span class="pre">CP_OEMCP</span></code>, and the <code class="docutils literal notranslate"><span class="pre">'ansi'</span></code>
|
||
alias for the existing <code class="docutils literal notranslate"><span class="pre">'mbcs'</span></code> encoding, which uses the <code class="docutils literal notranslate"><span class="pre">CP_ACP</span></code> code page.
|
||
(Contributed by Steve Dower in <a class="reference external" href="https://bugs.python.org/issue27959">bpo-27959</a>.)</p>
|
||
</div>
|
||
<div class="section" id="enum">
|
||
<h3>enum<a class="headerlink" href="#enum" title="Permalink to this headline">¶</a></h3>
|
||
<p>Two new enumeration base classes have been added to the <a class="reference internal" href="../library/enum.html#module-enum" title="enum: Implementation of an enumeration class."><code class="xref py py-mod docutils literal notranslate"><span class="pre">enum</span></code></a> module:
|
||
<a class="reference internal" href="../library/enum.html#enum.Flag" title="enum.Flag"><code class="xref py py-class docutils literal notranslate"><span class="pre">Flag</span></code></a> and <code class="xref py py-class docutils literal notranslate"><span class="pre">IntFlags</span></code>. Both are used to define
|
||
constants that can be combined using the bitwise operators.
|
||
(Contributed by Ethan Furman in <a class="reference external" href="https://bugs.python.org/issue23591">bpo-23591</a>.)</p>
|
||
<p>Many standard library modules have been updated to use the
|
||
<code class="xref py py-class docutils literal notranslate"><span class="pre">IntFlags</span></code> class for their constants.</p>
|
||
<p>The new <a class="reference internal" href="../library/enum.html#enum.auto" title="enum.auto"><code class="xref py py-class docutils literal notranslate"><span class="pre">enum.auto</span></code></a> value can be used to assign values to enum
|
||
members automatically:</p>
|
||
<div class="highlight-python3 notranslate"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="kn">from</span> <span class="nn">enum</span> <span class="k">import</span> <span class="n">Enum</span><span class="p">,</span> <span class="n">auto</span>
|
||
<span class="gp">>>> </span><span class="k">class</span> <span class="nc">Color</span><span class="p">(</span><span class="n">Enum</span><span class="p">):</span>
|
||
<span class="gp">... </span> <span class="n">red</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span>
|
||
<span class="gp">... </span> <span class="n">blue</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span>
|
||
<span class="gp">... </span> <span class="n">green</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span>
|
||
<span class="gp">...</span>
|
||
<span class="gp">>>> </span><span class="nb">list</span><span class="p">(</span><span class="n">Color</span><span class="p">)</span>
|
||
<span class="go">[<Color.red: 1>, <Color.blue: 2>, <Color.green: 3>]</span>
|
||
</pre></div>
|
||
</div>
|
||
</div>
|
||
<div class="section" id="faulthandler">
|
||
<h3>faulthandler<a class="headerlink" href="#faulthandler" title="Permalink to this headline">¶</a></h3>
|
||
<p>On Windows, the <a class="reference internal" href="../library/faulthandler.html#module-faulthandler" title="faulthandler: Dump the Python traceback."><code class="xref py py-mod docutils literal notranslate"><span class="pre">faulthandler</span></code></a> module now installs a handler for Windows
|
||
exceptions: see <a class="reference internal" href="../library/faulthandler.html#faulthandler.enable" title="faulthandler.enable"><code class="xref py py-func docutils literal notranslate"><span class="pre">faulthandler.enable()</span></code></a>. (Contributed by Victor Stinner in
|
||
<a class="reference external" href="https://bugs.python.org/issue23848">bpo-23848</a>.)</p>
|
||
</div>
|
||
<div class="section" id="fileinput">
|
||
<h3>fileinput<a class="headerlink" href="#fileinput" title="Permalink to this headline">¶</a></h3>
|
||
<p><a class="reference internal" href="../library/fileinput.html#fileinput.hook_encoded" title="fileinput.hook_encoded"><code class="xref py py-func docutils literal notranslate"><span class="pre">hook_encoded()</span></code></a> now supports the <em>errors</em> argument.
|
||
(Contributed by Joseph Hackman in <a class="reference external" href="https://bugs.python.org/issue25788">bpo-25788</a>.)</p>
|
||
</div>
|
||
<div class="section" id="hashlib">
|
||
<h3>hashlib<a class="headerlink" href="#hashlib" title="Permalink to this headline">¶</a></h3>
|
||
<p><a class="reference internal" href="../library/hashlib.html#module-hashlib" title="hashlib: Secure hash and message digest algorithms."><code class="xref py py-mod docutils literal notranslate"><span class="pre">hashlib</span></code></a> supports OpenSSL 1.1.0. The minimum recommend version is 1.0.2.
|
||
(Contributed by Christian Heimes in <a class="reference external" href="https://bugs.python.org/issue26470">bpo-26470</a>.)</p>
|
||
<p>BLAKE2 hash functions were added to the module. <a class="reference internal" href="../library/hashlib.html#hashlib.blake2b" title="hashlib.blake2b"><code class="xref py py-func docutils literal notranslate"><span class="pre">blake2b()</span></code></a>
|
||
and <a class="reference internal" href="../library/hashlib.html#hashlib.blake2s" title="hashlib.blake2s"><code class="xref py py-func docutils literal notranslate"><span class="pre">blake2s()</span></code></a> are always available and support the full
|
||
feature set of BLAKE2.
|
||
(Contributed by Christian Heimes in <a class="reference external" href="https://bugs.python.org/issue26798">bpo-26798</a> based on code by
|
||
Dmitry Chestnykh and Samuel Neves. Documentation written by Dmitry Chestnykh.)</p>
|
||
<p>The SHA-3 hash functions <code class="xref py py-func docutils literal notranslate"><span class="pre">sha3_224()</span></code>, <code class="xref py py-func docutils literal notranslate"><span class="pre">sha3_256()</span></code>,
|
||
<code class="xref py py-func docutils literal notranslate"><span class="pre">sha3_384()</span></code>, <code class="xref py py-func docutils literal notranslate"><span class="pre">sha3_512()</span></code>, and SHAKE hash functions
|
||
<code class="xref py py-func docutils literal notranslate"><span class="pre">shake_128()</span></code> and <code class="xref py py-func docutils literal notranslate"><span class="pre">shake_256()</span></code> were added.
|
||
(Contributed by Christian Heimes in <a class="reference external" href="https://bugs.python.org/issue16113">bpo-16113</a>. Keccak Code Package
|
||
by Guido Bertoni, Joan Daemen, Michaël Peeters, Gilles Van Assche, and
|
||
Ronny Van Keer.)</p>
|
||
<p>The password-based key derivation function <a class="reference internal" href="../library/hashlib.html#hashlib.scrypt" title="hashlib.scrypt"><code class="xref py py-func docutils literal notranslate"><span class="pre">scrypt()</span></code></a> is now
|
||
available with OpenSSL 1.1.0 and newer.
|
||
(Contributed by Christian Heimes in <a class="reference external" href="https://bugs.python.org/issue27928">bpo-27928</a>.)</p>
|
||
</div>
|
||
<div class="section" id="http-client">
|
||
<h3>http.client<a class="headerlink" href="#http-client" title="Permalink to this headline">¶</a></h3>
|
||
<p><a class="reference internal" href="../library/http.client.html#http.client.HTTPConnection.request" title="http.client.HTTPConnection.request"><code class="xref py py-meth docutils literal notranslate"><span class="pre">HTTPConnection.request()</span></code></a> and
|
||
<a class="reference internal" href="../library/http.client.html#http.client.HTTPConnection.endheaders" title="http.client.HTTPConnection.endheaders"><code class="xref py py-meth docutils literal notranslate"><span class="pre">endheaders()</span></code></a> both now support
|
||
chunked encoding request bodies.
|
||
(Contributed by Demian Brecht and Rolf Krahl in <a class="reference external" href="https://bugs.python.org/issue12319">bpo-12319</a>.)</p>
|
||
</div>
|
||
<div class="section" id="idlelib-and-idle">
|
||
<h3>idlelib and IDLE<a class="headerlink" href="#idlelib-and-idle" title="Permalink to this headline">¶</a></h3>
|
||
<p>The idlelib package is being modernized and refactored to make IDLE look and
|
||
work better and to make the code easier to understand, test, and improve. Part
|
||
of making IDLE look better, especially on Linux and Mac, is using ttk widgets,
|
||
mostly in the dialogs. As a result, IDLE no longer runs with tcl/tk 8.4. It
|
||
now requires tcl/tk 8.5 or 8.6. We recommend running the latest release of
|
||
either.</p>
|
||
<p>‘Modernizing’ includes renaming and consolidation of idlelib modules. The
|
||
renaming of files with partial uppercase names is similar to the renaming of,
|
||
for instance, Tkinter and TkFont to tkinter and tkinter.font in 3.0. As a
|
||
result, imports of idlelib files that worked in 3.5 will usually not work in
|
||
3.6. At least a module name change will be needed (see idlelib/README.txt),
|
||
sometimes more. (Name changes contributed by Al Swiegart and Terry Reedy in
|
||
<a class="reference external" href="https://bugs.python.org/issue24225">bpo-24225</a>. Most idlelib patches since have been and will be part of the
|
||
process.)</p>
|
||
<p>In compensation, the eventual result with be that some idlelib classes will be
|
||
easier to use, with better APIs and docstrings explaining them. Additional
|
||
useful information will be added to idlelib when available.</p>
|
||
<p>New in 3.6.2:</p>
|
||
<p>Multiple fixes for autocompletion. (Contributed by Louie Lu in <a class="reference external" href="https://bugs.python.org/issue15786">bpo-15786</a>.)</p>
|
||
<p>New in 3.6.3:</p>
|
||
<p>Module Browser (on the File menu, formerly called Class Browser),
|
||
now displays nested functions and classes in addition to top-level
|
||
functions and classes.
|
||
(Contributed by Guilherme Polo, Cheryl Sabella, and Terry Jan Reedy
|
||
in <a class="reference external" href="https://bugs.python.org/issue1612262">bpo-1612262</a>.)</p>
|
||
<p>The IDLE features formerly implemented as extensions have been reimplemented
|
||
as normal features. Their settings have been moved from the Extensions tab
|
||
to other dialog tabs.
|
||
(Contributed by Charles Wohlganger and Terry Jan Reedy in <a class="reference external" href="https://bugs.python.org/issue27099">bpo-27099</a>.)</p>
|
||
<p>The Settings dialog (Options, Configure IDLE) has been partly rewritten
|
||
to improve both appearance and function.
|
||
(Contributed by Cheryl Sabella and Terry Jan Reedy in multiple issues.)</p>
|
||
<p>New in 3.6.4:</p>
|
||
<p>The font sample now includes a selection of non-Latin characters so that
|
||
users can better see the effect of selecting a particular font.
|
||
(Contributed by Terry Jan Reedy in <a class="reference external" href="https://bugs.python.org/issue13802">bpo-13802</a>.)
|
||
The sample can be edited to include other characters.
|
||
(Contributed by Serhiy Storchaka in <a class="reference external" href="https://bugs.python.org/issue31860">bpo-31860</a>.)</p>
|
||
<p>New in 3.6.6:</p>
|
||
<p>Editor code context option revised. Box displays all context lines up to
|
||
maxlines. Clicking on a context line jumps the editor to that line. Context
|
||
colors for custom themes is added to Highlights tab of Settings dialog.
|
||
(Contributed by Cheryl Sabella and Terry Jan Reedy in <a class="reference external" href="https://bugs.python.org/issue33642">bpo-33642</a>,
|
||
<a class="reference external" href="https://bugs.python.org/issue33768">bpo-33768</a>, and <a class="reference external" href="https://bugs.python.org/issue33679">bpo-33679</a>.)</p>
|
||
<p>On Windows, a new API call tells Windows that tk scales for DPI. On Windows
|
||
8.1+ or 10, with DPI compatibility properties of the Python binary
|
||
unchanged, and a monitor resolution greater than 96 DPI, this should
|
||
make text and lines sharper. It should otherwise have no effect.
|
||
(Contributed by Terry Jan Reedy in <a class="reference external" href="https://bugs.python.org/issue33656">bpo-33656</a>.)</p>
|
||
<p>New in 3.6.7:</p>
|
||
<p>Output over N lines (50 by default) is squeezed down to a button.
|
||
N can be changed in the PyShell section of the General page of the
|
||
Settings dialog. Fewer, but possibly extra long, lines can be squeezed by
|
||
right clicking on the output. Squeezed output can be expanded in place
|
||
by double-clicking the button or into the clipboard or a separate window
|
||
by right-clicking the button. (Contributed by Tal Einat in <a class="reference external" href="https://bugs.python.org/issue1529353">bpo-1529353</a>.)</p>
|
||
</div>
|
||
<div class="section" id="importlib">
|
||
<h3>importlib<a class="headerlink" href="#importlib" title="Permalink to this headline">¶</a></h3>
|
||
<p>Import now raises the new exception <a class="reference internal" href="../library/exceptions.html#ModuleNotFoundError" title="ModuleNotFoundError"><code class="xref py py-exc docutils literal notranslate"><span class="pre">ModuleNotFoundError</span></code></a>
|
||
(subclass of <a class="reference internal" href="../library/exceptions.html#ImportError" title="ImportError"><code class="xref py py-exc docutils literal notranslate"><span class="pre">ImportError</span></code></a>) when it cannot find a module. Code
|
||
that current checks for <code class="docutils literal notranslate"><span class="pre">ImportError</span></code> (in try-except) will still work.
|
||
(Contributed by Eric Snow in <a class="reference external" href="https://bugs.python.org/issue15767">bpo-15767</a>.)</p>
|
||
<p><a class="reference internal" href="../library/importlib.html#importlib.util.LazyLoader" title="importlib.util.LazyLoader"><code class="xref py py-class docutils literal notranslate"><span class="pre">importlib.util.LazyLoader</span></code></a> now calls
|
||
<a class="reference internal" href="../library/importlib.html#importlib.abc.Loader.create_module" title="importlib.abc.Loader.create_module"><code class="xref py py-meth docutils literal notranslate"><span class="pre">create_module()</span></code></a> on the wrapped loader, removing the
|
||
restriction that <a class="reference internal" href="../library/importlib.html#importlib.machinery.BuiltinImporter" title="importlib.machinery.BuiltinImporter"><code class="xref py py-class docutils literal notranslate"><span class="pre">importlib.machinery.BuiltinImporter</span></code></a> and
|
||
<a class="reference internal" href="../library/importlib.html#importlib.machinery.ExtensionFileLoader" title="importlib.machinery.ExtensionFileLoader"><code class="xref py py-class docutils literal notranslate"><span class="pre">importlib.machinery.ExtensionFileLoader</span></code></a> couldn’t be used with
|
||
<a class="reference internal" href="../library/importlib.html#importlib.util.LazyLoader" title="importlib.util.LazyLoader"><code class="xref py py-class docutils literal notranslate"><span class="pre">importlib.util.LazyLoader</span></code></a>.</p>
|
||
<p><a class="reference internal" href="../library/importlib.html#importlib.util.cache_from_source" title="importlib.util.cache_from_source"><code class="xref py py-func docutils literal notranslate"><span class="pre">importlib.util.cache_from_source()</span></code></a>,
|
||
<a class="reference internal" href="../library/importlib.html#importlib.util.source_from_cache" title="importlib.util.source_from_cache"><code class="xref py py-func docutils literal notranslate"><span class="pre">importlib.util.source_from_cache()</span></code></a>, and
|
||
<a class="reference internal" href="../library/importlib.html#importlib.util.spec_from_file_location" title="importlib.util.spec_from_file_location"><code class="xref py py-func docutils literal notranslate"><span class="pre">importlib.util.spec_from_file_location()</span></code></a> now accept a
|
||
<a class="reference internal" href="../glossary.html#term-path-like-object"><span class="xref std std-term">path-like object</span></a>.</p>
|
||
</div>
|
||
<div class="section" id="inspect">
|
||
<h3>inspect<a class="headerlink" href="#inspect" title="Permalink to this headline">¶</a></h3>
|
||
<p>The <a class="reference internal" href="../library/inspect.html#inspect.signature" title="inspect.signature"><code class="xref py py-func docutils literal notranslate"><span class="pre">inspect.signature()</span></code></a> function now reports the
|
||
implicit <code class="docutils literal notranslate"><span class="pre">.0</span></code> parameters generated by the compiler for comprehension and
|
||
generator expression scopes as if they were positional-only parameters called
|
||
<code class="docutils literal notranslate"><span class="pre">implicit0</span></code>. (Contributed by Jelle Zijlstra in <a class="reference external" href="https://bugs.python.org/issue19611">bpo-19611</a>.)</p>
|
||
<p>To reduce code churn when upgrading from Python 2.7 and the legacy
|
||
<a class="reference internal" href="../library/inspect.html#inspect.getargspec" title="inspect.getargspec"><code class="xref py py-func docutils literal notranslate"><span class="pre">inspect.getargspec()</span></code></a> API, the previously documented deprecation of
|
||
<a class="reference internal" href="../library/inspect.html#inspect.getfullargspec" title="inspect.getfullargspec"><code class="xref py py-func docutils literal notranslate"><span class="pre">inspect.getfullargspec()</span></code></a> has been reversed. While this function is
|
||
convenient for single/source Python 2/3 code bases, the richer
|
||
<a class="reference internal" href="../library/inspect.html#inspect.signature" title="inspect.signature"><code class="xref py py-func docutils literal notranslate"><span class="pre">inspect.signature()</span></code></a> interface remains the recommended approach for new
|
||
code. (Contributed by Nick Coghlan in <a class="reference external" href="https://bugs.python.org/issue27172">bpo-27172</a>)</p>
|
||
</div>
|
||
<div class="section" id="json">
|
||
<h3>json<a class="headerlink" href="#json" title="Permalink to this headline">¶</a></h3>
|
||
<p><a class="reference internal" href="../library/json.html#json.load" title="json.load"><code class="xref py py-func docutils literal notranslate"><span class="pre">json.load()</span></code></a> and <a class="reference internal" href="../library/json.html#json.loads" title="json.loads"><code class="xref py py-func docutils literal notranslate"><span class="pre">json.loads()</span></code></a> now support binary input. Encoded
|
||
JSON should be represented using either UTF-8, UTF-16, or UTF-32.
|
||
(Contributed by Serhiy Storchaka in <a class="reference external" href="https://bugs.python.org/issue17909">bpo-17909</a>.)</p>
|
||
</div>
|
||
<div class="section" id="logging">
|
||
<h3>logging<a class="headerlink" href="#logging" title="Permalink to this headline">¶</a></h3>
|
||
<p>The new <a class="reference internal" href="../library/logging.handlers.html#logging.handlers.WatchedFileHandler.reopenIfNeeded" title="logging.handlers.WatchedFileHandler.reopenIfNeeded"><code class="xref py py-meth docutils literal notranslate"><span class="pre">WatchedFileHandler.reopenIfNeeded()</span></code></a>
|
||
method has been added to add the ability to check if the log file needs to
|
||
be reopened.
|
||
(Contributed by Marian Horban in <a class="reference external" href="https://bugs.python.org/issue24884">bpo-24884</a>.)</p>
|
||
</div>
|
||
<div class="section" id="math">
|
||
<h3>math<a class="headerlink" href="#math" title="Permalink to this headline">¶</a></h3>
|
||
<p>The tau (<em>τ</em>) constant has been added to the <a class="reference internal" href="../library/math.html#module-math" title="math: Mathematical functions (sin() etc.)."><code class="xref py py-mod docutils literal notranslate"><span class="pre">math</span></code></a> and <a class="reference internal" href="../library/cmath.html#module-cmath" title="cmath: Mathematical functions for complex numbers."><code class="xref py py-mod docutils literal notranslate"><span class="pre">cmath</span></code></a>
|
||
modules.
|
||
(Contributed by Lisa Roach in <a class="reference external" href="https://bugs.python.org/issue12345">bpo-12345</a>, see <span class="target" id="index-30"></span><a class="pep reference external" href="https://www.python.org/dev/peps/pep-0628"><strong>PEP 628</strong></a> for details.)</p>
|
||
</div>
|
||
<div class="section" id="multiprocessing">
|
||
<h3>multiprocessing<a class="headerlink" href="#multiprocessing" title="Permalink to this headline">¶</a></h3>
|
||
<p><a class="reference internal" href="../library/multiprocessing.html#multiprocessing-proxy-objects"><span class="std std-ref">Proxy Objects</span></a> returned by
|
||
<code class="xref py py-func docutils literal notranslate"><span class="pre">multiprocessing.Manager()</span></code> can now be nested.
|
||
(Contributed by Davin Potts in <a class="reference external" href="https://bugs.python.org/issue6766">bpo-6766</a>.)</p>
|
||
</div>
|
||
<div class="section" id="os">
|
||
<h3>os<a class="headerlink" href="#os" title="Permalink to this headline">¶</a></h3>
|
||
<p>See the summary of <a class="reference internal" href="#whatsnew36-pep519"><span class="std std-ref">PEP 519</span></a> for details on how the
|
||
<a class="reference internal" href="../library/os.html#module-os" title="os: Miscellaneous operating system interfaces."><code class="xref py py-mod docutils literal notranslate"><span class="pre">os</span></code></a> and <a class="reference internal" href="../library/os.path.html#module-os.path" title="os.path: Operations on pathnames."><code class="xref py py-mod docutils literal notranslate"><span class="pre">os.path</span></code></a> modules now support
|
||
<a class="reference internal" href="../glossary.html#term-path-like-object"><span class="xref std std-term">path-like objects</span></a>.</p>
|
||
<p><a class="reference internal" href="../library/os.html#os.scandir" title="os.scandir"><code class="xref py py-func docutils literal notranslate"><span class="pre">scandir()</span></code></a> now supports <a class="reference internal" href="../library/stdtypes.html#bytes" title="bytes"><code class="xref py py-class docutils literal notranslate"><span class="pre">bytes</span></code></a> paths on Windows.</p>
|
||
<p>A new <a class="reference internal" href="../library/os.html#os.scandir.close" title="os.scandir.close"><code class="xref py py-meth docutils literal notranslate"><span class="pre">close()</span></code></a> method allows explicitly closing a
|
||
<a class="reference internal" href="../library/os.html#os.scandir" title="os.scandir"><code class="xref py py-func docutils literal notranslate"><span class="pre">scandir()</span></code></a> iterator. The <a class="reference internal" href="../library/os.html#os.scandir" title="os.scandir"><code class="xref py py-func docutils literal notranslate"><span class="pre">scandir()</span></code></a> iterator now
|
||
supports the <a class="reference internal" href="../glossary.html#term-context-manager"><span class="xref std std-term">context manager</span></a> protocol. If a <code class="xref py py-func docutils literal notranslate"><span class="pre">scandir()</span></code>
|
||
iterator is neither exhausted nor explicitly closed a <a class="reference internal" href="../library/exceptions.html#ResourceWarning" title="ResourceWarning"><code class="xref py py-exc docutils literal notranslate"><span class="pre">ResourceWarning</span></code></a>
|
||
will be emitted in its destructor.
|
||
(Contributed by Serhiy Storchaka in <a class="reference external" href="https://bugs.python.org/issue25994">bpo-25994</a>.)</p>
|
||
<p>On Linux, <a class="reference internal" href="../library/os.html#os.urandom" title="os.urandom"><code class="xref py py-func docutils literal notranslate"><span class="pre">os.urandom()</span></code></a> now blocks until the system urandom entropy pool
|
||
is initialized to increase the security. See the <span class="target" id="index-31"></span><a class="pep reference external" href="https://www.python.org/dev/peps/pep-0524"><strong>PEP 524</strong></a> for the rationale.</p>
|
||
<p>The Linux <code class="docutils literal notranslate"><span class="pre">getrandom()</span></code> syscall (get random bytes) is now exposed as the new
|
||
<a class="reference internal" href="../library/os.html#os.getrandom" title="os.getrandom"><code class="xref py py-func docutils literal notranslate"><span class="pre">os.getrandom()</span></code></a> function.
|
||
(Contributed by Victor Stinner, part of the <span class="target" id="index-32"></span><a class="pep reference external" href="https://www.python.org/dev/peps/pep-0524"><strong>PEP 524</strong></a>)</p>
|
||
</div>
|
||
<div class="section" id="pathlib">
|
||
<h3>pathlib<a class="headerlink" href="#pathlib" title="Permalink to this headline">¶</a></h3>
|
||
<p><a class="reference internal" href="../library/pathlib.html#module-pathlib" title="pathlib: Object-oriented filesystem paths"><code class="xref py py-mod docutils literal notranslate"><span class="pre">pathlib</span></code></a> now supports <a class="reference internal" href="../glossary.html#term-path-like-object"><span class="xref std std-term">path-like objects</span></a>.
|
||
(Contributed by Brett Cannon in <a class="reference external" href="https://bugs.python.org/issue27186">bpo-27186</a>.)</p>
|
||
<p>See the summary of <a class="reference internal" href="#whatsnew36-pep519"><span class="std std-ref">PEP 519</span></a> for details.</p>
|
||
</div>
|
||
<div class="section" id="pdb">
|
||
<h3>pdb<a class="headerlink" href="#pdb" title="Permalink to this headline">¶</a></h3>
|
||
<p>The <a class="reference internal" href="../library/pdb.html#pdb.Pdb" title="pdb.Pdb"><code class="xref py py-class docutils literal notranslate"><span class="pre">Pdb</span></code></a> class constructor has a new optional <em>readrc</em> argument
|
||
to control whether <code class="docutils literal notranslate"><span class="pre">.pdbrc</span></code> files should be read.</p>
|
||
</div>
|
||
<div class="section" id="pickle">
|
||
<h3>pickle<a class="headerlink" href="#pickle" title="Permalink to this headline">¶</a></h3>
|
||
<p>Objects that need <code class="docutils literal notranslate"><span class="pre">__new__</span></code> called with keyword arguments can now be pickled
|
||
using <a class="reference internal" href="../library/pickle.html#pickle-protocols"><span class="std std-ref">pickle protocols</span></a> older than protocol version 4.
|
||
Protocol version 4 already supports this case. (Contributed by Serhiy
|
||
Storchaka in <a class="reference external" href="https://bugs.python.org/issue24164">bpo-24164</a>.)</p>
|
||
</div>
|
||
<div class="section" id="pickletools">
|
||
<h3>pickletools<a class="headerlink" href="#pickletools" title="Permalink to this headline">¶</a></h3>
|
||
<p><a class="reference internal" href="../library/pickletools.html#pickletools.dis" title="pickletools.dis"><code class="xref py py-func docutils literal notranslate"><span class="pre">pickletools.dis()</span></code></a> now outputs the implicit memo index for the
|
||
<code class="docutils literal notranslate"><span class="pre">MEMOIZE</span></code> opcode.
|
||
(Contributed by Serhiy Storchaka in <a class="reference external" href="https://bugs.python.org/issue25382">bpo-25382</a>.)</p>
|
||
</div>
|
||
<div class="section" id="pydoc">
|
||
<h3>pydoc<a class="headerlink" href="#pydoc" title="Permalink to this headline">¶</a></h3>
|
||
<p>The <a class="reference internal" href="../library/pydoc.html#module-pydoc" title="pydoc: Documentation generator and online help system."><code class="xref py py-mod docutils literal notranslate"><span class="pre">pydoc</span></code></a> module has learned to respect the <code class="docutils literal notranslate"><span class="pre">MANPAGER</span></code>
|
||
environment variable.
|
||
(Contributed by Matthias Klose in <a class="reference external" href="https://bugs.python.org/issue8637">bpo-8637</a>.)</p>
|
||
<p><a class="reference internal" href="../library/functions.html#help" title="help"><code class="xref py py-func docutils literal notranslate"><span class="pre">help()</span></code></a> and <a class="reference internal" href="../library/pydoc.html#module-pydoc" title="pydoc: Documentation generator and online help system."><code class="xref py py-mod docutils literal notranslate"><span class="pre">pydoc</span></code></a> can now list named tuple fields in the
|
||
order they were defined rather than alphabetically.
|
||
(Contributed by Raymond Hettinger in <a class="reference external" href="https://bugs.python.org/issue24879">bpo-24879</a>.)</p>
|
||
</div>
|
||
<div class="section" id="random">
|
||
<h3>random<a class="headerlink" href="#random" title="Permalink to this headline">¶</a></h3>
|
||
<p>The new <a class="reference internal" href="../library/random.html#random.choices" title="random.choices"><code class="xref py py-func docutils literal notranslate"><span class="pre">choices()</span></code></a> function returns a list of elements of
|
||
specified size from the given population with optional weights.
|
||
(Contributed by Raymond Hettinger in <a class="reference external" href="https://bugs.python.org/issue18844">bpo-18844</a>.)</p>
|
||
</div>
|
||
<div class="section" id="re">
|
||
<h3>re<a class="headerlink" href="#re" title="Permalink to this headline">¶</a></h3>
|
||
<p>Added support of modifier spans in regular expressions. Examples:
|
||
<code class="docutils literal notranslate"><span class="pre">'(?i:p)ython'</span></code> matches <code class="docutils literal notranslate"><span class="pre">'python'</span></code> and <code class="docutils literal notranslate"><span class="pre">'Python'</span></code>, but not <code class="docutils literal notranslate"><span class="pre">'PYTHON'</span></code>;
|
||
<code class="docutils literal notranslate"><span class="pre">'(?i)g(?-i:v)r'</span></code> matches <code class="docutils literal notranslate"><span class="pre">'GvR'</span></code> and <code class="docutils literal notranslate"><span class="pre">'gvr'</span></code>, but not <code class="docutils literal notranslate"><span class="pre">'GVR'</span></code>.
|
||
(Contributed by Serhiy Storchaka in <a class="reference external" href="https://bugs.python.org/issue433028">bpo-433028</a>.)</p>
|
||
<p>Match object groups can be accessed by <code class="docutils literal notranslate"><span class="pre">__getitem__</span></code>, which is
|
||
equivalent to <code class="docutils literal notranslate"><span class="pre">group()</span></code>. So <code class="docutils literal notranslate"><span class="pre">mo['name']</span></code> is now equivalent to
|
||
<code class="docutils literal notranslate"><span class="pre">mo.group('name')</span></code>. (Contributed by Eric Smith in <a class="reference external" href="https://bugs.python.org/issue24454">bpo-24454</a>.)</p>
|
||
<p><code class="xref py py-class docutils literal notranslate"><span class="pre">Match</span></code> objects now support
|
||
<a class="reference internal" href="../reference/datamodel.html#object.__index__" title="object.__index__"><code class="xref py py-meth docutils literal notranslate"><span class="pre">index-like</span> <span class="pre">objects</span></code></a> as group
|
||
indices.
|
||
(Contributed by Jeroen Demeyer and Xiang Zhang in <a class="reference external" href="https://bugs.python.org/issue27177">bpo-27177</a>.)</p>
|
||
</div>
|
||
<div class="section" id="readline">
|
||
<h3>readline<a class="headerlink" href="#readline" title="Permalink to this headline">¶</a></h3>
|
||
<p>Added <a class="reference internal" href="../library/readline.html#readline.set_auto_history" title="readline.set_auto_history"><code class="xref py py-func docutils literal notranslate"><span class="pre">set_auto_history()</span></code></a> to enable or disable
|
||
automatic addition of input to the history list. (Contributed by
|
||
Tyler Crompton in <a class="reference external" href="https://bugs.python.org/issue26870">bpo-26870</a>.)</p>
|
||
</div>
|
||
<div class="section" id="rlcompleter">
|
||
<h3>rlcompleter<a class="headerlink" href="#rlcompleter" title="Permalink to this headline">¶</a></h3>
|
||
<p>Private and special attribute names now are omitted unless the prefix starts
|
||
with underscores. A space or a colon is added after some completed keywords.
|
||
(Contributed by Serhiy Storchaka in <a class="reference external" href="https://bugs.python.org/issue25011">bpo-25011</a> and <a class="reference external" href="https://bugs.python.org/issue25209">bpo-25209</a>.)</p>
|
||
</div>
|
||
<div class="section" id="shlex">
|
||
<h3>shlex<a class="headerlink" href="#shlex" title="Permalink to this headline">¶</a></h3>
|
||
<p>The <a class="reference internal" href="../library/shlex.html#shlex.shlex" title="shlex.shlex"><code class="xref py py-class docutils literal notranslate"><span class="pre">shlex</span></code></a> has much
|
||
<a class="reference internal" href="../library/shlex.html#improved-shell-compatibility"><span class="std std-ref">improved shell compatibility</span></a>
|
||
through the new <em>punctuation_chars</em> argument to control which characters
|
||
are treated as punctuation.
|
||
(Contributed by Vinay Sajip in <a class="reference external" href="https://bugs.python.org/issue1521950">bpo-1521950</a>.)</p>
|
||
</div>
|
||
<div class="section" id="site">
|
||
<h3>site<a class="headerlink" href="#site" title="Permalink to this headline">¶</a></h3>
|
||
<p>When specifying paths to add to <a class="reference internal" href="../library/sys.html#sys.path" title="sys.path"><code class="xref py py-attr docutils literal notranslate"><span class="pre">sys.path</span></code></a> in a <cite>.pth</cite> file,
|
||
you may now specify file paths on top of directories (e.g. zip files).
|
||
(Contributed by Wolfgang Langner in <a class="reference external" href="https://bugs.python.org/issue26587">bpo-26587</a>).</p>
|
||
</div>
|
||
<div class="section" id="sqlite3">
|
||
<h3>sqlite3<a class="headerlink" href="#sqlite3" title="Permalink to this headline">¶</a></h3>
|
||
<p><a class="reference internal" href="../library/sqlite3.html#sqlite3.Cursor.lastrowid" title="sqlite3.Cursor.lastrowid"><code class="xref py py-attr docutils literal notranslate"><span class="pre">sqlite3.Cursor.lastrowid</span></code></a> now supports the <code class="docutils literal notranslate"><span class="pre">REPLACE</span></code> statement.
|
||
(Contributed by Alex LordThorsen in <a class="reference external" href="https://bugs.python.org/issue16864">bpo-16864</a>.)</p>
|
||
</div>
|
||
<div class="section" id="socket">
|
||
<h3>socket<a class="headerlink" href="#socket" title="Permalink to this headline">¶</a></h3>
|
||
<p>The <a class="reference internal" href="../library/socket.html#socket.socket.ioctl" title="socket.socket.ioctl"><code class="xref py py-func docutils literal notranslate"><span class="pre">ioctl()</span></code></a> function now supports the
|
||
<a class="reference internal" href="../library/socket.html#socket.SIO_LOOPBACK_FAST_PATH" title="socket.SIO_LOOPBACK_FAST_PATH"><code class="xref py py-data docutils literal notranslate"><span class="pre">SIO_LOOPBACK_FAST_PATH</span></code></a> control code.
|
||
(Contributed by Daniel Stokes in <a class="reference external" href="https://bugs.python.org/issue26536">bpo-26536</a>.)</p>
|
||
<p>The <a class="reference internal" href="../library/socket.html#socket.socket.getsockopt" title="socket.socket.getsockopt"><code class="xref py py-meth docutils literal notranslate"><span class="pre">getsockopt()</span></code></a> constants <code class="docutils literal notranslate"><span class="pre">SO_DOMAIN</span></code>,
|
||
<code class="docutils literal notranslate"><span class="pre">SO_PROTOCOL</span></code>, <code class="docutils literal notranslate"><span class="pre">SO_PEERSEC</span></code>, and <code class="docutils literal notranslate"><span class="pre">SO_PASSSEC</span></code> are now supported.
|
||
(Contributed by Christian Heimes in <a class="reference external" href="https://bugs.python.org/issue26907">bpo-26907</a>.)</p>
|
||
<p>The <a class="reference internal" href="../library/socket.html#socket.socket.setsockopt" title="socket.socket.setsockopt"><code class="xref py py-meth docutils literal notranslate"><span class="pre">setsockopt()</span></code></a> now supports the
|
||
<code class="docutils literal notranslate"><span class="pre">setsockopt(level,</span> <span class="pre">optname,</span> <span class="pre">None,</span> <span class="pre">optlen:</span> <span class="pre">int)</span></code> form.
|
||
(Contributed by Christian Heimes in <a class="reference external" href="https://bugs.python.org/issue27744">bpo-27744</a>.)</p>
|
||
<p>The socket module now supports the address family
|
||
<a class="reference internal" href="../library/socket.html#socket.AF_ALG" title="socket.AF_ALG"><code class="xref py py-data docutils literal notranslate"><span class="pre">AF_ALG</span></code></a> to interface with Linux Kernel crypto API. <code class="docutils literal notranslate"><span class="pre">ALG_*</span></code>,
|
||
<code class="docutils literal notranslate"><span class="pre">SOL_ALG</span></code> and <a class="reference internal" href="../library/socket.html#socket.socket.sendmsg_afalg" title="socket.socket.sendmsg_afalg"><code class="xref py py-meth docutils literal notranslate"><span class="pre">sendmsg_afalg()</span></code></a> were added.
|
||
(Contributed by Christian Heimes in <a class="reference external" href="https://bugs.python.org/issue27744">bpo-27744</a> with support from
|
||
Victor Stinner.)</p>
|
||
<p>New Linux constants <code class="docutils literal notranslate"><span class="pre">TCP_USER_TIMEOUT</span></code> and <code class="docutils literal notranslate"><span class="pre">TCP_CONGESTION</span></code> were added.
|
||
(Contributed by Omar Sandoval, issue:<cite>26273</cite>).</p>
|
||
</div>
|
||
<div class="section" id="socketserver">
|
||
<h3>socketserver<a class="headerlink" href="#socketserver" title="Permalink to this headline">¶</a></h3>
|
||
<p>Servers based on the <a class="reference internal" href="../library/socketserver.html#module-socketserver" title="socketserver: A framework for network servers."><code class="xref py py-mod docutils literal notranslate"><span class="pre">socketserver</span></code></a> module, including those
|
||
defined in <a class="reference internal" href="../library/http.server.html#module-http.server" title="http.server: HTTP server and request handlers."><code class="xref py py-mod docutils literal notranslate"><span class="pre">http.server</span></code></a>, <a class="reference internal" href="../library/xmlrpc.server.html#module-xmlrpc.server" title="xmlrpc.server: Basic XML-RPC server implementations."><code class="xref py py-mod docutils literal notranslate"><span class="pre">xmlrpc.server</span></code></a> and
|
||
<a class="reference internal" href="../library/wsgiref.html#module-wsgiref.simple_server" title="wsgiref.simple_server: A simple WSGI HTTP server."><code class="xref py py-mod docutils literal notranslate"><span class="pre">wsgiref.simple_server</span></code></a>, now support the <a class="reference internal" href="../glossary.html#term-context-manager"><span class="xref std std-term">context manager</span></a>
|
||
protocol.
|
||
(Contributed by Aviv Palivoda in <a class="reference external" href="https://bugs.python.org/issue26404">bpo-26404</a>.)</p>
|
||
<p>The <code class="xref py py-attr docutils literal notranslate"><span class="pre">wfile</span></code> attribute of
|
||
<a class="reference internal" href="../library/socketserver.html#socketserver.StreamRequestHandler" title="socketserver.StreamRequestHandler"><code class="xref py py-class docutils literal notranslate"><span class="pre">StreamRequestHandler</span></code></a> classes now implements
|
||
the <a class="reference internal" href="../library/io.html#io.BufferedIOBase" title="io.BufferedIOBase"><code class="xref py py-class docutils literal notranslate"><span class="pre">io.BufferedIOBase</span></code></a> writable interface. In particular,
|
||
calling <a class="reference internal" href="../library/io.html#io.BufferedIOBase.write" title="io.BufferedIOBase.write"><code class="xref py py-meth docutils literal notranslate"><span class="pre">write()</span></code></a> is now guaranteed to send the
|
||
data in full. (Contributed by Martin Panter in <a class="reference external" href="https://bugs.python.org/issue26721">bpo-26721</a>.)</p>
|
||
</div>
|
||
<div class="section" id="ssl">
|
||
<h3>ssl<a class="headerlink" href="#ssl" title="Permalink to this headline">¶</a></h3>
|
||
<p><a class="reference internal" href="../library/ssl.html#module-ssl" title="ssl: TLS/SSL wrapper for socket objects"><code class="xref py py-mod docutils literal notranslate"><span class="pre">ssl</span></code></a> supports OpenSSL 1.1.0. The minimum recommend version is 1.0.2.
|
||
(Contributed by Christian Heimes in <a class="reference external" href="https://bugs.python.org/issue26470">bpo-26470</a>.)</p>
|
||
<p>3DES has been removed from the default cipher suites and ChaCha20 Poly1305
|
||
cipher suites have been added.
|
||
(Contributed by Christian Heimes in <a class="reference external" href="https://bugs.python.org/issue27850">bpo-27850</a> and <a class="reference external" href="https://bugs.python.org/issue27766">bpo-27766</a>.)</p>
|
||
<p><a class="reference internal" href="../library/ssl.html#ssl.SSLContext" title="ssl.SSLContext"><code class="xref py py-class docutils literal notranslate"><span class="pre">SSLContext</span></code></a> has better default configuration for options
|
||
and ciphers.
|
||
(Contributed by Christian Heimes in <a class="reference external" href="https://bugs.python.org/issue28043">bpo-28043</a>.)</p>
|
||
<p>SSL session can be copied from one client-side connection to another
|
||
with the new <a class="reference internal" href="../library/ssl.html#ssl.SSLSession" title="ssl.SSLSession"><code class="xref py py-class docutils literal notranslate"><span class="pre">SSLSession</span></code></a> class. TLS session resumption can
|
||
speed up the initial handshake, reduce latency and improve performance
|
||
(Contributed by Christian Heimes in <a class="reference external" href="https://bugs.python.org/issue19500">bpo-19500</a> based on a draft by
|
||
Alex Warhawk.)</p>
|
||
<p>The new <a class="reference internal" href="../library/ssl.html#ssl.SSLContext.get_ciphers" title="ssl.SSLContext.get_ciphers"><code class="xref py py-meth docutils literal notranslate"><span class="pre">get_ciphers()</span></code></a> method can be used to
|
||
get a list of enabled ciphers in order of cipher priority.</p>
|
||
<p>All constants and flags have been converted to <a class="reference internal" href="../library/enum.html#enum.IntEnum" title="enum.IntEnum"><code class="xref py py-class docutils literal notranslate"><span class="pre">IntEnum</span></code></a> and
|
||
<code class="xref py py-class docutils literal notranslate"><span class="pre">IntFlags</span></code>.
|
||
(Contributed by Christian Heimes in <a class="reference external" href="https://bugs.python.org/issue28025">bpo-28025</a>.)</p>
|
||
<p>Server and client-side specific TLS protocols for <a class="reference internal" href="../library/ssl.html#ssl.SSLContext" title="ssl.SSLContext"><code class="xref py py-class docutils literal notranslate"><span class="pre">SSLContext</span></code></a>
|
||
were added.
|
||
(Contributed by Christian Heimes in <a class="reference external" href="https://bugs.python.org/issue28085">bpo-28085</a>.)</p>
|
||
</div>
|
||
<div class="section" id="statistics">
|
||
<h3>statistics<a class="headerlink" href="#statistics" title="Permalink to this headline">¶</a></h3>
|
||
<p>A new <a class="reference internal" href="../library/statistics.html#statistics.harmonic_mean" title="statistics.harmonic_mean"><code class="xref py py-func docutils literal notranslate"><span class="pre">harmonic_mean()</span></code></a> function has been added.
|
||
(Contributed by Steven D’Aprano in <a class="reference external" href="https://bugs.python.org/issue27181">bpo-27181</a>.)</p>
|
||
</div>
|
||
<div class="section" id="struct">
|
||
<h3>struct<a class="headerlink" href="#struct" title="Permalink to this headline">¶</a></h3>
|
||
<p><a class="reference internal" href="../library/struct.html#module-struct" title="struct: Interpret bytes as packed binary data."><code class="xref py py-mod docutils literal notranslate"><span class="pre">struct</span></code></a> now supports IEEE 754 half-precision floats via the <code class="docutils literal notranslate"><span class="pre">'e'</span></code>
|
||
format specifier.
|
||
(Contributed by Eli Stevens, Mark Dickinson in <a class="reference external" href="https://bugs.python.org/issue11734">bpo-11734</a>.)</p>
|
||
</div>
|
||
<div class="section" id="subprocess">
|
||
<h3>subprocess<a class="headerlink" href="#subprocess" title="Permalink to this headline">¶</a></h3>
|
||
<p><a class="reference internal" href="../library/subprocess.html#subprocess.Popen" title="subprocess.Popen"><code class="xref py py-class docutils literal notranslate"><span class="pre">subprocess.Popen</span></code></a> destructor now emits a <a class="reference internal" href="../library/exceptions.html#ResourceWarning" title="ResourceWarning"><code class="xref py py-exc docutils literal notranslate"><span class="pre">ResourceWarning</span></code></a> warning
|
||
if the child process is still running. Use the context manager protocol (<code class="docutils literal notranslate"><span class="pre">with</span>
|
||
<span class="pre">proc:</span> <span class="pre">...</span></code>) or explicitly call the <a class="reference internal" href="../library/subprocess.html#subprocess.Popen.wait" title="subprocess.Popen.wait"><code class="xref py py-meth docutils literal notranslate"><span class="pre">wait()</span></code></a> method to
|
||
read the exit status of the child process. (Contributed by Victor Stinner in
|
||
<a class="reference external" href="https://bugs.python.org/issue26741">bpo-26741</a>.)</p>
|
||
<p>The <a class="reference internal" href="../library/subprocess.html#subprocess.Popen" title="subprocess.Popen"><code class="xref py py-class docutils literal notranslate"><span class="pre">subprocess.Popen</span></code></a> constructor and all functions that pass arguments
|
||
through to it now accept <em>encoding</em> and <em>errors</em> arguments. Specifying either
|
||
of these will enable text mode for the <em>stdin</em>, <em>stdout</em> and <em>stderr</em> streams.
|
||
(Contributed by Steve Dower in <a class="reference external" href="https://bugs.python.org/issue6135">bpo-6135</a>.)</p>
|
||
</div>
|
||
<div class="section" id="sys">
|
||
<h3>sys<a class="headerlink" href="#sys" title="Permalink to this headline">¶</a></h3>
|
||
<p>The new <a class="reference internal" href="../library/sys.html#sys.getfilesystemencodeerrors" title="sys.getfilesystemencodeerrors"><code class="xref py py-func docutils literal notranslate"><span class="pre">getfilesystemencodeerrors()</span></code></a> function returns the name of
|
||
the error mode used to convert between Unicode filenames and bytes filenames.
|
||
(Contributed by Steve Dower in <a class="reference external" href="https://bugs.python.org/issue27781">bpo-27781</a>.)</p>
|
||
<p>On Windows the return value of the <a class="reference internal" href="../library/sys.html#sys.getwindowsversion" title="sys.getwindowsversion"><code class="xref py py-func docutils literal notranslate"><span class="pre">getwindowsversion()</span></code></a> function
|
||
now includes the <em>platform_version</em> field which contains the accurate major
|
||
version, minor version and build number of the current operating system,
|
||
rather than the version that is being emulated for the process
|
||
(Contributed by Steve Dower in <a class="reference external" href="https://bugs.python.org/issue27932">bpo-27932</a>.)</p>
|
||
</div>
|
||
<div class="section" id="telnetlib">
|
||
<h3>telnetlib<a class="headerlink" href="#telnetlib" title="Permalink to this headline">¶</a></h3>
|
||
<p><a class="reference internal" href="../library/telnetlib.html#telnetlib.Telnet" title="telnetlib.Telnet"><code class="xref py py-class docutils literal notranslate"><span class="pre">Telnet</span></code></a> is now a context manager (contributed by
|
||
Stéphane Wirtel in <a class="reference external" href="https://bugs.python.org/issue25485">bpo-25485</a>).</p>
|
||
</div>
|
||
<div class="section" id="time">
|
||
<h3>time<a class="headerlink" href="#time" title="Permalink to this headline">¶</a></h3>
|
||
<p>The <a class="reference internal" href="../library/time.html#time.struct_time" title="time.struct_time"><code class="xref py py-class docutils literal notranslate"><span class="pre">struct_time</span></code></a> attributes <code class="xref py py-attr docutils literal notranslate"><span class="pre">tm_gmtoff</span></code> and
|
||
<code class="xref py py-attr docutils literal notranslate"><span class="pre">tm_zone</span></code> are now available on all platforms.</p>
|
||
</div>
|
||
<div class="section" id="timeit">
|
||
<h3>timeit<a class="headerlink" href="#timeit" title="Permalink to this headline">¶</a></h3>
|
||
<p>The new <a class="reference internal" href="../library/timeit.html#timeit.Timer.autorange" title="timeit.Timer.autorange"><code class="xref py py-meth docutils literal notranslate"><span class="pre">Timer.autorange()</span></code></a> convenience
|
||
method has been added to call <a class="reference internal" href="../library/timeit.html#timeit.Timer.timeit" title="timeit.Timer.timeit"><code class="xref py py-meth docutils literal notranslate"><span class="pre">Timer.timeit()</span></code></a>
|
||
repeatedly so that the total run time is greater or equal to 200 milliseconds.
|
||
(Contributed by Steven D’Aprano in <a class="reference external" href="https://bugs.python.org/issue6422">bpo-6422</a>.)</p>
|
||
<p><a class="reference internal" href="../library/timeit.html#module-timeit" title="timeit: Measure the execution time of small code snippets."><code class="xref py py-mod docutils literal notranslate"><span class="pre">timeit</span></code></a> now warns when there is substantial (4x) variance
|
||
between best and worst times.
|
||
(Contributed by Serhiy Storchaka in <a class="reference external" href="https://bugs.python.org/issue23552">bpo-23552</a>.)</p>
|
||
</div>
|
||
<div class="section" id="tkinter">
|
||
<h3>tkinter<a class="headerlink" href="#tkinter" title="Permalink to this headline">¶</a></h3>
|
||
<p>Added methods <code class="xref py py-meth docutils literal notranslate"><span class="pre">trace_add()</span></code>,
|
||
<code class="xref py py-meth docutils literal notranslate"><span class="pre">trace_remove()</span></code> and <code class="xref py py-meth docutils literal notranslate"><span class="pre">trace_info()</span></code>
|
||
in the <code class="xref py py-class docutils literal notranslate"><span class="pre">tkinter.Variable</span></code> class. They replace old methods
|
||
<code class="xref py py-meth docutils literal notranslate"><span class="pre">trace_variable()</span></code>, <code class="xref py py-meth docutils literal notranslate"><span class="pre">trace()</span></code>,
|
||
<code class="xref py py-meth docutils literal notranslate"><span class="pre">trace_vdelete()</span></code> and
|
||
<code class="xref py py-meth docutils literal notranslate"><span class="pre">trace_vinfo()</span></code> that use obsolete Tcl commands and might
|
||
not work in future versions of Tcl.
|
||
(Contributed by Serhiy Storchaka in <a class="reference external" href="https://bugs.python.org/issue22115">bpo-22115</a>).</p>
|
||
</div>
|
||
<div class="section" id="traceback">
|
||
<span id="whatsnew36-traceback"></span><h3>traceback<a class="headerlink" href="#traceback" title="Permalink to this headline">¶</a></h3>
|
||
<p>Both the traceback module and the interpreter’s builtin exception display now
|
||
abbreviate long sequences of repeated lines in tracebacks as shown in the
|
||
following example:</p>
|
||
<div class="highlight-python3 notranslate"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="k">def</span> <span class="nf">f</span><span class="p">():</span> <span class="n">f</span><span class="p">()</span>
|
||
<span class="gp">...</span>
|
||
<span class="gp">>>> </span><span class="n">f</span><span class="p">()</span>
|
||
<span class="gt">Traceback (most recent call last):</span>
|
||
File <span class="nb">"<stdin>"</span>, line <span class="m">1</span>, in <span class="n"><module></span>
|
||
File <span class="nb">"<stdin>"</span>, line <span class="m">1</span>, in <span class="n">f</span>
|
||
File <span class="nb">"<stdin>"</span>, line <span class="m">1</span>, in <span class="n">f</span>
|
||
File <span class="nb">"<stdin>"</span>, line <span class="m">1</span>, in <span class="n">f</span>
|
||
<span class="gr"> [Previous line repeated 995 more times]</span>
|
||
<span class="gr">RecursionError</span>: <span class="n">maximum recursion depth exceeded</span>
|
||
</pre></div>
|
||
</div>
|
||
<p>(Contributed by Emanuel Barry in <a class="reference external" href="https://bugs.python.org/issue26823">bpo-26823</a>.)</p>
|
||
</div>
|
||
<div class="section" id="tracemalloc">
|
||
<h3>tracemalloc<a class="headerlink" href="#tracemalloc" title="Permalink to this headline">¶</a></h3>
|
||
<p>The <a class="reference internal" href="../library/tracemalloc.html#module-tracemalloc" title="tracemalloc: Trace memory allocations."><code class="xref py py-mod docutils literal notranslate"><span class="pre">tracemalloc</span></code></a> module now supports tracing memory allocations in
|
||
multiple different address spaces.</p>
|
||
<p>The new <a class="reference internal" href="../library/tracemalloc.html#tracemalloc.DomainFilter" title="tracemalloc.DomainFilter"><code class="xref py py-class docutils literal notranslate"><span class="pre">DomainFilter</span></code></a> filter class has been added
|
||
to filter block traces by their address space (domain).</p>
|
||
<p>(Contributed by Victor Stinner in <a class="reference external" href="https://bugs.python.org/issue26588">bpo-26588</a>.)</p>
|
||
</div>
|
||
<div class="section" id="typing">
|
||
<span id="whatsnew36-typing"></span><h3>typing<a class="headerlink" href="#typing" title="Permalink to this headline">¶</a></h3>
|
||
<p>Since the <a class="reference internal" href="../library/typing.html#module-typing" title="typing: Support for type hints (see PEP 484)."><code class="xref py py-mod docutils literal notranslate"><span class="pre">typing</span></code></a> module is <a class="reference internal" href="../glossary.html#term-provisional-api"><span class="xref std std-term">provisional</span></a>,
|
||
all changes introduced in Python 3.6 have also been
|
||
backported to Python 3.5.x.</p>
|
||
<p>The <a class="reference internal" href="../library/typing.html#module-typing" title="typing: Support for type hints (see PEP 484)."><code class="xref py py-mod docutils literal notranslate"><span class="pre">typing</span></code></a> module has a much improved support for generic type
|
||
aliases. For example <code class="docutils literal notranslate"><span class="pre">Dict[str,</span> <span class="pre">Tuple[S,</span> <span class="pre">T]]</span></code> is now a valid
|
||
type annotation.
|
||
(Contributed by Guido van Rossum in <a class="reference external" href="https://github.com/python/typing/pull/195">Github #195</a>.)</p>
|
||
<p>The <a class="reference internal" href="../library/typing.html#typing.ContextManager" title="typing.ContextManager"><code class="xref py py-class docutils literal notranslate"><span class="pre">typing.ContextManager</span></code></a> class has been added for
|
||
representing <a class="reference internal" href="../library/contextlib.html#contextlib.AbstractContextManager" title="contextlib.AbstractContextManager"><code class="xref py py-class docutils literal notranslate"><span class="pre">contextlib.AbstractContextManager</span></code></a>.
|
||
(Contributed by Brett Cannon in <a class="reference external" href="https://bugs.python.org/issue25609">bpo-25609</a>.)</p>
|
||
<p>The <a class="reference internal" href="../library/typing.html#typing.Collection" title="typing.Collection"><code class="xref py py-class docutils literal notranslate"><span class="pre">typing.Collection</span></code></a> class has been added for
|
||
representing <a class="reference internal" href="../library/collections.abc.html#collections.abc.Collection" title="collections.abc.Collection"><code class="xref py py-class docutils literal notranslate"><span class="pre">collections.abc.Collection</span></code></a>.
|
||
(Contributed by Ivan Levkivskyi in <a class="reference external" href="https://bugs.python.org/issue27598">bpo-27598</a>.)</p>
|
||
<p>The <a class="reference internal" href="../library/typing.html#typing.ClassVar" title="typing.ClassVar"><code class="xref py py-const docutils literal notranslate"><span class="pre">typing.ClassVar</span></code></a> type construct has been added to
|
||
mark class variables. As introduced in <span class="target" id="index-33"></span><a class="pep reference external" href="https://www.python.org/dev/peps/pep-0526"><strong>PEP 526</strong></a>, a variable annotation
|
||
wrapped in ClassVar indicates that a given attribute is intended to be used as
|
||
a class variable and should not be set on instances of that class.
|
||
(Contributed by Ivan Levkivskyi in <a class="reference external" href="https://github.com/python/typing/pull/280">Github #280</a>.)</p>
|
||
<p>A new <a class="reference internal" href="../library/typing.html#typing.TYPE_CHECKING" title="typing.TYPE_CHECKING"><code class="xref py py-const docutils literal notranslate"><span class="pre">TYPE_CHECKING</span></code></a> constant that is assumed to be
|
||
<code class="docutils literal notranslate"><span class="pre">True</span></code> by the static type checkers, but is <code class="docutils literal notranslate"><span class="pre">False</span></code> at runtime.
|
||
(Contributed by Guido van Rossum in <a class="reference external" href="https://github.com/python/typing/issues/230">Github #230</a>.)</p>
|
||
<p>A new <a class="reference internal" href="../library/typing.html#typing.NewType" title="typing.NewType"><code class="xref py py-func docutils literal notranslate"><span class="pre">NewType()</span></code></a> helper function has been added to create
|
||
lightweight distinct types for annotations:</p>
|
||
<div class="highlight-python3 notranslate"><div class="highlight"><pre><span></span><span class="kn">from</span> <span class="nn">typing</span> <span class="k">import</span> <span class="n">NewType</span>
|
||
|
||
<span class="n">UserId</span> <span class="o">=</span> <span class="n">NewType</span><span class="p">(</span><span class="s1">'UserId'</span><span class="p">,</span> <span class="nb">int</span><span class="p">)</span>
|
||
<span class="n">some_id</span> <span class="o">=</span> <span class="n">UserId</span><span class="p">(</span><span class="mi">524313</span><span class="p">)</span>
|
||
</pre></div>
|
||
</div>
|
||
<p>The static type checker will treat the new type as if it were a subclass
|
||
of the original type. (Contributed by Ivan Levkivskyi in <a class="reference external" href="https://github.com/python/typing/issues/189">Github #189</a>.)</p>
|
||
</div>
|
||
<div class="section" id="unicodedata">
|
||
<h3>unicodedata<a class="headerlink" href="#unicodedata" title="Permalink to this headline">¶</a></h3>
|
||
<p>The <a class="reference internal" href="../library/unicodedata.html#module-unicodedata" title="unicodedata: Access the Unicode Database."><code class="xref py py-mod docutils literal notranslate"><span class="pre">unicodedata</span></code></a> module now uses data from <a class="reference external" href="http://unicode.org/versions/Unicode9.0.0/">Unicode 9.0.0</a>.
|
||
(Contributed by Benjamin Peterson.)</p>
|
||
</div>
|
||
<div class="section" id="unittest-mock">
|
||
<h3>unittest.mock<a class="headerlink" href="#unittest-mock" title="Permalink to this headline">¶</a></h3>
|
||
<p>The <a class="reference internal" href="../library/unittest.mock.html#unittest.mock.Mock" title="unittest.mock.Mock"><code class="xref py py-class docutils literal notranslate"><span class="pre">Mock</span></code></a> class has the following improvements:</p>
|
||
<ul class="simple">
|
||
<li><p>Two new methods, <a class="reference internal" href="../library/unittest.mock.html#unittest.mock.Mock.assert_called" title="unittest.mock.Mock.assert_called"><code class="xref py py-meth docutils literal notranslate"><span class="pre">Mock.assert_called()</span></code></a> and <a class="reference internal" href="../library/unittest.mock.html#unittest.mock.Mock.assert_called_once" title="unittest.mock.Mock.assert_called_once"><code class="xref py py-meth docutils literal notranslate"><span class="pre">Mock.assert_called_once()</span></code></a> to check if the mock object
|
||
was called.
|
||
(Contributed by Amit Saha in <a class="reference external" href="https://bugs.python.org/issue26323">bpo-26323</a>.)</p></li>
|
||
<li><p>The <a class="reference internal" href="../library/unittest.mock.html#unittest.mock.Mock.reset_mock" title="unittest.mock.Mock.reset_mock"><code class="xref py py-meth docutils literal notranslate"><span class="pre">Mock.reset_mock()</span></code></a> method
|
||
now has two optional keyword only arguments: <em>return_value</em> and
|
||
<em>side_effect</em>.
|
||
(Contributed by Kushal Das in <a class="reference external" href="https://bugs.python.org/issue21271">bpo-21271</a>.)</p></li>
|
||
</ul>
|
||
</div>
|
||
<div class="section" id="urllib-request">
|
||
<h3>urllib.request<a class="headerlink" href="#urllib-request" title="Permalink to this headline">¶</a></h3>
|
||
<p>If a HTTP request has a file or iterable body (other than a
|
||
bytes object) but no <code class="docutils literal notranslate"><span class="pre">Content-Length</span></code> header, rather than
|
||
throwing an error, <code class="xref py py-class docutils literal notranslate"><span class="pre">AbstractHTTPHandler</span></code> now
|
||
falls back to use chunked transfer encoding.
|
||
(Contributed by Demian Brecht and Rolf Krahl in <a class="reference external" href="https://bugs.python.org/issue12319">bpo-12319</a>.)</p>
|
||
</div>
|
||
<div class="section" id="urllib-robotparser">
|
||
<h3>urllib.robotparser<a class="headerlink" href="#urllib-robotparser" title="Permalink to this headline">¶</a></h3>
|
||
<p><a class="reference internal" href="../library/urllib.robotparser.html#urllib.robotparser.RobotFileParser" title="urllib.robotparser.RobotFileParser"><code class="xref py py-class docutils literal notranslate"><span class="pre">RobotFileParser</span></code></a> now supports the <code class="docutils literal notranslate"><span class="pre">Crawl-delay</span></code> and
|
||
<code class="docutils literal notranslate"><span class="pre">Request-rate</span></code> extensions.
|
||
(Contributed by Nikolay Bogoychev in <a class="reference external" href="https://bugs.python.org/issue16099">bpo-16099</a>.)</p>
|
||
</div>
|
||
<div class="section" id="venv">
|
||
<h3>venv<a class="headerlink" href="#venv" title="Permalink to this headline">¶</a></h3>
|
||
<p><a class="reference internal" href="../library/venv.html#module-venv" title="venv: Creation of virtual environments."><code class="xref py py-mod docutils literal notranslate"><span class="pre">venv</span></code></a> accepts a new parameter <code class="docutils literal notranslate"><span class="pre">--prompt</span></code>. This parameter provides an
|
||
alternative prefix for the virtual environment. (Proposed by Łukasz Balcerzak
|
||
and ported to 3.6 by Stéphane Wirtel in <a class="reference external" href="https://bugs.python.org/issue22829">bpo-22829</a>.)</p>
|
||
</div>
|
||
<div class="section" id="warnings">
|
||
<h3>warnings<a class="headerlink" href="#warnings" title="Permalink to this headline">¶</a></h3>
|
||
<p>A new optional <em>source</em> parameter has been added to the
|
||
<a class="reference internal" href="../library/warnings.html#warnings.warn_explicit" title="warnings.warn_explicit"><code class="xref py py-func docutils literal notranslate"><span class="pre">warnings.warn_explicit()</span></code></a> function: the destroyed object which emitted a
|
||
<a class="reference internal" href="../library/exceptions.html#ResourceWarning" title="ResourceWarning"><code class="xref py py-exc docutils literal notranslate"><span class="pre">ResourceWarning</span></code></a>. A <em>source</em> attribute has also been added to
|
||
<code class="xref py py-class docutils literal notranslate"><span class="pre">warnings.WarningMessage</span></code> (contributed by Victor Stinner in
|
||
<a class="reference external" href="https://bugs.python.org/issue26568">bpo-26568</a> and <a class="reference external" href="https://bugs.python.org/issue26567">bpo-26567</a>).</p>
|
||
<p>When a <a class="reference internal" href="../library/exceptions.html#ResourceWarning" title="ResourceWarning"><code class="xref py py-exc docutils literal notranslate"><span class="pre">ResourceWarning</span></code></a> warning is logged, the <a class="reference internal" href="../library/tracemalloc.html#module-tracemalloc" title="tracemalloc: Trace memory allocations."><code class="xref py py-mod docutils literal notranslate"><span class="pre">tracemalloc</span></code></a> module is now
|
||
used to try to retrieve the traceback where the destroyed object was allocated.</p>
|
||
<p>Example with the script <code class="docutils literal notranslate"><span class="pre">example.py</span></code>:</p>
|
||
<div class="highlight-python3 notranslate"><div class="highlight"><pre><span></span><span class="kn">import</span> <span class="nn">warnings</span>
|
||
|
||
<span class="k">def</span> <span class="nf">func</span><span class="p">():</span>
|
||
<span class="k">return</span> <span class="nb">open</span><span class="p">(</span><span class="vm">__file__</span><span class="p">)</span>
|
||
|
||
<span class="n">f</span> <span class="o">=</span> <span class="n">func</span><span class="p">()</span>
|
||
<span class="n">f</span> <span class="o">=</span> <span class="kc">None</span>
|
||
</pre></div>
|
||
</div>
|
||
<p>Output of the command <code class="docutils literal notranslate"><span class="pre">python3.6</span> <span class="pre">-Wd</span> <span class="pre">-X</span> <span class="pre">tracemalloc=5</span> <span class="pre">example.py</span></code>:</p>
|
||
<div class="highlight-python3 notranslate"><div class="highlight"><pre><span></span><span class="n">example</span><span class="o">.</span><span class="n">py</span><span class="p">:</span><span class="mi">7</span><span class="p">:</span> <span class="ne">ResourceWarning</span><span class="p">:</span> <span class="n">unclosed</span> <span class="n">file</span> <span class="o"><</span><span class="n">_io</span><span class="o">.</span><span class="n">TextIOWrapper</span> <span class="n">name</span><span class="o">=</span><span class="s1">'example.py'</span> <span class="n">mode</span><span class="o">=</span><span class="s1">'r'</span> <span class="n">encoding</span><span class="o">=</span><span class="s1">'UTF-8'</span><span class="o">></span>
|
||
<span class="n">f</span> <span class="o">=</span> <span class="kc">None</span>
|
||
<span class="n">Object</span> <span class="n">allocated</span> <span class="n">at</span> <span class="p">(</span><span class="n">most</span> <span class="n">recent</span> <span class="n">call</span> <span class="n">first</span><span class="p">):</span>
|
||
<span class="n">File</span> <span class="s2">"example.py"</span><span class="p">,</span> <span class="n">lineno</span> <span class="mi">4</span>
|
||
<span class="k">return</span> <span class="nb">open</span><span class="p">(</span><span class="vm">__file__</span><span class="p">)</span>
|
||
<span class="n">File</span> <span class="s2">"example.py"</span><span class="p">,</span> <span class="n">lineno</span> <span class="mi">6</span>
|
||
<span class="n">f</span> <span class="o">=</span> <span class="n">func</span><span class="p">()</span>
|
||
</pre></div>
|
||
</div>
|
||
<p>The “Object allocated at” traceback is new and is only displayed if
|
||
<a class="reference internal" href="../library/tracemalloc.html#module-tracemalloc" title="tracemalloc: Trace memory allocations."><code class="xref py py-mod docutils literal notranslate"><span class="pre">tracemalloc</span></code></a> is tracing Python memory allocations and if the
|
||
<a class="reference internal" href="../library/warnings.html#module-warnings" title="warnings: Issue warning messages and control their disposition."><code class="xref py py-mod docutils literal notranslate"><span class="pre">warnings</span></code></a> module was already imported.</p>
|
||
</div>
|
||
<div class="section" id="winreg">
|
||
<h3>winreg<a class="headerlink" href="#winreg" title="Permalink to this headline">¶</a></h3>
|
||
<p>Added the 64-bit integer type <a class="reference internal" href="../library/winreg.html#winreg.REG_QWORD" title="winreg.REG_QWORD"><code class="xref py py-data docutils literal notranslate"><span class="pre">REG_QWORD</span></code></a>.
|
||
(Contributed by Clement Rouault in <a class="reference external" href="https://bugs.python.org/issue23026">bpo-23026</a>.)</p>
|
||
</div>
|
||
<div class="section" id="winsound">
|
||
<h3>winsound<a class="headerlink" href="#winsound" title="Permalink to this headline">¶</a></h3>
|
||
<p>Allowed keyword arguments to be passed to <a class="reference internal" href="../library/winsound.html#winsound.Beep" title="winsound.Beep"><code class="xref py py-func docutils literal notranslate"><span class="pre">Beep</span></code></a>,
|
||
<a class="reference internal" href="../library/winsound.html#winsound.MessageBeep" title="winsound.MessageBeep"><code class="xref py py-func docutils literal notranslate"><span class="pre">MessageBeep</span></code></a>, and <a class="reference internal" href="../library/winsound.html#winsound.PlaySound" title="winsound.PlaySound"><code class="xref py py-func docutils literal notranslate"><span class="pre">PlaySound</span></code></a> (<a class="reference external" href="https://bugs.python.org/issue27982">bpo-27982</a>).</p>
|
||
</div>
|
||
<div class="section" id="xmlrpc-client">
|
||
<h3>xmlrpc.client<a class="headerlink" href="#xmlrpc-client" title="Permalink to this headline">¶</a></h3>
|
||
<p>The <a class="reference internal" href="../library/xmlrpc.client.html#module-xmlrpc.client" title="xmlrpc.client: XML-RPC client access."><code class="xref py py-mod docutils literal notranslate"><span class="pre">xmlrpc.client</span></code></a> module now supports unmarshalling
|
||
additional data types used by the Apache XML-RPC implementation
|
||
for numerics and <code class="docutils literal notranslate"><span class="pre">None</span></code>.
|
||
(Contributed by Serhiy Storchaka in <a class="reference external" href="https://bugs.python.org/issue26885">bpo-26885</a>.)</p>
|
||
</div>
|
||
<div class="section" id="zipfile">
|
||
<h3>zipfile<a class="headerlink" href="#zipfile" title="Permalink to this headline">¶</a></h3>
|
||
<p>A new <a class="reference internal" href="../library/zipfile.html#zipfile.ZipInfo.from_file" title="zipfile.ZipInfo.from_file"><code class="xref py py-meth docutils literal notranslate"><span class="pre">ZipInfo.from_file()</span></code></a> class method
|
||
allows making a <a class="reference internal" href="../library/zipfile.html#zipfile.ZipInfo" title="zipfile.ZipInfo"><code class="xref py py-class docutils literal notranslate"><span class="pre">ZipInfo</span></code></a> instance from a filesystem file.
|
||
A new <a class="reference internal" href="../library/zipfile.html#zipfile.ZipInfo.is_dir" title="zipfile.ZipInfo.is_dir"><code class="xref py py-meth docutils literal notranslate"><span class="pre">ZipInfo.is_dir()</span></code></a> method can be used
|
||
to check if the <a class="reference internal" href="../library/zipfile.html#zipfile.ZipInfo" title="zipfile.ZipInfo"><code class="xref py py-class docutils literal notranslate"><span class="pre">ZipInfo</span></code></a> instance represents a directory.
|
||
(Contributed by Thomas Kluyver in <a class="reference external" href="https://bugs.python.org/issue26039">bpo-26039</a>.)</p>
|
||
<p>The <a class="reference internal" href="../library/zipfile.html#zipfile.ZipFile.open" title="zipfile.ZipFile.open"><code class="xref py py-meth docutils literal notranslate"><span class="pre">ZipFile.open()</span></code></a> method can now be used to
|
||
write data into a ZIP file, as well as for extracting data.
|
||
(Contributed by Thomas Kluyver in <a class="reference external" href="https://bugs.python.org/issue26039">bpo-26039</a>.)</p>
|
||
</div>
|
||
<div class="section" id="zlib">
|
||
<h3>zlib<a class="headerlink" href="#zlib" title="Permalink to this headline">¶</a></h3>
|
||
<p>The <a class="reference internal" href="../library/zlib.html#zlib.compress" title="zlib.compress"><code class="xref py py-func docutils literal notranslate"><span class="pre">compress()</span></code></a> and <a class="reference internal" href="../library/zlib.html#zlib.decompress" title="zlib.decompress"><code class="xref py py-func docutils literal notranslate"><span class="pre">decompress()</span></code></a> functions now accept
|
||
keyword arguments.
|
||
(Contributed by Aviv Palivoda in <a class="reference external" href="https://bugs.python.org/issue26243">bpo-26243</a> and
|
||
Xiang Zhang in <a class="reference external" href="https://bugs.python.org/issue16764">bpo-16764</a> respectively.)</p>
|
||
</div>
|
||
</div>
|
||
<div class="section" id="optimizations">
|
||
<h2>Optimizations<a class="headerlink" href="#optimizations" title="Permalink to this headline">¶</a></h2>
|
||
<ul class="simple">
|
||
<li><p>The Python interpreter now uses a 16-bit wordcode instead of bytecode which
|
||
made a number of opcode optimizations possible.
|
||
(Contributed by Demur Rumed with input and reviews from
|
||
Serhiy Storchaka and Victor Stinner in <a class="reference external" href="https://bugs.python.org/issue26647">bpo-26647</a> and <a class="reference external" href="https://bugs.python.org/issue28050">bpo-28050</a>.)</p></li>
|
||
<li><p>The <a class="reference internal" href="../library/asyncio-future.html#asyncio.Future" title="asyncio.Future"><code class="xref py py-class docutils literal notranslate"><span class="pre">asyncio.Future</span></code></a> class now has an optimized C implementation.
|
||
(Contributed by Yury Selivanov and INADA Naoki in <a class="reference external" href="https://bugs.python.org/issue26081">bpo-26081</a>.)</p></li>
|
||
<li><p>The <a class="reference internal" href="../library/asyncio-task.html#asyncio.Task" title="asyncio.Task"><code class="xref py py-class docutils literal notranslate"><span class="pre">asyncio.Task</span></code></a> class now has an optimized
|
||
C implementation. (Contributed by Yury Selivanov in <a class="reference external" href="https://bugs.python.org/issue28544">bpo-28544</a>.)</p></li>
|
||
<li><p>Various implementation improvements in the <a class="reference internal" href="../library/typing.html#module-typing" title="typing: Support for type hints (see PEP 484)."><code class="xref py py-mod docutils literal notranslate"><span class="pre">typing</span></code></a> module
|
||
(such as caching of generic types) allow up to 30 times performance
|
||
improvements and reduced memory footprint.</p></li>
|
||
<li><p>The ASCII decoder is now up to 60 times as fast for error handlers
|
||
<code class="docutils literal notranslate"><span class="pre">surrogateescape</span></code>, <code class="docutils literal notranslate"><span class="pre">ignore</span></code> and <code class="docutils literal notranslate"><span class="pre">replace</span></code> (Contributed
|
||
by Victor Stinner in <a class="reference external" href="https://bugs.python.org/issue24870">bpo-24870</a>).</p></li>
|
||
<li><p>The ASCII and the Latin1 encoders are now up to 3 times as fast for the
|
||
error handler <code class="docutils literal notranslate"><span class="pre">surrogateescape</span></code>
|
||
(Contributed by Victor Stinner in <a class="reference external" href="https://bugs.python.org/issue25227">bpo-25227</a>).</p></li>
|
||
<li><p>The UTF-8 encoder is now up to 75 times as fast for error handlers
|
||
<code class="docutils literal notranslate"><span class="pre">ignore</span></code>, <code class="docutils literal notranslate"><span class="pre">replace</span></code>, <code class="docutils literal notranslate"><span class="pre">surrogateescape</span></code>, <code class="docutils literal notranslate"><span class="pre">surrogatepass</span></code> (Contributed
|
||
by Victor Stinner in <a class="reference external" href="https://bugs.python.org/issue25267">bpo-25267</a>).</p></li>
|
||
<li><p>The UTF-8 decoder is now up to 15 times as fast for error handlers
|
||
<code class="docutils literal notranslate"><span class="pre">ignore</span></code>, <code class="docutils literal notranslate"><span class="pre">replace</span></code> and <code class="docutils literal notranslate"><span class="pre">surrogateescape</span></code> (Contributed
|
||
by Victor Stinner in <a class="reference external" href="https://bugs.python.org/issue25301">bpo-25301</a>).</p></li>
|
||
<li><p><code class="docutils literal notranslate"><span class="pre">bytes</span> <span class="pre">%</span> <span class="pre">args</span></code> is now up to 2 times faster. (Contributed by Victor Stinner
|
||
in <a class="reference external" href="https://bugs.python.org/issue25349">bpo-25349</a>).</p></li>
|
||
<li><p><code class="docutils literal notranslate"><span class="pre">bytearray</span> <span class="pre">%</span> <span class="pre">args</span></code> is now between 2.5 and 5 times faster. (Contributed by
|
||
Victor Stinner in <a class="reference external" href="https://bugs.python.org/issue25399">bpo-25399</a>).</p></li>
|
||
<li><p>Optimize <a class="reference internal" href="../library/stdtypes.html#bytes.fromhex" title="bytes.fromhex"><code class="xref py py-meth docutils literal notranslate"><span class="pre">bytes.fromhex()</span></code></a> and <a class="reference internal" href="../library/stdtypes.html#bytearray.fromhex" title="bytearray.fromhex"><code class="xref py py-meth docutils literal notranslate"><span class="pre">bytearray.fromhex()</span></code></a>: they are now
|
||
between 2x and 3.5x faster. (Contributed by Victor Stinner in <a class="reference external" href="https://bugs.python.org/issue25401">bpo-25401</a>).</p></li>
|
||
<li><p>Optimize <code class="docutils literal notranslate"><span class="pre">bytes.replace(b'',</span> <span class="pre">b'.')</span></code> and <code class="docutils literal notranslate"><span class="pre">bytearray.replace(b'',</span> <span class="pre">b'.')</span></code>:
|
||
up to 80% faster. (Contributed by Josh Snider in <a class="reference external" href="https://bugs.python.org/issue26574">bpo-26574</a>).</p></li>
|
||
<li><p>Allocator functions of the <a class="reference internal" href="../c-api/memory.html#c.PyMem_Malloc" title="PyMem_Malloc"><code class="xref c c-func docutils literal notranslate"><span class="pre">PyMem_Malloc()</span></code></a> domain
|
||
(<a class="reference internal" href="../c-api/memory.html#c.PYMEM_DOMAIN_MEM" title="PYMEM_DOMAIN_MEM"><code class="xref c c-data docutils literal notranslate"><span class="pre">PYMEM_DOMAIN_MEM</span></code></a>) now use the <a class="reference internal" href="../c-api/memory.html#pymalloc"><span class="std std-ref">pymalloc memory allocator</span></a> instead of <code class="xref c c-func docutils literal notranslate"><span class="pre">malloc()</span></code> function of the C library. The
|
||
pymalloc allocator is optimized for objects smaller or equal to 512 bytes
|
||
with a short lifetime, and use <code class="xref c c-func docutils literal notranslate"><span class="pre">malloc()</span></code> for larger memory blocks.
|
||
(Contributed by Victor Stinner in <a class="reference external" href="https://bugs.python.org/issue26249">bpo-26249</a>).</p></li>
|
||
<li><p><a class="reference internal" href="../library/pickle.html#pickle.load" title="pickle.load"><code class="xref py py-func docutils literal notranslate"><span class="pre">pickle.load()</span></code></a> and <a class="reference internal" href="../library/pickle.html#pickle.loads" title="pickle.loads"><code class="xref py py-func docutils literal notranslate"><span class="pre">pickle.loads()</span></code></a> are now up to 10% faster when
|
||
deserializing many small objects (Contributed by Victor Stinner in
|
||
<a class="reference external" href="https://bugs.python.org/issue27056">bpo-27056</a>).</p></li>
|
||
<li><p>Passing <a class="reference internal" href="../glossary.html#term-keyword-argument"><span class="xref std std-term">keyword arguments</span></a> to a function has an
|
||
overhead in comparison with passing <a class="reference internal" href="../glossary.html#term-positional-argument"><span class="xref std std-term">positional arguments</span></a>. Now in extension functions implemented with using
|
||
Argument Clinic this overhead is significantly decreased.
|
||
(Contributed by Serhiy Storchaka in <a class="reference external" href="https://bugs.python.org/issue27574">bpo-27574</a>).</p></li>
|
||
<li><p>Optimized <a class="reference internal" href="../library/glob.html#glob.glob" title="glob.glob"><code class="xref py py-func docutils literal notranslate"><span class="pre">glob()</span></code></a> and <a class="reference internal" href="../library/glob.html#glob.iglob" title="glob.iglob"><code class="xref py py-func docutils literal notranslate"><span class="pre">iglob()</span></code></a> functions in the
|
||
<a class="reference internal" href="../library/glob.html#module-glob" title="glob: Unix shell style pathname pattern expansion."><code class="xref py py-mod docutils literal notranslate"><span class="pre">glob</span></code></a> module; they are now about 3–6 times faster.
|
||
(Contributed by Serhiy Storchaka in <a class="reference external" href="https://bugs.python.org/issue25596">bpo-25596</a>).</p></li>
|
||
<li><p>Optimized globbing in <a class="reference internal" href="../library/pathlib.html#module-pathlib" title="pathlib: Object-oriented filesystem paths"><code class="xref py py-mod docutils literal notranslate"><span class="pre">pathlib</span></code></a> by using <a class="reference internal" href="../library/os.html#os.scandir" title="os.scandir"><code class="xref py py-func docutils literal notranslate"><span class="pre">os.scandir()</span></code></a>;
|
||
it is now about 1.5–4 times faster.
|
||
(Contributed by Serhiy Storchaka in <a class="reference external" href="https://bugs.python.org/issue26032">bpo-26032</a>).</p></li>
|
||
<li><p><a class="reference internal" href="../library/xml.etree.elementtree.html#module-xml.etree.ElementTree" title="xml.etree.ElementTree: Implementation of the ElementTree API."><code class="xref py py-class docutils literal notranslate"><span class="pre">xml.etree.ElementTree</span></code></a> parsing, iteration and deepcopy performance
|
||
has been significantly improved.
|
||
(Contributed by Serhiy Storchaka in <a class="reference external" href="https://bugs.python.org/issue25638">bpo-25638</a>, <a class="reference external" href="https://bugs.python.org/issue25873">bpo-25873</a>,
|
||
and <a class="reference external" href="https://bugs.python.org/issue25869">bpo-25869</a>.)</p></li>
|
||
<li><p>Creation of <a class="reference internal" href="../library/fractions.html#fractions.Fraction" title="fractions.Fraction"><code class="xref py py-class docutils literal notranslate"><span class="pre">fractions.Fraction</span></code></a> instances from floats and
|
||
decimals is now 2 to 3 times faster.
|
||
(Contributed by Serhiy Storchaka in <a class="reference external" href="https://bugs.python.org/issue25971">bpo-25971</a>.)</p></li>
|
||
</ul>
|
||
</div>
|
||
<div class="section" id="build-and-c-api-changes">
|
||
<h2>Build and C API Changes<a class="headerlink" href="#build-and-c-api-changes" title="Permalink to this headline">¶</a></h2>
|
||
<ul class="simple">
|
||
<li><p>Python now requires some C99 support in the toolchain to build.
|
||
Most notably, Python now uses standard integer types and macros in
|
||
place of custom macros like <code class="docutils literal notranslate"><span class="pre">PY_LONG_LONG</span></code>.
|
||
For more information, see <span class="target" id="index-34"></span><a class="pep reference external" href="https://www.python.org/dev/peps/pep-0007"><strong>PEP 7</strong></a> and <a class="reference external" href="https://bugs.python.org/issue17884">bpo-17884</a>.</p></li>
|
||
<li><p>Cross-compiling CPython with the Android NDK and the Android API level set to
|
||
21 (Android 5.0 Lollipop) or greater runs successfully. While Android is not
|
||
yet a supported platform, the Python test suite runs on the Android emulator
|
||
with only about 16 tests failures. See the Android meta-issue <a class="reference external" href="https://bugs.python.org/issue26865">bpo-26865</a>.</p></li>
|
||
<li><p>The <code class="docutils literal notranslate"><span class="pre">--enable-optimizations</span></code> configure flag has been added. Turning it on
|
||
will activate expensive optimizations like PGO.
|
||
(Original patch by Alecsandru Patrascu of Intel in <a class="reference external" href="https://bugs.python.org/issue26359">bpo-26359</a>.)</p></li>
|
||
<li><p>The <a class="reference internal" href="../glossary.html#term-global-interpreter-lock"><span class="xref std std-term">GIL</span></a> must now be held when allocator
|
||
functions of <a class="reference internal" href="../c-api/memory.html#c.PYMEM_DOMAIN_OBJ" title="PYMEM_DOMAIN_OBJ"><code class="xref c c-data docutils literal notranslate"><span class="pre">PYMEM_DOMAIN_OBJ</span></code></a> (ex: <a class="reference internal" href="../c-api/memory.html#c.PyObject_Malloc" title="PyObject_Malloc"><code class="xref c c-func docutils literal notranslate"><span class="pre">PyObject_Malloc()</span></code></a>) and
|
||
<a class="reference internal" href="../c-api/memory.html#c.PYMEM_DOMAIN_MEM" title="PYMEM_DOMAIN_MEM"><code class="xref c c-data docutils literal notranslate"><span class="pre">PYMEM_DOMAIN_MEM</span></code></a> (ex: <a class="reference internal" href="../c-api/memory.html#c.PyMem_Malloc" title="PyMem_Malloc"><code class="xref c c-func docutils literal notranslate"><span class="pre">PyMem_Malloc()</span></code></a>) domains are called.</p></li>
|
||
<li><p>New <a class="reference internal" href="../c-api/init.html#c.Py_FinalizeEx" title="Py_FinalizeEx"><code class="xref c c-func docutils literal notranslate"><span class="pre">Py_FinalizeEx()</span></code></a> API which indicates if flushing buffered data
|
||
failed.
|
||
(Contributed by Martin Panter in <a class="reference external" href="https://bugs.python.org/issue5319">bpo-5319</a>.)</p></li>
|
||
<li><p><a class="reference internal" href="../c-api/arg.html#c.PyArg_ParseTupleAndKeywords" title="PyArg_ParseTupleAndKeywords"><code class="xref c c-func docutils literal notranslate"><span class="pre">PyArg_ParseTupleAndKeywords()</span></code></a> now supports <a class="reference internal" href="../glossary.html#positional-only-parameter"><span class="std std-ref">positional-only
|
||
parameters</span></a>. Positional-only parameters are
|
||
defined by empty names.
|
||
(Contributed by Serhiy Storchaka in <a class="reference external" href="https://bugs.python.org/issue26282">bpo-26282</a>).</p></li>
|
||
<li><p><code class="docutils literal notranslate"><span class="pre">PyTraceback_Print</span></code> method now abbreviates long sequences of repeated lines
|
||
as <code class="docutils literal notranslate"><span class="pre">"[Previous</span> <span class="pre">line</span> <span class="pre">repeated</span> <span class="pre">{count}</span> <span class="pre">more</span> <span class="pre">times]"</span></code>.
|
||
(Contributed by Emanuel Barry in <a class="reference external" href="https://bugs.python.org/issue26823">bpo-26823</a>.)</p></li>
|
||
<li><p>The new <a class="reference internal" href="../c-api/exceptions.html#c.PyErr_SetImportErrorSubclass" title="PyErr_SetImportErrorSubclass"><code class="xref c c-func docutils literal notranslate"><span class="pre">PyErr_SetImportErrorSubclass()</span></code></a> function allows for
|
||
specifying a subclass of <a class="reference internal" href="../library/exceptions.html#ImportError" title="ImportError"><code class="xref py py-exc docutils literal notranslate"><span class="pre">ImportError</span></code></a> to raise.
|
||
(Contributed by Eric Snow in <a class="reference external" href="https://bugs.python.org/issue15767">bpo-15767</a>.)</p></li>
|
||
<li><p>The new <a class="reference internal" href="../c-api/exceptions.html#c.PyErr_ResourceWarning" title="PyErr_ResourceWarning"><code class="xref c c-func docutils literal notranslate"><span class="pre">PyErr_ResourceWarning()</span></code></a> function can be used to generate
|
||
a <a class="reference internal" href="../library/exceptions.html#ResourceWarning" title="ResourceWarning"><code class="xref py py-exc docutils literal notranslate"><span class="pre">ResourceWarning</span></code></a> providing the source of the resource allocation.
|
||
(Contributed by Victor Stinner in <a class="reference external" href="https://bugs.python.org/issue26567">bpo-26567</a>.)</p></li>
|
||
<li><p>The new <a class="reference internal" href="../c-api/sys.html#c.PyOS_FSPath" title="PyOS_FSPath"><code class="xref c c-func docutils literal notranslate"><span class="pre">PyOS_FSPath()</span></code></a> function returns the file system
|
||
representation of a <a class="reference internal" href="../glossary.html#term-path-like-object"><span class="xref std std-term">path-like object</span></a>.
|
||
(Contributed by Brett Cannon in <a class="reference external" href="https://bugs.python.org/issue27186">bpo-27186</a>.)</p></li>
|
||
<li><p>The <a class="reference internal" href="../c-api/unicode.html#c.PyUnicode_FSConverter" title="PyUnicode_FSConverter"><code class="xref c c-func docutils literal notranslate"><span class="pre">PyUnicode_FSConverter()</span></code></a> and <a class="reference internal" href="../c-api/unicode.html#c.PyUnicode_FSDecoder" title="PyUnicode_FSDecoder"><code class="xref c c-func docutils literal notranslate"><span class="pre">PyUnicode_FSDecoder()</span></code></a>
|
||
functions will now accept <a class="reference internal" href="../glossary.html#term-path-like-object"><span class="xref std std-term">path-like objects</span></a>.</p></li>
|
||
</ul>
|
||
</div>
|
||
<div class="section" id="other-improvements">
|
||
<h2>Other Improvements<a class="headerlink" href="#other-improvements" title="Permalink to this headline">¶</a></h2>
|
||
<ul>
|
||
<li><p>When <a class="reference internal" href="../using/cmdline.html#cmdoption-version"><code class="xref std std-option docutils literal notranslate"><span class="pre">--version</span></code></a> (short form: <a class="reference internal" href="../using/cmdline.html#cmdoption-v"><code class="xref std std-option docutils literal notranslate"><span class="pre">-V</span></code></a>) is supplied twice,
|
||
Python prints <a class="reference internal" href="../library/sys.html#sys.version" title="sys.version"><code class="xref py py-data docutils literal notranslate"><span class="pre">sys.version</span></code></a> for detailed information.</p>
|
||
<div class="highlight-shell-session notranslate"><div class="highlight"><pre><span></span><span class="gp">$</span> ./python -VV
|
||
<span class="go">Python 3.6.0b4+ (3.6:223967b49e49+, Nov 21 2016, 20:55:04)</span>
|
||
<span class="go">[GCC 4.2.1 Compatible Apple LLVM 8.0.0 (clang-800.0.42.1)]</span>
|
||
</pre></div>
|
||
</div>
|
||
</li>
|
||
</ul>
|
||
</div>
|
||
<div class="section" id="deprecated">
|
||
<h2>Deprecated<a class="headerlink" href="#deprecated" title="Permalink to this headline">¶</a></h2>
|
||
<div class="section" id="new-keywords">
|
||
<h3>New Keywords<a class="headerlink" href="#new-keywords" title="Permalink to this headline">¶</a></h3>
|
||
<p><code class="docutils literal notranslate"><span class="pre">async</span></code> and <code class="docutils literal notranslate"><span class="pre">await</span></code> are not recommended to be used as variable, class,
|
||
function or module names. Introduced by <span class="target" id="index-35"></span><a class="pep reference external" href="https://www.python.org/dev/peps/pep-0492"><strong>PEP 492</strong></a> in Python 3.5, they will
|
||
become proper keywords in Python 3.7. Starting in Python 3.6, the use of
|
||
<code class="docutils literal notranslate"><span class="pre">async</span></code> or <code class="docutils literal notranslate"><span class="pre">await</span></code> as names will generate a <a class="reference internal" href="../library/exceptions.html#DeprecationWarning" title="DeprecationWarning"><code class="xref py py-exc docutils literal notranslate"><span class="pre">DeprecationWarning</span></code></a>.</p>
|
||
</div>
|
||
<div class="section" id="deprecated-python-behavior">
|
||
<h3>Deprecated Python behavior<a class="headerlink" href="#deprecated-python-behavior" title="Permalink to this headline">¶</a></h3>
|
||
<p>Raising the <a class="reference internal" href="../library/exceptions.html#StopIteration" title="StopIteration"><code class="xref py py-exc docutils literal notranslate"><span class="pre">StopIteration</span></code></a> exception inside a generator will now
|
||
generate a <a class="reference internal" href="../library/exceptions.html#DeprecationWarning" title="DeprecationWarning"><code class="xref py py-exc docutils literal notranslate"><span class="pre">DeprecationWarning</span></code></a>, and will trigger a <a class="reference internal" href="../library/exceptions.html#RuntimeError" title="RuntimeError"><code class="xref py py-exc docutils literal notranslate"><span class="pre">RuntimeError</span></code></a>
|
||
in Python 3.7. See <a class="reference internal" href="3.5.html#whatsnew-pep-479"><span class="std std-ref">PEP 479: Change StopIteration handling inside generators</span></a> for details.</p>
|
||
<p>The <a class="reference internal" href="../reference/datamodel.html#object.__aiter__" title="object.__aiter__"><code class="xref py py-meth docutils literal notranslate"><span class="pre">__aiter__()</span></code></a> method is now expected to return an asynchronous
|
||
iterator directly instead of returning an awaitable as previously.
|
||
Doing the former will trigger a <a class="reference internal" href="../library/exceptions.html#DeprecationWarning" title="DeprecationWarning"><code class="xref py py-exc docutils literal notranslate"><span class="pre">DeprecationWarning</span></code></a>. Backward
|
||
compatibility will be removed in Python 3.7.
|
||
(Contributed by Yury Selivanov in <a class="reference external" href="https://bugs.python.org/issue27243">bpo-27243</a>.)</p>
|
||
<p>A backslash-character pair that is not a valid escape sequence now generates
|
||
a <a class="reference internal" href="../library/exceptions.html#DeprecationWarning" title="DeprecationWarning"><code class="xref py py-exc docutils literal notranslate"><span class="pre">DeprecationWarning</span></code></a>. Although this will eventually become a
|
||
<a class="reference internal" href="../library/exceptions.html#SyntaxError" title="SyntaxError"><code class="xref py py-exc docutils literal notranslate"><span class="pre">SyntaxError</span></code></a>, that will not be for several Python releases.
|
||
(Contributed by Emanuel Barry in <a class="reference external" href="https://bugs.python.org/issue27364">bpo-27364</a>.)</p>
|
||
<p>When performing a relative import, falling back on <code class="docutils literal notranslate"><span class="pre">__name__</span></code> and
|
||
<code class="docutils literal notranslate"><span class="pre">__path__</span></code> from the calling module when <code class="docutils literal notranslate"><span class="pre">__spec__</span></code> or
|
||
<code class="docutils literal notranslate"><span class="pre">__package__</span></code> are not defined now raises an <a class="reference internal" href="../library/exceptions.html#ImportWarning" title="ImportWarning"><code class="xref py py-exc docutils literal notranslate"><span class="pre">ImportWarning</span></code></a>.
|
||
(Contributed by Rose Ames in <a class="reference external" href="https://bugs.python.org/issue25791">bpo-25791</a>.)</p>
|
||
</div>
|
||
<div class="section" id="deprecated-python-modules-functions-and-methods">
|
||
<h3>Deprecated Python modules, functions and methods<a class="headerlink" href="#deprecated-python-modules-functions-and-methods" title="Permalink to this headline">¶</a></h3>
|
||
<div class="section" id="asynchat">
|
||
<h4>asynchat<a class="headerlink" href="#asynchat" title="Permalink to this headline">¶</a></h4>
|
||
<p>The <a class="reference internal" href="../library/asynchat.html#module-asynchat" title="asynchat: Support for asynchronous command/response protocols."><code class="xref py py-mod docutils literal notranslate"><span class="pre">asynchat</span></code></a> has been deprecated in favor of <a class="reference internal" href="../library/asyncio.html#module-asyncio" title="asyncio: Asynchronous I/O."><code class="xref py py-mod docutils literal notranslate"><span class="pre">asyncio</span></code></a>.
|
||
(Contributed by Mariatta in <a class="reference external" href="https://bugs.python.org/issue25002">bpo-25002</a>.)</p>
|
||
</div>
|
||
<div class="section" id="asyncore">
|
||
<h4>asyncore<a class="headerlink" href="#asyncore" title="Permalink to this headline">¶</a></h4>
|
||
<p>The <a class="reference internal" href="../library/asyncore.html#module-asyncore" title="asyncore: A base class for developing asynchronous socket handling services."><code class="xref py py-mod docutils literal notranslate"><span class="pre">asyncore</span></code></a> has been deprecated in favor of <a class="reference internal" href="../library/asyncio.html#module-asyncio" title="asyncio: Asynchronous I/O."><code class="xref py py-mod docutils literal notranslate"><span class="pre">asyncio</span></code></a>.
|
||
(Contributed by Mariatta in <a class="reference external" href="https://bugs.python.org/issue25002">bpo-25002</a>.)</p>
|
||
</div>
|
||
<div class="section" id="dbm">
|
||
<h4>dbm<a class="headerlink" href="#dbm" title="Permalink to this headline">¶</a></h4>
|
||
<p>Unlike other <a class="reference internal" href="../library/dbm.html#module-dbm" title="dbm: Interfaces to various Unix "database" formats."><code class="xref py py-mod docutils literal notranslate"><span class="pre">dbm</span></code></a> implementations, the <a class="reference internal" href="../library/dbm.html#module-dbm.dumb" title="dbm.dumb: Portable implementation of the simple DBM interface."><code class="xref py py-mod docutils literal notranslate"><span class="pre">dbm.dumb</span></code></a> module
|
||
creates databases with the <code class="docutils literal notranslate"><span class="pre">'rw'</span></code> mode and allows modifying the database
|
||
opened with the <code class="docutils literal notranslate"><span class="pre">'r'</span></code> mode. This behavior is now deprecated and will
|
||
be removed in 3.8.
|
||
(Contributed by Serhiy Storchaka in <a class="reference external" href="https://bugs.python.org/issue21708">bpo-21708</a>.)</p>
|
||
</div>
|
||
<div class="section" id="id2">
|
||
<h4>distutils<a class="headerlink" href="#id2" title="Permalink to this headline">¶</a></h4>
|
||
<p>The undocumented <code class="docutils literal notranslate"><span class="pre">extra_path</span></code> argument to the
|
||
<code class="xref py py-class docutils literal notranslate"><span class="pre">Distribution</span></code> constructor is now considered deprecated
|
||
and will raise a warning if set. Support for this parameter will be
|
||
removed in a future Python release. See <a class="reference external" href="https://bugs.python.org/issue27919">bpo-27919</a> for details.</p>
|
||
</div>
|
||
<div class="section" id="grp">
|
||
<h4>grp<a class="headerlink" href="#grp" title="Permalink to this headline">¶</a></h4>
|
||
<p>The support of non-integer arguments in <a class="reference internal" href="../library/grp.html#grp.getgrgid" title="grp.getgrgid"><code class="xref py py-func docutils literal notranslate"><span class="pre">getgrgid()</span></code></a> has been
|
||
deprecated.
|
||
(Contributed by Serhiy Storchaka in <a class="reference external" href="https://bugs.python.org/issue26129">bpo-26129</a>.)</p>
|
||
</div>
|
||
<div class="section" id="id3">
|
||
<h4>importlib<a class="headerlink" href="#id3" title="Permalink to this headline">¶</a></h4>
|
||
<p>The <a class="reference internal" href="../library/importlib.html#importlib.machinery.SourceFileLoader.load_module" title="importlib.machinery.SourceFileLoader.load_module"><code class="xref py py-meth docutils literal notranslate"><span class="pre">importlib.machinery.SourceFileLoader.load_module()</span></code></a> and
|
||
<a class="reference internal" href="../library/importlib.html#importlib.machinery.SourcelessFileLoader.load_module" title="importlib.machinery.SourcelessFileLoader.load_module"><code class="xref py py-meth docutils literal notranslate"><span class="pre">importlib.machinery.SourcelessFileLoader.load_module()</span></code></a> methods
|
||
are now deprecated. They were the only remaining implementations of
|
||
<a class="reference internal" href="../library/importlib.html#importlib.abc.Loader.load_module" title="importlib.abc.Loader.load_module"><code class="xref py py-meth docutils literal notranslate"><span class="pre">importlib.abc.Loader.load_module()</span></code></a> in <a class="reference internal" href="../library/importlib.html#module-importlib" title="importlib: The implementation of the import machinery."><code class="xref py py-mod docutils literal notranslate"><span class="pre">importlib</span></code></a> that had not
|
||
been deprecated in previous versions of Python in favour of
|
||
<a class="reference internal" href="../library/importlib.html#importlib.abc.Loader.exec_module" title="importlib.abc.Loader.exec_module"><code class="xref py py-meth docutils literal notranslate"><span class="pre">importlib.abc.Loader.exec_module()</span></code></a>.</p>
|
||
<p>The <a class="reference internal" href="../library/importlib.html#importlib.machinery.WindowsRegistryFinder" title="importlib.machinery.WindowsRegistryFinder"><code class="xref py py-class docutils literal notranslate"><span class="pre">importlib.machinery.WindowsRegistryFinder</span></code></a> class is now
|
||
deprecated. As of 3.6.0, it is still added to <a class="reference internal" href="../library/sys.html#sys.meta_path" title="sys.meta_path"><code class="xref py py-attr docutils literal notranslate"><span class="pre">sys.meta_path</span></code></a> by
|
||
default (on Windows), but this may change in future releases.</p>
|
||
</div>
|
||
<div class="section" id="id4">
|
||
<h4>os<a class="headerlink" href="#id4" title="Permalink to this headline">¶</a></h4>
|
||
<p>Undocumented support of general <a class="reference internal" href="../glossary.html#term-bytes-like-object"><span class="xref std std-term">bytes-like objects</span></a>
|
||
as paths in <a class="reference internal" href="../library/os.html#module-os" title="os: Miscellaneous operating system interfaces."><code class="xref py py-mod docutils literal notranslate"><span class="pre">os</span></code></a> functions, <a class="reference internal" href="../library/functions.html#compile" title="compile"><code class="xref py py-func docutils literal notranslate"><span class="pre">compile()</span></code></a> and similar functions is
|
||
now deprecated.
|
||
(Contributed by Serhiy Storchaka in <a class="reference external" href="https://bugs.python.org/issue25791">bpo-25791</a> and <a class="reference external" href="https://bugs.python.org/issue26754">bpo-26754</a>.)</p>
|
||
</div>
|
||
<div class="section" id="id5">
|
||
<h4>re<a class="headerlink" href="#id5" title="Permalink to this headline">¶</a></h4>
|
||
<p>Support for inline flags <code class="docutils literal notranslate"><span class="pre">(?letters)</span></code> in the middle of the regular
|
||
expression has been deprecated and will be removed in a future Python
|
||
version. Flags at the start of a regular expression are still allowed.
|
||
(Contributed by Serhiy Storchaka in <a class="reference external" href="https://bugs.python.org/issue22493">bpo-22493</a>.)</p>
|
||
</div>
|
||
<div class="section" id="id6">
|
||
<h4>ssl<a class="headerlink" href="#id6" title="Permalink to this headline">¶</a></h4>
|
||
<p>OpenSSL 0.9.8, 1.0.0 and 1.0.1 are deprecated and no longer supported.
|
||
In the future the <a class="reference internal" href="../library/ssl.html#module-ssl" title="ssl: TLS/SSL wrapper for socket objects"><code class="xref py py-mod docutils literal notranslate"><span class="pre">ssl</span></code></a> module will require at least OpenSSL 1.0.2 or
|
||
1.1.0.</p>
|
||
<p>SSL-related arguments like <code class="docutils literal notranslate"><span class="pre">certfile</span></code>, <code class="docutils literal notranslate"><span class="pre">keyfile</span></code> and <code class="docutils literal notranslate"><span class="pre">check_hostname</span></code>
|
||
in <a class="reference internal" href="../library/ftplib.html#module-ftplib" title="ftplib: FTP protocol client (requires sockets)."><code class="xref py py-mod docutils literal notranslate"><span class="pre">ftplib</span></code></a>, <a class="reference internal" href="../library/http.client.html#module-http.client" title="http.client: HTTP and HTTPS protocol client (requires sockets)."><code class="xref py py-mod docutils literal notranslate"><span class="pre">http.client</span></code></a>, <a class="reference internal" href="../library/imaplib.html#module-imaplib" title="imaplib: IMAP4 protocol client (requires sockets)."><code class="xref py py-mod docutils literal notranslate"><span class="pre">imaplib</span></code></a>, <a class="reference internal" href="../library/poplib.html#module-poplib" title="poplib: POP3 protocol client (requires sockets)."><code class="xref py py-mod docutils literal notranslate"><span class="pre">poplib</span></code></a>,
|
||
and <a class="reference internal" href="../library/smtplib.html#module-smtplib" title="smtplib: SMTP protocol client (requires sockets)."><code class="xref py py-mod docutils literal notranslate"><span class="pre">smtplib</span></code></a> have been deprecated in favor of <code class="docutils literal notranslate"><span class="pre">context</span></code>.
|
||
(Contributed by Christian Heimes in <a class="reference external" href="https://bugs.python.org/issue28022">bpo-28022</a>.)</p>
|
||
<p>A couple of protocols and functions of the <a class="reference internal" href="../library/ssl.html#module-ssl" title="ssl: TLS/SSL wrapper for socket objects"><code class="xref py py-mod docutils literal notranslate"><span class="pre">ssl</span></code></a> module are now
|
||
deprecated. Some features will no longer be available in future versions
|
||
of OpenSSL. Other features are deprecated in favor of a different API.
|
||
(Contributed by Christian Heimes in <a class="reference external" href="https://bugs.python.org/issue28022">bpo-28022</a> and <a class="reference external" href="https://bugs.python.org/issue26470">bpo-26470</a>.)</p>
|
||
</div>
|
||
<div class="section" id="id7">
|
||
<h4>tkinter<a class="headerlink" href="#id7" title="Permalink to this headline">¶</a></h4>
|
||
<p>The <a class="reference internal" href="../library/tkinter.tix.html#module-tkinter.tix" title="tkinter.tix: Tk Extension Widgets for Tkinter"><code class="xref py py-mod docutils literal notranslate"><span class="pre">tkinter.tix</span></code></a> module is now deprecated. <a class="reference internal" href="../library/tkinter.html#module-tkinter" title="tkinter: Interface to Tcl/Tk for graphical user interfaces"><code class="xref py py-mod docutils literal notranslate"><span class="pre">tkinter</span></code></a> users
|
||
should use <a class="reference internal" href="../library/tkinter.ttk.html#module-tkinter.ttk" title="tkinter.ttk: Tk themed widget set"><code class="xref py py-mod docutils literal notranslate"><span class="pre">tkinter.ttk</span></code></a> instead.</p>
|
||
</div>
|
||
<div class="section" id="id8">
|
||
<h4>venv<a class="headerlink" href="#id8" title="Permalink to this headline">¶</a></h4>
|
||
<p>The <code class="docutils literal notranslate"><span class="pre">pyvenv</span></code> script has been deprecated in favour of <code class="docutils literal notranslate"><span class="pre">python3</span> <span class="pre">-m</span> <span class="pre">venv</span></code>.
|
||
This prevents confusion as to what Python interpreter <code class="docutils literal notranslate"><span class="pre">pyvenv</span></code> is
|
||
connected to and thus what Python interpreter will be used by the virtual
|
||
environment. (Contributed by Brett Cannon in <a class="reference external" href="https://bugs.python.org/issue25154">bpo-25154</a>.)</p>
|
||
</div>
|
||
</div>
|
||
<div class="section" id="deprecated-functions-and-types-of-the-c-api">
|
||
<h3>Deprecated functions and types of the C API<a class="headerlink" href="#deprecated-functions-and-types-of-the-c-api" title="Permalink to this headline">¶</a></h3>
|
||
<p>Undocumented functions <code class="xref c c-func docutils literal notranslate"><span class="pre">PyUnicode_AsEncodedObject()</span></code>,
|
||
<code class="xref c c-func docutils literal notranslate"><span class="pre">PyUnicode_AsDecodedObject()</span></code>, <code class="xref c c-func docutils literal notranslate"><span class="pre">PyUnicode_AsEncodedUnicode()</span></code>
|
||
and <code class="xref c c-func docutils literal notranslate"><span class="pre">PyUnicode_AsDecodedUnicode()</span></code> are deprecated now.
|
||
Use the <a class="reference internal" href="../c-api/codec.html#codec-registry"><span class="std std-ref">generic codec based API</span></a> instead.</p>
|
||
</div>
|
||
<div class="section" id="deprecated-build-options">
|
||
<h3>Deprecated Build Options<a class="headerlink" href="#deprecated-build-options" title="Permalink to this headline">¶</a></h3>
|
||
<p>The <code class="docutils literal notranslate"><span class="pre">--with-system-ffi</span></code> configure flag is now on by default on non-macOS
|
||
UNIX platforms. It may be disabled by using <code class="docutils literal notranslate"><span class="pre">--without-system-ffi</span></code>, but
|
||
using the flag is deprecated and will not be accepted in Python 3.7.
|
||
macOS is unaffected by this change. Note that many OS distributors already
|
||
use the <code class="docutils literal notranslate"><span class="pre">--with-system-ffi</span></code> flag when building their system Python.</p>
|
||
</div>
|
||
</div>
|
||
<div class="section" id="removed">
|
||
<h2>Removed<a class="headerlink" href="#removed" title="Permalink to this headline">¶</a></h2>
|
||
<div class="section" id="api-and-feature-removals">
|
||
<h3>API and Feature Removals<a class="headerlink" href="#api-and-feature-removals" title="Permalink to this headline">¶</a></h3>
|
||
<ul class="simple">
|
||
<li><p>Unknown escapes consisting of <code class="docutils literal notranslate"><span class="pre">'\'</span></code> and an ASCII letter in
|
||
regular expressions will now cause an error. In replacement templates for
|
||
<a class="reference internal" href="../library/re.html#re.sub" title="re.sub"><code class="xref py py-func docutils literal notranslate"><span class="pre">re.sub()</span></code></a> they are still allowed, but deprecated.
|
||
The <a class="reference internal" href="../library/re.html#re.LOCALE" title="re.LOCALE"><code class="xref py py-const docutils literal notranslate"><span class="pre">re.LOCALE</span></code></a> flag can now only be used with binary patterns.</p></li>
|
||
<li><p><code class="docutils literal notranslate"><span class="pre">inspect.getmoduleinfo()</span></code> was removed (was deprecated since CPython 3.3).
|
||
<a class="reference internal" href="../library/inspect.html#inspect.getmodulename" title="inspect.getmodulename"><code class="xref py py-func docutils literal notranslate"><span class="pre">inspect.getmodulename()</span></code></a> should be used for obtaining the module
|
||
name for a given path.
|
||
(Contributed by Yury Selivanov in <a class="reference external" href="https://bugs.python.org/issue13248">bpo-13248</a>.)</p></li>
|
||
<li><p><code class="docutils literal notranslate"><span class="pre">traceback.Ignore</span></code> class and <code class="docutils literal notranslate"><span class="pre">traceback.usage</span></code>, <code class="docutils literal notranslate"><span class="pre">traceback.modname</span></code>,
|
||
<code class="docutils literal notranslate"><span class="pre">traceback.fullmodname</span></code>, <code class="docutils literal notranslate"><span class="pre">traceback.find_lines_from_code</span></code>,
|
||
<code class="docutils literal notranslate"><span class="pre">traceback.find_lines</span></code>, <code class="docutils literal notranslate"><span class="pre">traceback.find_strings</span></code>,
|
||
<code class="docutils literal notranslate"><span class="pre">traceback.find_executable_lines</span></code> methods were removed from the
|
||
<a class="reference internal" href="../library/traceback.html#module-traceback" title="traceback: Print or retrieve a stack traceback."><code class="xref py py-mod docutils literal notranslate"><span class="pre">traceback</span></code></a> module. They were undocumented methods deprecated since
|
||
Python 3.2 and equivalent functionality is available from private methods.</p></li>
|
||
<li><p>The <code class="docutils literal notranslate"><span class="pre">tk_menuBar()</span></code> and <code class="docutils literal notranslate"><span class="pre">tk_bindForTraversal()</span></code> dummy methods in
|
||
<a class="reference internal" href="../library/tkinter.html#module-tkinter" title="tkinter: Interface to Tcl/Tk for graphical user interfaces"><code class="xref py py-mod docutils literal notranslate"><span class="pre">tkinter</span></code></a> widget classes were removed (corresponding Tk commands
|
||
were obsolete since Tk 4.0).</p></li>
|
||
<li><p>The <a class="reference internal" href="../library/zipfile.html#zipfile.ZipFile.open" title="zipfile.ZipFile.open"><code class="xref py py-meth docutils literal notranslate"><span class="pre">open()</span></code></a> method of the <a class="reference internal" href="../library/zipfile.html#zipfile.ZipFile" title="zipfile.ZipFile"><code class="xref py py-class docutils literal notranslate"><span class="pre">zipfile.ZipFile</span></code></a>
|
||
class no longer supports the <code class="docutils literal notranslate"><span class="pre">'U'</span></code> mode (was deprecated since Python 3.4).
|
||
Use <a class="reference internal" href="../library/io.html#io.TextIOWrapper" title="io.TextIOWrapper"><code class="xref py py-class docutils literal notranslate"><span class="pre">io.TextIOWrapper</span></code></a> for reading compressed text files in
|
||
<a class="reference internal" href="../glossary.html#term-universal-newlines"><span class="xref std std-term">universal newlines</span></a> mode.</p></li>
|
||
<li><p>The undocumented <code class="docutils literal notranslate"><span class="pre">IN</span></code>, <code class="docutils literal notranslate"><span class="pre">CDROM</span></code>, <code class="docutils literal notranslate"><span class="pre">DLFCN</span></code>, <code class="docutils literal notranslate"><span class="pre">TYPES</span></code>, <code class="docutils literal notranslate"><span class="pre">CDIO</span></code>, and
|
||
<code class="docutils literal notranslate"><span class="pre">STROPTS</span></code> modules have been removed. They had been available in the
|
||
platform specific <code class="docutils literal notranslate"><span class="pre">Lib/plat-*/</span></code> directories, but were chronically out of
|
||
date, inconsistently available across platforms, and unmaintained. The
|
||
script that created these modules is still available in the source
|
||
distribution at <a class="reference external" href="https://github.com/python/cpython/tree/3.7/Tools/scripts/h2py.py">Tools/scripts/h2py.py</a>.</p></li>
|
||
<li><p>The deprecated <code class="docutils literal notranslate"><span class="pre">asynchat.fifo</span></code> class has been removed.</p></li>
|
||
</ul>
|
||
</div>
|
||
</div>
|
||
<div class="section" id="porting-to-python-3-6">
|
||
<h2>Porting to Python 3.6<a class="headerlink" href="#porting-to-python-3-6" title="Permalink to this headline">¶</a></h2>
|
||
<p>This section lists previously described changes and other bugfixes
|
||
that may require changes to your code.</p>
|
||
<div class="section" id="changes-in-python-command-behavior">
|
||
<h3>Changes in ‘python’ Command Behavior<a class="headerlink" href="#changes-in-python-command-behavior" title="Permalink to this headline">¶</a></h3>
|
||
<ul class="simple">
|
||
<li><p>The output of a special Python build with defined <code class="docutils literal notranslate"><span class="pre">COUNT_ALLOCS</span></code>,
|
||
<code class="docutils literal notranslate"><span class="pre">SHOW_ALLOC_COUNT</span></code> or <code class="docutils literal notranslate"><span class="pre">SHOW_TRACK_COUNT</span></code> macros is now off by
|
||
default. It can be re-enabled using the <code class="docutils literal notranslate"><span class="pre">-X</span> <span class="pre">showalloccount</span></code> option.
|
||
It now outputs to <code class="docutils literal notranslate"><span class="pre">stderr</span></code> instead of <code class="docutils literal notranslate"><span class="pre">stdout</span></code>.
|
||
(Contributed by Serhiy Storchaka in <a class="reference external" href="https://bugs.python.org/issue23034">bpo-23034</a>.)</p></li>
|
||
</ul>
|
||
</div>
|
||
<div class="section" id="changes-in-the-python-api">
|
||
<h3>Changes in the Python API<a class="headerlink" href="#changes-in-the-python-api" title="Permalink to this headline">¶</a></h3>
|
||
<ul>
|
||
<li><p><a class="reference internal" href="../library/functions.html#open" title="open"><code class="xref py py-func docutils literal notranslate"><span class="pre">open()</span></code></a> will no longer allow combining the <code class="docutils literal notranslate"><span class="pre">'U'</span></code> mode flag
|
||
with <code class="docutils literal notranslate"><span class="pre">'+'</span></code>.
|
||
(Contributed by Jeff Balogh and John O’Connor in <a class="reference external" href="https://bugs.python.org/issue2091">bpo-2091</a>.)</p></li>
|
||
<li><p><a class="reference internal" href="../library/sqlite3.html#module-sqlite3" title="sqlite3: A DB-API 2.0 implementation using SQLite 3.x."><code class="xref py py-mod docutils literal notranslate"><span class="pre">sqlite3</span></code></a> no longer implicitly commits an open transaction before DDL
|
||
statements.</p></li>
|
||
<li><p>On Linux, <a class="reference internal" href="../library/os.html#os.urandom" title="os.urandom"><code class="xref py py-func docutils literal notranslate"><span class="pre">os.urandom()</span></code></a> now blocks until the system urandom entropy pool
|
||
is initialized to increase the security.</p></li>
|
||
<li><p>When <a class="reference internal" href="../library/importlib.html#importlib.abc.Loader.exec_module" title="importlib.abc.Loader.exec_module"><code class="xref py py-meth docutils literal notranslate"><span class="pre">importlib.abc.Loader.exec_module()</span></code></a> is defined,
|
||
<a class="reference internal" href="../library/importlib.html#importlib.abc.Loader.create_module" title="importlib.abc.Loader.create_module"><code class="xref py py-meth docutils literal notranslate"><span class="pre">importlib.abc.Loader.create_module()</span></code></a> must also be defined.</p></li>
|
||
<li><p><a class="reference internal" href="../c-api/exceptions.html#c.PyErr_SetImportError" title="PyErr_SetImportError"><code class="xref c c-func docutils literal notranslate"><span class="pre">PyErr_SetImportError()</span></code></a> now sets <a class="reference internal" href="../library/exceptions.html#TypeError" title="TypeError"><code class="xref py py-exc docutils literal notranslate"><span class="pre">TypeError</span></code></a> when its <strong>msg</strong>
|
||
argument is not set. Previously only <code class="docutils literal notranslate"><span class="pre">NULL</span></code> was returned.</p></li>
|
||
<li><p>The format of the <code class="docutils literal notranslate"><span class="pre">co_lnotab</span></code> attribute of code objects changed to support
|
||
a negative line number delta. By default, Python does not emit bytecode with
|
||
a negative line number delta. Functions using <code class="docutils literal notranslate"><span class="pre">frame.f_lineno</span></code>,
|
||
<code class="docutils literal notranslate"><span class="pre">PyFrame_GetLineNumber()</span></code> or <code class="docutils literal notranslate"><span class="pre">PyCode_Addr2Line()</span></code> are not affected.
|
||
Functions directly decoding <code class="docutils literal notranslate"><span class="pre">co_lnotab</span></code> should be updated to use a signed
|
||
8-bit integer type for the line number delta, but this is only required to
|
||
support applications using a negative line number delta. See
|
||
<code class="docutils literal notranslate"><span class="pre">Objects/lnotab_notes.txt</span></code> for the <code class="docutils literal notranslate"><span class="pre">co_lnotab</span></code> format and how to decode
|
||
it, and see the <span class="target" id="index-36"></span><a class="pep reference external" href="https://www.python.org/dev/peps/pep-0511"><strong>PEP 511</strong></a> for the rationale.</p></li>
|
||
<li><p>The functions in the <a class="reference internal" href="../library/compileall.html#module-compileall" title="compileall: Tools for byte-compiling all Python source files in a directory tree."><code class="xref py py-mod docutils literal notranslate"><span class="pre">compileall</span></code></a> module now return booleans instead
|
||
of <code class="docutils literal notranslate"><span class="pre">1</span></code> or <code class="docutils literal notranslate"><span class="pre">0</span></code> to represent success or failure, respectively. Thanks to
|
||
booleans being a subclass of integers, this should only be an issue if you
|
||
were doing identity checks for <code class="docutils literal notranslate"><span class="pre">1</span></code> or <code class="docutils literal notranslate"><span class="pre">0</span></code>. See <a class="reference external" href="https://bugs.python.org/issue25768">bpo-25768</a>.</p></li>
|
||
<li><p>Reading the <code class="xref py py-attr docutils literal notranslate"><span class="pre">port</span></code> attribute of
|
||
<a class="reference internal" href="../library/urllib.parse.html#urllib.parse.urlsplit" title="urllib.parse.urlsplit"><code class="xref py py-func docutils literal notranslate"><span class="pre">urllib.parse.urlsplit()</span></code></a> and <a class="reference internal" href="../library/urllib.parse.html#urllib.parse.urlparse" title="urllib.parse.urlparse"><code class="xref py py-func docutils literal notranslate"><span class="pre">urlparse()</span></code></a> results
|
||
now raises <a class="reference internal" href="../library/exceptions.html#ValueError" title="ValueError"><code class="xref py py-exc docutils literal notranslate"><span class="pre">ValueError</span></code></a> for out-of-range values, rather than
|
||
returning <a class="reference internal" href="../library/constants.html#None" title="None"><code class="xref py py-const docutils literal notranslate"><span class="pre">None</span></code></a>. See <a class="reference external" href="https://bugs.python.org/issue20059">bpo-20059</a>.</p></li>
|
||
<li><p>The <a class="reference internal" href="../library/imp.html#module-imp" title="imp: Access the implementation of the import statement. (deprecated)"><code class="xref py py-mod docutils literal notranslate"><span class="pre">imp</span></code></a> module now raises a <a class="reference internal" href="../library/exceptions.html#DeprecationWarning" title="DeprecationWarning"><code class="xref py py-exc docutils literal notranslate"><span class="pre">DeprecationWarning</span></code></a> instead of
|
||
<a class="reference internal" href="../library/exceptions.html#PendingDeprecationWarning" title="PendingDeprecationWarning"><code class="xref py py-exc docutils literal notranslate"><span class="pre">PendingDeprecationWarning</span></code></a>.</p></li>
|
||
<li><p>The following modules have had missing APIs added to their <code class="xref py py-attr docutils literal notranslate"><span class="pre">__all__</span></code>
|
||
attributes to match the documented APIs:
|
||
<a class="reference internal" href="../library/calendar.html#module-calendar" title="calendar: Functions for working with calendars, including some emulation of the Unix cal program."><code class="xref py py-mod docutils literal notranslate"><span class="pre">calendar</span></code></a>, <a class="reference internal" href="../library/cgi.html#module-cgi" title="cgi: Helpers for running Python scripts via the Common Gateway Interface."><code class="xref py py-mod docutils literal notranslate"><span class="pre">cgi</span></code></a>, <a class="reference internal" href="../library/csv.html#module-csv" title="csv: Write and read tabular data to and from delimited files."><code class="xref py py-mod docutils literal notranslate"><span class="pre">csv</span></code></a>,
|
||
<a class="reference internal" href="../library/xml.etree.elementtree.html#module-xml.etree.ElementTree" title="xml.etree.ElementTree: Implementation of the ElementTree API."><code class="xref py py-mod docutils literal notranslate"><span class="pre">ElementTree</span></code></a>, <a class="reference internal" href="../library/enum.html#module-enum" title="enum: Implementation of an enumeration class."><code class="xref py py-mod docutils literal notranslate"><span class="pre">enum</span></code></a>,
|
||
<a class="reference internal" href="../library/fileinput.html#module-fileinput" title="fileinput: Loop over standard input or a list of files."><code class="xref py py-mod docutils literal notranslate"><span class="pre">fileinput</span></code></a>, <a class="reference internal" href="../library/ftplib.html#module-ftplib" title="ftplib: FTP protocol client (requires sockets)."><code class="xref py py-mod docutils literal notranslate"><span class="pre">ftplib</span></code></a>, <a class="reference internal" href="../library/logging.html#module-logging" title="logging: Flexible event logging system for applications."><code class="xref py py-mod docutils literal notranslate"><span class="pre">logging</span></code></a>, <a class="reference internal" href="../library/mailbox.html#module-mailbox" title="mailbox: Manipulate mailboxes in various formats"><code class="xref py py-mod docutils literal notranslate"><span class="pre">mailbox</span></code></a>,
|
||
<a class="reference internal" href="../library/mimetypes.html#module-mimetypes" title="mimetypes: Mapping of filename extensions to MIME types."><code class="xref py py-mod docutils literal notranslate"><span class="pre">mimetypes</span></code></a>, <a class="reference internal" href="../library/optparse.html#module-optparse" title="optparse: Command-line option parsing library. (deprecated)"><code class="xref py py-mod docutils literal notranslate"><span class="pre">optparse</span></code></a>, <a class="reference internal" href="../library/plistlib.html#module-plistlib" title="plistlib: Generate and parse Mac OS X plist files."><code class="xref py py-mod docutils literal notranslate"><span class="pre">plistlib</span></code></a>, <a class="reference internal" href="../library/smtpd.html#module-smtpd" title="smtpd: A SMTP server implementation in Python."><code class="xref py py-mod docutils literal notranslate"><span class="pre">smtpd</span></code></a>,
|
||
<a class="reference internal" href="../library/subprocess.html#module-subprocess" title="subprocess: Subprocess management."><code class="xref py py-mod docutils literal notranslate"><span class="pre">subprocess</span></code></a>, <a class="reference internal" href="../library/tarfile.html#module-tarfile" title="tarfile: Read and write tar-format archive files."><code class="xref py py-mod docutils literal notranslate"><span class="pre">tarfile</span></code></a>, <a class="reference internal" href="../library/threading.html#module-threading" title="threading: Thread-based parallelism."><code class="xref py py-mod docutils literal notranslate"><span class="pre">threading</span></code></a> and
|
||
<a class="reference internal" href="../library/wave.html#module-wave" title="wave: Provide an interface to the WAV sound format."><code class="xref py py-mod docutils literal notranslate"><span class="pre">wave</span></code></a>. This means they will export new symbols when <code class="docutils literal notranslate"><span class="pre">import</span> <span class="pre">*</span></code>
|
||
is used.
|
||
(Contributed by Joel Taddei and Jacek Kołodziej in <a class="reference external" href="https://bugs.python.org/issue23883">bpo-23883</a>.)</p></li>
|
||
<li><p>When performing a relative import, if <code class="docutils literal notranslate"><span class="pre">__package__</span></code> does not compare equal
|
||
to <code class="docutils literal notranslate"><span class="pre">__spec__.parent</span></code> then <a class="reference internal" href="../library/exceptions.html#ImportWarning" title="ImportWarning"><code class="xref py py-exc docutils literal notranslate"><span class="pre">ImportWarning</span></code></a> is raised.
|
||
(Contributed by Brett Cannon in <a class="reference external" href="https://bugs.python.org/issue25791">bpo-25791</a>.)</p></li>
|
||
<li><p>When a relative import is performed and no parent package is known, then
|
||
<a class="reference internal" href="../library/exceptions.html#ImportError" title="ImportError"><code class="xref py py-exc docutils literal notranslate"><span class="pre">ImportError</span></code></a> will be raised. Previously, <a class="reference internal" href="../library/exceptions.html#SystemError" title="SystemError"><code class="xref py py-exc docutils literal notranslate"><span class="pre">SystemError</span></code></a> could be
|
||
raised. (Contributed by Brett Cannon in <a class="reference external" href="https://bugs.python.org/issue18018">bpo-18018</a>.)</p></li>
|
||
<li><p>Servers based on the <a class="reference internal" href="../library/socketserver.html#module-socketserver" title="socketserver: A framework for network servers."><code class="xref py py-mod docutils literal notranslate"><span class="pre">socketserver</span></code></a> module, including those
|
||
defined in <a class="reference internal" href="../library/http.server.html#module-http.server" title="http.server: HTTP server and request handlers."><code class="xref py py-mod docutils literal notranslate"><span class="pre">http.server</span></code></a>, <a class="reference internal" href="../library/xmlrpc.server.html#module-xmlrpc.server" title="xmlrpc.server: Basic XML-RPC server implementations."><code class="xref py py-mod docutils literal notranslate"><span class="pre">xmlrpc.server</span></code></a> and
|
||
<a class="reference internal" href="../library/wsgiref.html#module-wsgiref.simple_server" title="wsgiref.simple_server: A simple WSGI HTTP server."><code class="xref py py-mod docutils literal notranslate"><span class="pre">wsgiref.simple_server</span></code></a>, now only catch exceptions derived
|
||
from <a class="reference internal" href="../library/exceptions.html#Exception" title="Exception"><code class="xref py py-exc docutils literal notranslate"><span class="pre">Exception</span></code></a>. Therefore if a request handler raises
|
||
an exception like <a class="reference internal" href="../library/exceptions.html#SystemExit" title="SystemExit"><code class="xref py py-exc docutils literal notranslate"><span class="pre">SystemExit</span></code></a> or <a class="reference internal" href="../library/exceptions.html#KeyboardInterrupt" title="KeyboardInterrupt"><code class="xref py py-exc docutils literal notranslate"><span class="pre">KeyboardInterrupt</span></code></a>,
|
||
<a class="reference internal" href="../library/socketserver.html#socketserver.BaseServer.handle_error" title="socketserver.BaseServer.handle_error"><code class="xref py py-meth docutils literal notranslate"><span class="pre">handle_error()</span></code></a> is no longer called, and
|
||
the exception will stop a single-threaded server. (Contributed by
|
||
Martin Panter in <a class="reference external" href="https://bugs.python.org/issue23430">bpo-23430</a>.)</p></li>
|
||
<li><p><a class="reference internal" href="../library/spwd.html#spwd.getspnam" title="spwd.getspnam"><code class="xref py py-func docutils literal notranslate"><span class="pre">spwd.getspnam()</span></code></a> now raises a <a class="reference internal" href="../library/exceptions.html#PermissionError" title="PermissionError"><code class="xref py py-exc docutils literal notranslate"><span class="pre">PermissionError</span></code></a> instead of
|
||
<a class="reference internal" href="../library/exceptions.html#KeyError" title="KeyError"><code class="xref py py-exc docutils literal notranslate"><span class="pre">KeyError</span></code></a> if the user doesn’t have privileges.</p></li>
|
||
<li><p>The <a class="reference internal" href="../library/socket.html#socket.socket.close" title="socket.socket.close"><code class="xref py py-meth docutils literal notranslate"><span class="pre">socket.socket.close()</span></code></a> method now raises an exception if
|
||
an error (e.g. <code class="docutils literal notranslate"><span class="pre">EBADF</span></code>) was reported by the underlying system call.
|
||
(Contributed by Martin Panter in <a class="reference external" href="https://bugs.python.org/issue26685">bpo-26685</a>.)</p></li>
|
||
<li><p>The <em>decode_data</em> argument for the <a class="reference internal" href="../library/smtpd.html#smtpd.SMTPChannel" title="smtpd.SMTPChannel"><code class="xref py py-class docutils literal notranslate"><span class="pre">smtpd.SMTPChannel</span></code></a> and
|
||
<a class="reference internal" href="../library/smtpd.html#smtpd.SMTPServer" title="smtpd.SMTPServer"><code class="xref py py-class docutils literal notranslate"><span class="pre">smtpd.SMTPServer</span></code></a> constructors is now <code class="docutils literal notranslate"><span class="pre">False</span></code> by default.
|
||
This means that the argument passed to
|
||
<a class="reference internal" href="../library/smtpd.html#smtpd.SMTPServer.process_message" title="smtpd.SMTPServer.process_message"><code class="xref py py-meth docutils literal notranslate"><span class="pre">process_message()</span></code></a> is now a bytes object by
|
||
default, and <code class="docutils literal notranslate"><span class="pre">process_message()</span></code> will be passed keyword arguments.
|
||
Code that has already been updated in accordance with the deprecation
|
||
warning generated by 3.5 will not be affected.</p></li>
|
||
<li><p>All optional arguments of the <a class="reference internal" href="../library/json.html#json.dump" title="json.dump"><code class="xref py py-func docutils literal notranslate"><span class="pre">dump()</span></code></a>, <a class="reference internal" href="../library/json.html#json.dumps" title="json.dumps"><code class="xref py py-func docutils literal notranslate"><span class="pre">dumps()</span></code></a>,
|
||
<a class="reference internal" href="../library/json.html#json.load" title="json.load"><code class="xref py py-func docutils literal notranslate"><span class="pre">load()</span></code></a> and <a class="reference internal" href="../library/json.html#json.loads" title="json.loads"><code class="xref py py-func docutils literal notranslate"><span class="pre">loads()</span></code></a> functions and
|
||
<a class="reference internal" href="../library/json.html#json.JSONEncoder" title="json.JSONEncoder"><code class="xref py py-class docutils literal notranslate"><span class="pre">JSONEncoder</span></code></a> and <a class="reference internal" href="../library/json.html#json.JSONDecoder" title="json.JSONDecoder"><code class="xref py py-class docutils literal notranslate"><span class="pre">JSONDecoder</span></code></a> class
|
||
constructors in the <a class="reference internal" href="../library/json.html#module-json" title="json: Encode and decode the JSON format."><code class="xref py py-mod docutils literal notranslate"><span class="pre">json</span></code></a> module are now <a class="reference internal" href="../glossary.html#keyword-only-parameter"><span class="std std-ref">keyword-only</span></a>.
|
||
(Contributed by Serhiy Storchaka in <a class="reference external" href="https://bugs.python.org/issue18726">bpo-18726</a>.)</p></li>
|
||
<li><p>Subclasses of <a class="reference internal" href="../library/functions.html#type" title="type"><code class="xref py py-class docutils literal notranslate"><span class="pre">type</span></code></a> which don’t override <code class="docutils literal notranslate"><span class="pre">type.__new__</span></code> may no
|
||
longer use the one-argument form to get the type of an object.</p></li>
|
||
<li><p>As part of <span class="target" id="index-37"></span><a class="pep reference external" href="https://www.python.org/dev/peps/pep-0487"><strong>PEP 487</strong></a>, the handling of keyword arguments passed to
|
||
<a class="reference internal" href="../library/functions.html#type" title="type"><code class="xref py py-class docutils literal notranslate"><span class="pre">type</span></code></a> (other than the metaclass hint, <code class="docutils literal notranslate"><span class="pre">metaclass</span></code>) is now
|
||
consistently delegated to <a class="reference internal" href="../reference/datamodel.html#object.__init_subclass__" title="object.__init_subclass__"><code class="xref py py-meth docutils literal notranslate"><span class="pre">object.__init_subclass__()</span></code></a>. This means that
|
||
<code class="xref py py-meth docutils literal notranslate"><span class="pre">type.__new__()</span></code> and <code class="xref py py-meth docutils literal notranslate"><span class="pre">type.__init__()</span></code> both now accept arbitrary
|
||
keyword arguments, but <a class="reference internal" href="../reference/datamodel.html#object.__init_subclass__" title="object.__init_subclass__"><code class="xref py py-meth docutils literal notranslate"><span class="pre">object.__init_subclass__()</span></code></a> (which is called from
|
||
<code class="xref py py-meth docutils literal notranslate"><span class="pre">type.__new__()</span></code>) will reject them by default. Custom metaclasses
|
||
accepting additional keyword arguments will need to adjust their calls to
|
||
<code class="xref py py-meth docutils literal notranslate"><span class="pre">type.__new__()</span></code> (whether direct or via <a class="reference internal" href="../library/functions.html#super" title="super"><code class="xref py py-class docutils literal notranslate"><span class="pre">super</span></code></a>) accordingly.</p></li>
|
||
<li><p>In <code class="xref py py-class docutils literal notranslate"><span class="pre">distutils.command.sdist.sdist</span></code>, the <code class="docutils literal notranslate"><span class="pre">default_format</span></code>
|
||
attribute has been removed and is no longer honored. Instead, the
|
||
gzipped tarfile format is the default on all platforms and no
|
||
platform-specific selection is made.
|
||
In environments where distributions are
|
||
built on Windows and zip distributions are required, configure
|
||
the project with a <code class="docutils literal notranslate"><span class="pre">setup.cfg</span></code> file containing the following:</p>
|
||
<div class="highlight-ini notranslate"><div class="highlight"><pre><span></span><span class="k">[sdist]</span>
|
||
<span class="na">formats</span><span class="o">=</span><span class="s">zip</span>
|
||
</pre></div>
|
||
</div>
|
||
<p>This behavior has also been backported to earlier Python versions
|
||
by Setuptools 26.0.0.</p>
|
||
</li>
|
||
<li><p>In the <a class="reference internal" href="../library/urllib.request.html#module-urllib.request" title="urllib.request: Extensible library for opening URLs."><code class="xref py py-mod docutils literal notranslate"><span class="pre">urllib.request</span></code></a> module and the
|
||
<a class="reference internal" href="../library/http.client.html#http.client.HTTPConnection.request" title="http.client.HTTPConnection.request"><code class="xref py py-meth docutils literal notranslate"><span class="pre">http.client.HTTPConnection.request()</span></code></a> method, if no Content-Length
|
||
header field has been specified and the request body is a file object,
|
||
it is now sent with HTTP 1.1 chunked encoding. If a file object has to
|
||
be sent to a HTTP 1.0 server, the Content-Length value now has to be
|
||
specified by the caller.
|
||
(Contributed by Demian Brecht and Rolf Krahl with tweaks from
|
||
Martin Panter in <a class="reference external" href="https://bugs.python.org/issue12319">bpo-12319</a>.)</p></li>
|
||
<li><p>The <a class="reference internal" href="../library/csv.html#csv.DictReader" title="csv.DictReader"><code class="xref py py-class docutils literal notranslate"><span class="pre">DictReader</span></code></a> now returns rows of type
|
||
<a class="reference internal" href="../library/collections.html#collections.OrderedDict" title="collections.OrderedDict"><code class="xref py py-class docutils literal notranslate"><span class="pre">OrderedDict</span></code></a>.
|
||
(Contributed by Steve Holden in <a class="reference external" href="https://bugs.python.org/issue27842">bpo-27842</a>.)</p></li>
|
||
<li><p>The <a class="reference internal" href="../library/crypt.html#crypt.METHOD_CRYPT" title="crypt.METHOD_CRYPT"><code class="xref py py-const docutils literal notranslate"><span class="pre">crypt.METHOD_CRYPT</span></code></a> will no longer be added to <code class="docutils literal notranslate"><span class="pre">crypt.methods</span></code>
|
||
if unsupported by the platform.
|
||
(Contributed by Victor Stinner in <a class="reference external" href="https://bugs.python.org/issue25287">bpo-25287</a>.)</p></li>
|
||
<li><p>The <em>verbose</em> and <em>rename</em> arguments for
|
||
<a class="reference internal" href="../library/collections.html#collections.namedtuple" title="collections.namedtuple"><code class="xref py py-func docutils literal notranslate"><span class="pre">namedtuple()</span></code></a> are now keyword-only.
|
||
(Contributed by Raymond Hettinger in <a class="reference external" href="https://bugs.python.org/issue25628">bpo-25628</a>.)</p></li>
|
||
<li><p>On Linux, <a class="reference internal" href="../library/ctypes.html#ctypes.util.find_library" title="ctypes.util.find_library"><code class="xref py py-func docutils literal notranslate"><span class="pre">ctypes.util.find_library()</span></code></a> now looks in
|
||
<code class="docutils literal notranslate"><span class="pre">LD_LIBRARY_PATH</span></code> for shared libraries.
|
||
(Contributed by Vinay Sajip in <a class="reference external" href="https://bugs.python.org/issue9998">bpo-9998</a>.)</p></li>
|
||
<li><p>The <a class="reference internal" href="../library/imaplib.html#imaplib.IMAP4" title="imaplib.IMAP4"><code class="xref py py-class docutils literal notranslate"><span class="pre">imaplib.IMAP4</span></code></a> class now handles flags containing the
|
||
<code class="docutils literal notranslate"><span class="pre">']'</span></code> character in messages sent from the server to improve
|
||
real-world compatibility.
|
||
(Contributed by Lita Cho in <a class="reference external" href="https://bugs.python.org/issue21815">bpo-21815</a>.)</p></li>
|
||
<li><p>The <code class="xref py py-func docutils literal notranslate"><span class="pre">mmap.write()</span></code> function now returns the number
|
||
of bytes written like other write methods.
|
||
(Contributed by Jakub Stasiak in <a class="reference external" href="https://bugs.python.org/issue26335">bpo-26335</a>.)</p></li>
|
||
<li><p>The <a class="reference internal" href="../library/pkgutil.html#pkgutil.iter_modules" title="pkgutil.iter_modules"><code class="xref py py-func docutils literal notranslate"><span class="pre">pkgutil.iter_modules()</span></code></a> and <a class="reference internal" href="../library/pkgutil.html#pkgutil.walk_packages" title="pkgutil.walk_packages"><code class="xref py py-func docutils literal notranslate"><span class="pre">pkgutil.walk_packages()</span></code></a>
|
||
functions now return <a class="reference internal" href="../library/pkgutil.html#pkgutil.ModuleInfo" title="pkgutil.ModuleInfo"><code class="xref py py-class docutils literal notranslate"><span class="pre">ModuleInfo</span></code></a> named tuples.
|
||
(Contributed by Ramchandra Apte in <a class="reference external" href="https://bugs.python.org/issue17211">bpo-17211</a>.)</p></li>
|
||
<li><p><a class="reference internal" href="../library/re.html#re.sub" title="re.sub"><code class="xref py py-func docutils literal notranslate"><span class="pre">re.sub()</span></code></a> now raises an error for invalid numerical group
|
||
references in replacement templates even if the pattern is not
|
||
found in the string. The error message for invalid group references
|
||
now includes the group index and the position of the reference.
|
||
(Contributed by SilentGhost, Serhiy Storchaka in <a class="reference external" href="https://bugs.python.org/issue25953">bpo-25953</a>.)</p></li>
|
||
<li><p><a class="reference internal" href="../library/zipfile.html#zipfile.ZipFile" title="zipfile.ZipFile"><code class="xref py py-class docutils literal notranslate"><span class="pre">zipfile.ZipFile</span></code></a> will now raise <a class="reference internal" href="../library/exceptions.html#NotImplementedError" title="NotImplementedError"><code class="xref py py-exc docutils literal notranslate"><span class="pre">NotImplementedError</span></code></a> for
|
||
unrecognized compression values. Previously a plain <a class="reference internal" href="../library/exceptions.html#RuntimeError" title="RuntimeError"><code class="xref py py-exc docutils literal notranslate"><span class="pre">RuntimeError</span></code></a>
|
||
was raised. Additionally, calling <a class="reference internal" href="../library/zipfile.html#zipfile.ZipFile" title="zipfile.ZipFile"><code class="xref py py-class docutils literal notranslate"><span class="pre">ZipFile</span></code></a> methods
|
||
on a closed ZipFile or calling the <a class="reference internal" href="../library/zipfile.html#zipfile.ZipFile.write" title="zipfile.ZipFile.write"><code class="xref py py-meth docutils literal notranslate"><span class="pre">write()</span></code></a> method
|
||
on a ZipFile created with mode <code class="docutils literal notranslate"><span class="pre">'r'</span></code> will raise a <a class="reference internal" href="../library/exceptions.html#ValueError" title="ValueError"><code class="xref py py-exc docutils literal notranslate"><span class="pre">ValueError</span></code></a>.
|
||
Previously, a <a class="reference internal" href="../library/exceptions.html#RuntimeError" title="RuntimeError"><code class="xref py py-exc docutils literal notranslate"><span class="pre">RuntimeError</span></code></a> was raised in those scenarios.</p></li>
|
||
<li><p>when custom metaclasses are combined with zero-argument <a class="reference internal" href="../library/functions.html#super" title="super"><code class="xref py py-func docutils literal notranslate"><span class="pre">super()</span></code></a> or
|
||
direct references from methods to the implicit <code class="docutils literal notranslate"><span class="pre">__class__</span></code> closure
|
||
variable, the implicit <code class="docutils literal notranslate"><span class="pre">__classcell__</span></code> namespace entry must now be passed
|
||
up to <code class="docutils literal notranslate"><span class="pre">type.__new__</span></code> for initialisation. Failing to do so will result in
|
||
a <a class="reference internal" href="../library/exceptions.html#DeprecationWarning" title="DeprecationWarning"><code class="xref py py-exc docutils literal notranslate"><span class="pre">DeprecationWarning</span></code></a> in Python 3.6 and a <a class="reference internal" href="../library/exceptions.html#RuntimeError" title="RuntimeError"><code class="xref py py-exc docutils literal notranslate"><span class="pre">RuntimeError</span></code></a> in
|
||
Python 3.8.</p></li>
|
||
<li><p>With the introduction of <a class="reference internal" href="../library/exceptions.html#ModuleNotFoundError" title="ModuleNotFoundError"><code class="xref py py-exc docutils literal notranslate"><span class="pre">ModuleNotFoundError</span></code></a>, import system consumers
|
||
may start expecting import system replacements to raise that more specific
|
||
exception when appropriate, rather than the less-specific <a class="reference internal" href="../library/exceptions.html#ImportError" title="ImportError"><code class="xref py py-exc docutils literal notranslate"><span class="pre">ImportError</span></code></a>.
|
||
To provide future compatibility with such consumers, implementors of
|
||
alternative import systems that completely replace <a class="reference internal" href="../library/functions.html#__import__" title="__import__"><code class="xref py py-func docutils literal notranslate"><span class="pre">__import__()</span></code></a> will
|
||
need to update their implementations to raise the new subclass when a module
|
||
can’t be found at all. Implementors of compliant plugins to the default
|
||
import system shouldn’t need to make any changes, as the default import
|
||
system will raise the new subclass when appropriate.</p></li>
|
||
</ul>
|
||
</div>
|
||
<div class="section" id="changes-in-the-c-api">
|
||
<h3>Changes in the C API<a class="headerlink" href="#changes-in-the-c-api" title="Permalink to this headline">¶</a></h3>
|
||
<ul class="simple">
|
||
<li><p>The <a class="reference internal" href="../c-api/memory.html#c.PyMem_Malloc" title="PyMem_Malloc"><code class="xref c c-func docutils literal notranslate"><span class="pre">PyMem_Malloc()</span></code></a> allocator family now uses the <a class="reference internal" href="../c-api/memory.html#pymalloc"><span class="std std-ref">pymalloc allocator</span></a> rather than the system <code class="xref c c-func docutils literal notranslate"><span class="pre">malloc()</span></code>. Applications calling
|
||
<a class="reference internal" href="../c-api/memory.html#c.PyMem_Malloc" title="PyMem_Malloc"><code class="xref c c-func docutils literal notranslate"><span class="pre">PyMem_Malloc()</span></code></a> without holding the GIL can now crash. Set the
|
||
<span class="target" id="index-38"></span><a class="reference internal" href="../using/cmdline.html#envvar-PYTHONMALLOC"><code class="xref std std-envvar docutils literal notranslate"><span class="pre">PYTHONMALLOC</span></code></a> environment variable to <code class="docutils literal notranslate"><span class="pre">debug</span></code> to validate the
|
||
usage of memory allocators in your application. See <a class="reference external" href="https://bugs.python.org/issue26249">bpo-26249</a>.</p></li>
|
||
<li><p><a class="reference internal" href="../c-api/sys.html#c.Py_Exit" title="Py_Exit"><code class="xref c c-func docutils literal notranslate"><span class="pre">Py_Exit()</span></code></a> (and the main interpreter) now override the exit status
|
||
with 120 if flushing buffered data failed. See <a class="reference external" href="https://bugs.python.org/issue5319">bpo-5319</a>.</p></li>
|
||
</ul>
|
||
</div>
|
||
<div class="section" id="cpython-bytecode-changes">
|
||
<h3>CPython bytecode changes<a class="headerlink" href="#cpython-bytecode-changes" title="Permalink to this headline">¶</a></h3>
|
||
<p>There have been several major changes to the <a class="reference internal" href="../glossary.html#term-bytecode"><span class="xref std std-term">bytecode</span></a> in Python 3.6.</p>
|
||
<ul class="simple">
|
||
<li><p>The Python interpreter now uses a 16-bit wordcode instead of bytecode.
|
||
(Contributed by Demur Rumed with input and reviews from
|
||
Serhiy Storchaka and Victor Stinner in <a class="reference external" href="https://bugs.python.org/issue26647">bpo-26647</a> and <a class="reference external" href="https://bugs.python.org/issue28050">bpo-28050</a>.)</p></li>
|
||
<li><p>The new <a class="reference internal" href="../library/dis.html#opcode-FORMAT_VALUE"><code class="xref std std-opcode docutils literal notranslate"><span class="pre">FORMAT_VALUE</span></code></a> and <a class="reference internal" href="../library/dis.html#opcode-BUILD_STRING"><code class="xref std std-opcode docutils literal notranslate"><span class="pre">BUILD_STRING</span></code></a> opcodes as part
|
||
of the <a class="reference internal" href="#whatsnew36-pep498"><span class="std std-ref">formatted string literal</span></a> implementation.
|
||
(Contributed by Eric Smith in <a class="reference external" href="https://bugs.python.org/issue25483">bpo-25483</a> and
|
||
Serhiy Storchaka in <a class="reference external" href="https://bugs.python.org/issue27078">bpo-27078</a>.)</p></li>
|
||
<li><p>The new <a class="reference internal" href="../library/dis.html#opcode-BUILD_CONST_KEY_MAP"><code class="xref std std-opcode docutils literal notranslate"><span class="pre">BUILD_CONST_KEY_MAP</span></code></a> opcode to optimize the creation
|
||
of dictionaries with constant keys.
|
||
(Contributed by Serhiy Storchaka in <a class="reference external" href="https://bugs.python.org/issue27140">bpo-27140</a>.)</p></li>
|
||
<li><p>The function call opcodes have been heavily reworked for better performance
|
||
and simpler implementation.
|
||
The <a class="reference internal" href="../library/dis.html#opcode-MAKE_FUNCTION"><code class="xref std std-opcode docutils literal notranslate"><span class="pre">MAKE_FUNCTION</span></code></a>, <a class="reference internal" href="../library/dis.html#opcode-CALL_FUNCTION"><code class="xref std std-opcode docutils literal notranslate"><span class="pre">CALL_FUNCTION</span></code></a>,
|
||
<a class="reference internal" href="../library/dis.html#opcode-CALL_FUNCTION_KW"><code class="xref std std-opcode docutils literal notranslate"><span class="pre">CALL_FUNCTION_KW</span></code></a> and <a class="reference internal" href="../library/dis.html#opcode-BUILD_MAP_UNPACK_WITH_CALL"><code class="xref std std-opcode docutils literal notranslate"><span class="pre">BUILD_MAP_UNPACK_WITH_CALL</span></code></a> opcodes
|
||
have been modified, the new <a class="reference internal" href="../library/dis.html#opcode-CALL_FUNCTION_EX"><code class="xref std std-opcode docutils literal notranslate"><span class="pre">CALL_FUNCTION_EX</span></code></a> and
|
||
<a class="reference internal" href="../library/dis.html#opcode-BUILD_TUPLE_UNPACK_WITH_CALL"><code class="xref std std-opcode docutils literal notranslate"><span class="pre">BUILD_TUPLE_UNPACK_WITH_CALL</span></code></a> have been added, and
|
||
<code class="docutils literal notranslate"><span class="pre">CALL_FUNCTION_VAR</span></code>, <code class="docutils literal notranslate"><span class="pre">CALL_FUNCTION_VAR_KW</span></code> and <code class="docutils literal notranslate"><span class="pre">MAKE_CLOSURE</span></code> opcodes
|
||
have been removed.
|
||
(Contributed by Demur Rumed in <a class="reference external" href="https://bugs.python.org/issue27095">bpo-27095</a>, and Serhiy Storchaka in
|
||
<a class="reference external" href="https://bugs.python.org/issue27213">bpo-27213</a>, <a class="reference external" href="https://bugs.python.org/issue28257">bpo-28257</a>.)</p></li>
|
||
<li><p>The new <a class="reference internal" href="../library/dis.html#opcode-SETUP_ANNOTATIONS"><code class="xref std std-opcode docutils literal notranslate"><span class="pre">SETUP_ANNOTATIONS</span></code></a> and <code class="xref std std-opcode docutils literal notranslate"><span class="pre">STORE_ANNOTATION</span></code> opcodes
|
||
have been added to support the new <a class="reference internal" href="../glossary.html#term-variable-annotation"><span class="xref std std-term">variable annotation</span></a> syntax.
|
||
(Contributed by Ivan Levkivskyi in <a class="reference external" href="https://bugs.python.org/issue27985">bpo-27985</a>.)</p></li>
|
||
</ul>
|
||
</div>
|
||
</div>
|
||
<div class="section" id="notable-changes-in-python-3-6-2">
|
||
<h2>Notable changes in Python 3.6.2<a class="headerlink" href="#notable-changes-in-python-3-6-2" title="Permalink to this headline">¶</a></h2>
|
||
<div class="section" id="new-make-regen-all-build-target">
|
||
<h3>New <code class="docutils literal notranslate"><span class="pre">make</span> <span class="pre">regen-all</span></code> build target<a class="headerlink" href="#new-make-regen-all-build-target" title="Permalink to this headline">¶</a></h3>
|
||
<p>To simplify cross-compilation, and to ensure that CPython can reliably be
|
||
compiled without requiring an existing version of Python to already be
|
||
available, the autotools-based build system no longer attempts to implicitly
|
||
recompile generated files based on file modification times.</p>
|
||
<p>Instead, a new <code class="docutils literal notranslate"><span class="pre">make</span> <span class="pre">regen-all</span></code> command has been added to force regeneration
|
||
of these files when desired (e.g. after an initial version of Python has
|
||
already been built based on the pregenerated versions).</p>
|
||
<p>More selective regeneration targets are also defined - see
|
||
<a class="reference external" href="https://github.com/python/cpython/tree/3.7/Makefile.pre.in">Makefile.pre.in</a> for details.</p>
|
||
<p>(Contributed by Victor Stinner in <a class="reference external" href="https://bugs.python.org/issue23404">bpo-23404</a>.)</p>
|
||
<div class="versionadded">
|
||
<p><span class="versionmodified added">New in version 3.6.2.</span></p>
|
||
</div>
|
||
</div>
|
||
<div class="section" id="removal-of-make-touch-build-target">
|
||
<h3>Removal of <code class="docutils literal notranslate"><span class="pre">make</span> <span class="pre">touch</span></code> build target<a class="headerlink" href="#removal-of-make-touch-build-target" title="Permalink to this headline">¶</a></h3>
|
||
<p>The <code class="docutils literal notranslate"><span class="pre">make</span> <span class="pre">touch</span></code> build target previously used to request implicit regeneration
|
||
of generated files by updating their modification times has been removed.</p>
|
||
<p>It has been replaced by the new <code class="docutils literal notranslate"><span class="pre">make</span> <span class="pre">regen-all</span></code> target.</p>
|
||
<p>(Contributed by Victor Stinner in <a class="reference external" href="https://bugs.python.org/issue23404">bpo-23404</a>.)</p>
|
||
<div class="versionchanged">
|
||
<p><span class="versionmodified changed">Changed in version 3.6.2.</span></p>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
<div class="section" id="notable-changes-in-python-3-6-4">
|
||
<h2>Notable changes in Python 3.6.4<a class="headerlink" href="#notable-changes-in-python-3-6-4" title="Permalink to this headline">¶</a></h2>
|
||
<p>The <code class="docutils literal notranslate"><span class="pre">PyExc_RecursionErrorInst</span></code> singleton that was part of the public API
|
||
has been removed as its members being never cleared may cause a segfault
|
||
during finalization of the interpreter.
|
||
(Contributed by Xavier de Gaye in <a class="reference external" href="https://bugs.python.org/issue22898">bpo-22898</a> and <a class="reference external" href="https://bugs.python.org/issue30697">bpo-30697</a>.)</p>
|
||
</div>
|
||
<div class="section" id="notable-changes-in-python-3-6-5">
|
||
<h2>Notable changes in Python 3.6.5<a class="headerlink" href="#notable-changes-in-python-3-6-5" title="Permalink to this headline">¶</a></h2>
|
||
<p>The <a class="reference internal" href="../library/locale.html#locale.localeconv" title="locale.localeconv"><code class="xref py py-func docutils literal notranslate"><span class="pre">locale.localeconv()</span></code></a> function now sets temporarily the <code class="docutils literal notranslate"><span class="pre">LC_CTYPE</span></code>
|
||
locale to the <code class="docutils literal notranslate"><span class="pre">LC_NUMERIC</span></code> locale in some cases.
|
||
(Contributed by Victor Stinner in <a class="reference external" href="https://bugs.python.org/issue31900">bpo-31900</a>.)</p>
|
||
</div>
|
||
<div class="section" id="notable-changes-in-python-3-6-7">
|
||
<h2>Notable changes in Python 3.6.7<a class="headerlink" href="#notable-changes-in-python-3-6-7" title="Permalink to this headline">¶</a></h2>
|
||
<p>In 3.6.7 the <a class="reference internal" href="../library/tokenize.html#module-tokenize" title="tokenize: Lexical scanner for Python source code."><code class="xref py py-mod docutils literal notranslate"><span class="pre">tokenize</span></code></a> module now implicitly emits a <code class="docutils literal notranslate"><span class="pre">NEWLINE</span></code> token
|
||
when provided with input that does not have a trailing new line. This behavior
|
||
now matches what the C tokenizer does internally.
|
||
(Contributed by Ammar Askar in <a class="reference external" href="https://bugs.python.org/issue33899">bpo-33899</a>.)</p>
|
||
</div>
|
||
</div>
|
||
|
||
|
||
</div>
|
||
</div>
|
||
</div>
|
||
<div class="sphinxsidebar" role="navigation" aria-label="main navigation">
|
||
<div class="sphinxsidebarwrapper">
|
||
<h3><a href="../contents.html">Table of Contents</a></h3>
|
||
<ul>
|
||
<li><a class="reference internal" href="#">What’s New In Python 3.6</a><ul>
|
||
<li><a class="reference internal" href="#summary-release-highlights">Summary – Release highlights</a></li>
|
||
<li><a class="reference internal" href="#new-features">New Features</a><ul>
|
||
<li><a class="reference internal" href="#pep-498-formatted-string-literals">PEP 498: Formatted string literals</a></li>
|
||
<li><a class="reference internal" href="#pep-526-syntax-for-variable-annotations">PEP 526: Syntax for variable annotations</a></li>
|
||
<li><a class="reference internal" href="#pep-515-underscores-in-numeric-literals">PEP 515: Underscores in Numeric Literals</a></li>
|
||
<li><a class="reference internal" href="#pep-525-asynchronous-generators">PEP 525: Asynchronous Generators</a></li>
|
||
<li><a class="reference internal" href="#pep-530-asynchronous-comprehensions">PEP 530: Asynchronous Comprehensions</a></li>
|
||
<li><a class="reference internal" href="#pep-487-simpler-customization-of-class-creation">PEP 487: Simpler customization of class creation</a></li>
|
||
<li><a class="reference internal" href="#pep-487-descriptor-protocol-enhancements">PEP 487: Descriptor Protocol Enhancements</a></li>
|
||
<li><a class="reference internal" href="#pep-519-adding-a-file-system-path-protocol">PEP 519: Adding a file system path protocol</a></li>
|
||
<li><a class="reference internal" href="#pep-495-local-time-disambiguation">PEP 495: Local Time Disambiguation</a></li>
|
||
<li><a class="reference internal" href="#pep-529-change-windows-filesystem-encoding-to-utf-8">PEP 529: Change Windows filesystem encoding to UTF-8</a></li>
|
||
<li><a class="reference internal" href="#pep-528-change-windows-console-encoding-to-utf-8">PEP 528: Change Windows console encoding to UTF-8</a></li>
|
||
<li><a class="reference internal" href="#pep-520-preserving-class-attribute-definition-order">PEP 520: Preserving Class Attribute Definition Order</a></li>
|
||
<li><a class="reference internal" href="#pep-468-preserving-keyword-argument-order">PEP 468: Preserving Keyword Argument Order</a></li>
|
||
<li><a class="reference internal" href="#new-dict-implementation">New <span class="xref std std-ref">dict</span> implementation</a></li>
|
||
<li><a class="reference internal" href="#pep-523-adding-a-frame-evaluation-api-to-cpython">PEP 523: Adding a frame evaluation API to CPython</a></li>
|
||
<li><a class="reference internal" href="#pythonmalloc-environment-variable">PYTHONMALLOC environment variable</a></li>
|
||
<li><a class="reference internal" href="#dtrace-and-systemtap-probing-support">DTrace and SystemTap probing support</a></li>
|
||
</ul>
|
||
</li>
|
||
<li><a class="reference internal" href="#other-language-changes">Other Language Changes</a></li>
|
||
<li><a class="reference internal" href="#new-modules">New Modules</a><ul>
|
||
<li><a class="reference internal" href="#secrets">secrets</a></li>
|
||
</ul>
|
||
</li>
|
||
<li><a class="reference internal" href="#improved-modules">Improved Modules</a><ul>
|
||
<li><a class="reference internal" href="#array">array</a></li>
|
||
<li><a class="reference internal" href="#ast">ast</a></li>
|
||
<li><a class="reference internal" href="#asyncio">asyncio</a></li>
|
||
<li><a class="reference internal" href="#binascii">binascii</a></li>
|
||
<li><a class="reference internal" href="#cmath">cmath</a></li>
|
||
<li><a class="reference internal" href="#collections">collections</a></li>
|
||
<li><a class="reference internal" href="#concurrent-futures">concurrent.futures</a></li>
|
||
<li><a class="reference internal" href="#contextlib">contextlib</a></li>
|
||
<li><a class="reference internal" href="#datetime">datetime</a></li>
|
||
<li><a class="reference internal" href="#decimal">decimal</a></li>
|
||
<li><a class="reference internal" href="#distutils">distutils</a></li>
|
||
<li><a class="reference internal" href="#email">email</a></li>
|
||
<li><a class="reference internal" href="#encodings">encodings</a></li>
|
||
<li><a class="reference internal" href="#enum">enum</a></li>
|
||
<li><a class="reference internal" href="#faulthandler">faulthandler</a></li>
|
||
<li><a class="reference internal" href="#fileinput">fileinput</a></li>
|
||
<li><a class="reference internal" href="#hashlib">hashlib</a></li>
|
||
<li><a class="reference internal" href="#http-client">http.client</a></li>
|
||
<li><a class="reference internal" href="#idlelib-and-idle">idlelib and IDLE</a></li>
|
||
<li><a class="reference internal" href="#importlib">importlib</a></li>
|
||
<li><a class="reference internal" href="#inspect">inspect</a></li>
|
||
<li><a class="reference internal" href="#json">json</a></li>
|
||
<li><a class="reference internal" href="#logging">logging</a></li>
|
||
<li><a class="reference internal" href="#math">math</a></li>
|
||
<li><a class="reference internal" href="#multiprocessing">multiprocessing</a></li>
|
||
<li><a class="reference internal" href="#os">os</a></li>
|
||
<li><a class="reference internal" href="#pathlib">pathlib</a></li>
|
||
<li><a class="reference internal" href="#pdb">pdb</a></li>
|
||
<li><a class="reference internal" href="#pickle">pickle</a></li>
|
||
<li><a class="reference internal" href="#pickletools">pickletools</a></li>
|
||
<li><a class="reference internal" href="#pydoc">pydoc</a></li>
|
||
<li><a class="reference internal" href="#random">random</a></li>
|
||
<li><a class="reference internal" href="#re">re</a></li>
|
||
<li><a class="reference internal" href="#readline">readline</a></li>
|
||
<li><a class="reference internal" href="#rlcompleter">rlcompleter</a></li>
|
||
<li><a class="reference internal" href="#shlex">shlex</a></li>
|
||
<li><a class="reference internal" href="#site">site</a></li>
|
||
<li><a class="reference internal" href="#sqlite3">sqlite3</a></li>
|
||
<li><a class="reference internal" href="#socket">socket</a></li>
|
||
<li><a class="reference internal" href="#socketserver">socketserver</a></li>
|
||
<li><a class="reference internal" href="#ssl">ssl</a></li>
|
||
<li><a class="reference internal" href="#statistics">statistics</a></li>
|
||
<li><a class="reference internal" href="#struct">struct</a></li>
|
||
<li><a class="reference internal" href="#subprocess">subprocess</a></li>
|
||
<li><a class="reference internal" href="#sys">sys</a></li>
|
||
<li><a class="reference internal" href="#telnetlib">telnetlib</a></li>
|
||
<li><a class="reference internal" href="#time">time</a></li>
|
||
<li><a class="reference internal" href="#timeit">timeit</a></li>
|
||
<li><a class="reference internal" href="#tkinter">tkinter</a></li>
|
||
<li><a class="reference internal" href="#traceback">traceback</a></li>
|
||
<li><a class="reference internal" href="#tracemalloc">tracemalloc</a></li>
|
||
<li><a class="reference internal" href="#typing">typing</a></li>
|
||
<li><a class="reference internal" href="#unicodedata">unicodedata</a></li>
|
||
<li><a class="reference internal" href="#unittest-mock">unittest.mock</a></li>
|
||
<li><a class="reference internal" href="#urllib-request">urllib.request</a></li>
|
||
<li><a class="reference internal" href="#urllib-robotparser">urllib.robotparser</a></li>
|
||
<li><a class="reference internal" href="#venv">venv</a></li>
|
||
<li><a class="reference internal" href="#warnings">warnings</a></li>
|
||
<li><a class="reference internal" href="#winreg">winreg</a></li>
|
||
<li><a class="reference internal" href="#winsound">winsound</a></li>
|
||
<li><a class="reference internal" href="#xmlrpc-client">xmlrpc.client</a></li>
|
||
<li><a class="reference internal" href="#zipfile">zipfile</a></li>
|
||
<li><a class="reference internal" href="#zlib">zlib</a></li>
|
||
</ul>
|
||
</li>
|
||
<li><a class="reference internal" href="#optimizations">Optimizations</a></li>
|
||
<li><a class="reference internal" href="#build-and-c-api-changes">Build and C API Changes</a></li>
|
||
<li><a class="reference internal" href="#other-improvements">Other Improvements</a></li>
|
||
<li><a class="reference internal" href="#deprecated">Deprecated</a><ul>
|
||
<li><a class="reference internal" href="#new-keywords">New Keywords</a></li>
|
||
<li><a class="reference internal" href="#deprecated-python-behavior">Deprecated Python behavior</a></li>
|
||
<li><a class="reference internal" href="#deprecated-python-modules-functions-and-methods">Deprecated Python modules, functions and methods</a><ul>
|
||
<li><a class="reference internal" href="#asynchat">asynchat</a></li>
|
||
<li><a class="reference internal" href="#asyncore">asyncore</a></li>
|
||
<li><a class="reference internal" href="#dbm">dbm</a></li>
|
||
<li><a class="reference internal" href="#id2">distutils</a></li>
|
||
<li><a class="reference internal" href="#grp">grp</a></li>
|
||
<li><a class="reference internal" href="#id3">importlib</a></li>
|
||
<li><a class="reference internal" href="#id4">os</a></li>
|
||
<li><a class="reference internal" href="#id5">re</a></li>
|
||
<li><a class="reference internal" href="#id6">ssl</a></li>
|
||
<li><a class="reference internal" href="#id7">tkinter</a></li>
|
||
<li><a class="reference internal" href="#id8">venv</a></li>
|
||
</ul>
|
||
</li>
|
||
<li><a class="reference internal" href="#deprecated-functions-and-types-of-the-c-api">Deprecated functions and types of the C API</a></li>
|
||
<li><a class="reference internal" href="#deprecated-build-options">Deprecated Build Options</a></li>
|
||
</ul>
|
||
</li>
|
||
<li><a class="reference internal" href="#removed">Removed</a><ul>
|
||
<li><a class="reference internal" href="#api-and-feature-removals">API and Feature Removals</a></li>
|
||
</ul>
|
||
</li>
|
||
<li><a class="reference internal" href="#porting-to-python-3-6">Porting to Python 3.6</a><ul>
|
||
<li><a class="reference internal" href="#changes-in-python-command-behavior">Changes in ‘python’ Command Behavior</a></li>
|
||
<li><a class="reference internal" href="#changes-in-the-python-api">Changes in the Python API</a></li>
|
||
<li><a class="reference internal" href="#changes-in-the-c-api">Changes in the C API</a></li>
|
||
<li><a class="reference internal" href="#cpython-bytecode-changes">CPython bytecode changes</a></li>
|
||
</ul>
|
||
</li>
|
||
<li><a class="reference internal" href="#notable-changes-in-python-3-6-2">Notable changes in Python 3.6.2</a><ul>
|
||
<li><a class="reference internal" href="#new-make-regen-all-build-target">New <code class="docutils literal notranslate"><span class="pre">make</span> <span class="pre">regen-all</span></code> build target</a></li>
|
||
<li><a class="reference internal" href="#removal-of-make-touch-build-target">Removal of <code class="docutils literal notranslate"><span class="pre">make</span> <span class="pre">touch</span></code> build target</a></li>
|
||
</ul>
|
||
</li>
|
||
<li><a class="reference internal" href="#notable-changes-in-python-3-6-4">Notable changes in Python 3.6.4</a></li>
|
||
<li><a class="reference internal" href="#notable-changes-in-python-3-6-5">Notable changes in Python 3.6.5</a></li>
|
||
<li><a class="reference internal" href="#notable-changes-in-python-3-6-7">Notable changes in Python 3.6.7</a></li>
|
||
</ul>
|
||
</li>
|
||
</ul>
|
||
|
||
<h4>Previous topic</h4>
|
||
<p class="topless"><a href="3.7.html"
|
||
title="previous chapter">What’s New In Python 3.7</a></p>
|
||
<h4>Next topic</h4>
|
||
<p class="topless"><a href="3.5.html"
|
||
title="next chapter">What’s New In Python 3.5</a></p>
|
||
<div role="note" aria-label="source link">
|
||
<h3>This Page</h3>
|
||
<ul class="this-page-menu">
|
||
<li><a href="../bugs.html">Report a Bug</a></li>
|
||
<li>
|
||
<a href="https://github.com/python/cpython/blob/3.7/Doc/whatsnew/3.6.rst"
|
||
rel="nofollow">Show Source
|
||
</a>
|
||
</li>
|
||
</ul>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
<div class="clearer"></div>
|
||
</div>
|
||
<div class="related" role="navigation" aria-label="related navigation">
|
||
<h3>Navigation</h3>
|
||
<ul>
|
||
<li class="right" style="margin-right: 10px">
|
||
<a href="../genindex.html" title="General Index"
|
||
>index</a></li>
|
||
<li class="right" >
|
||
<a href="../py-modindex.html" title="Python Module Index"
|
||
>modules</a> |</li>
|
||
<li class="right" >
|
||
<a href="3.5.html" title="What’s New In Python 3.5"
|
||
>next</a> |</li>
|
||
<li class="right" >
|
||
<a href="3.7.html" title="What’s New In Python 3.7"
|
||
>previous</a> |</li>
|
||
<li><img src="../_static/py.png" alt=""
|
||
style="vertical-align: middle; margin-top: -1px"/></li>
|
||
<li><a href="https://www.python.org/">Python</a> »</li>
|
||
<li>
|
||
<span class="language_switcher_placeholder">en</span>
|
||
<span class="version_switcher_placeholder">3.7.4</span>
|
||
<a href="../index.html">Documentation </a> »
|
||
</li>
|
||
|
||
<li class="nav-item nav-item-1"><a href="index.html" >What’s New in Python</a> »</li>
|
||
<li class="right">
|
||
|
||
|
||
<div class="inline-search" style="display: none" role="search">
|
||
<form class="inline-search" action="../search.html" method="get">
|
||
<input placeholder="Quick search" type="text" name="q" />
|
||
<input type="submit" value="Go" />
|
||
<input type="hidden" name="check_keywords" value="yes" />
|
||
<input type="hidden" name="area" value="default" />
|
||
</form>
|
||
</div>
|
||
<script type="text/javascript">$('.inline-search').show(0);</script>
|
||
|
|
||
</li>
|
||
|
||
</ul>
|
||
</div>
|
||
<div class="footer">
|
||
© <a href="../copyright.html">Copyright</a> 2001-2019, Python Software Foundation.
|
||
<br />
|
||
The Python Software Foundation is a non-profit corporation.
|
||
<a href="https://www.python.org/psf/donations/">Please donate.</a>
|
||
<br />
|
||
Last updated on Jul 13, 2019.
|
||
<a href="../bugs.html">Found a bug</a>?
|
||
<br />
|
||
Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 2.0.1.
|
||
</div>
|
||
|
||
</body>
|
||
</html> |