gooderp18绿色标准版
Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

2692 lines
312KB

  1. <!DOCTYPE html>
  2. <html lang="en" data-content_root="../">
  3. <head>
  4. <meta charset="utf-8" />
  5. <meta name="viewport" content="width=device-width, initial-scale=1.0" /><meta name="viewport" content="width=device-width, initial-scale=1" />
  6. <meta property="og:title" content="What’s New In Python 3.7" />
  7. <meta property="og:type" content="website" />
  8. <meta property="og:url" content="https://docs.python.org/3/whatsnew/3.7.html" />
  9. <meta property="og:site_name" content="Python documentation" />
  10. <meta property="og:description" content="Editor, Elvis Pranskevichus < elvis@magic.io>,. This article explains the new features in Python 3.7, compared to 3.6. Python 3.7 was released on June 27, 2018. For full details, see the changelog...." />
  11. <meta property="og:image" content="https://docs.python.org/3/_static/og-image.png" />
  12. <meta property="og:image:alt" content="Python documentation" />
  13. <meta name="description" content="Editor, Elvis Pranskevichus < elvis@magic.io>,. This article explains the new features in Python 3.7, compared to 3.6. Python 3.7 was released on June 27, 2018. For full details, see the changelog...." />
  14. <meta property="og:image:width" content="200" />
  15. <meta property="og:image:height" content="200" />
  16. <meta name="theme-color" content="#3776ab" />
  17. <title>What’s New In Python 3.7 &#8212; Python 3.12.3 documentation</title><meta name="viewport" content="width=device-width, initial-scale=1.0">
  18. <link rel="stylesheet" type="text/css" href="../_static/pygments.css?v=80d5e7a1" />
  19. <link rel="stylesheet" type="text/css" href="../_static/pydoctheme.css?v=bb723527" />
  20. <link id="pygments_dark_css" media="(prefers-color-scheme: dark)" rel="stylesheet" type="text/css" href="../_static/pygments_dark.css?v=b20cc3f5" />
  21. <script src="../_static/documentation_options.js?v=2c828074"></script>
  22. <script src="../_static/doctools.js?v=888ff710"></script>
  23. <script src="../_static/sphinx_highlight.js?v=dc90522c"></script>
  24. <script src="../_static/sidebar.js"></script>
  25. <link rel="search" type="application/opensearchdescription+xml"
  26. title="Search within Python 3.12.3 documentation"
  27. href="../_static/opensearch.xml"/>
  28. <link rel="author" title="About these documents" href="../about.html" />
  29. <link rel="index" title="Index" href="../genindex.html" />
  30. <link rel="search" title="Search" href="../search.html" />
  31. <link rel="copyright" title="Copyright" href="../copyright.html" />
  32. <link rel="next" title="What’s New In Python 3.6" href="3.6.html" />
  33. <link rel="prev" title="What’s New In Python 3.8" href="3.8.html" />
  34. <link rel="canonical" href="https://docs.python.org/3/whatsnew/3.7.html" />
  35. <style>
  36. @media only screen {
  37. table.full-width-table {
  38. width: 100%;
  39. }
  40. }
  41. </style>
  42. <link rel="stylesheet" href="../_static/pydoctheme_dark.css" media="(prefers-color-scheme: dark)" id="pydoctheme_dark_css">
  43. <link rel="shortcut icon" type="image/png" href="../_static/py.svg" />
  44. <script type="text/javascript" src="../_static/copybutton.js"></script>
  45. <script type="text/javascript" src="../_static/menu.js"></script>
  46. <script type="text/javascript" src="../_static/search-focus.js"></script>
  47. <script type="text/javascript" src="../_static/themetoggle.js"></script>
  48. </head>
  49. <body>
  50. <div class="mobile-nav">
  51. <input type="checkbox" id="menuToggler" class="toggler__input" aria-controls="navigation"
  52. aria-pressed="false" aria-expanded="false" role="button" aria-label="Menu" />
  53. <nav class="nav-content" role="navigation">
  54. <label for="menuToggler" class="toggler__label">
  55. <span></span>
  56. </label>
  57. <span class="nav-items-wrapper">
  58. <a href="https://www.python.org/" class="nav-logo">
  59. <img src="../_static/py.svg" alt="Python logo"/>
  60. </a>
  61. <span class="version_switcher_placeholder"></span>
  62. <form role="search" class="search" action="../search.html" method="get">
  63. <svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" class="search-icon">
  64. <path fill-rule="nonzero" fill="currentColor" d="M15.5 14h-.79l-.28-.27a6.5 6.5 0 001.48-5.34c-.47-2.78-2.79-5-5.59-5.34a6.505 6.505 0 00-7.27 7.27c.34 2.8 2.56 5.12 5.34 5.59a6.5 6.5 0 005.34-1.48l.27.28v.79l4.25 4.25c.41.41 1.08.41 1.49 0 .41-.41.41-1.08 0-1.49L15.5 14zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14z"></path>
  65. </svg>
  66. <input placeholder="Quick search" aria-label="Quick search" type="search" name="q" />
  67. <input type="submit" value="Go"/>
  68. </form>
  69. </span>
  70. </nav>
  71. <div class="menu-wrapper">
  72. <nav class="menu" role="navigation" aria-label="main navigation">
  73. <div class="language_switcher_placeholder"></div>
  74. <label class="theme-selector-label">
  75. Theme
  76. <select class="theme-selector" oninput="activateTheme(this.value)">
  77. <option value="auto" selected>Auto</option>
  78. <option value="light">Light</option>
  79. <option value="dark">Dark</option>
  80. </select>
  81. </label>
  82. <div>
  83. <h3><a href="../contents.html">Table of Contents</a></h3>
  84. <ul>
  85. <li><a class="reference internal" href="#">What’s New In Python 3.7</a><ul>
  86. <li><a class="reference internal" href="#summary-release-highlights">Summary – Release Highlights</a></li>
  87. <li><a class="reference internal" href="#new-features">New Features</a><ul>
  88. <li><a class="reference internal" href="#pep-563-postponed-evaluation-of-annotations">PEP 563: Postponed Evaluation of Annotations</a></li>
  89. <li><a class="reference internal" href="#pep-538-legacy-c-locale-coercion">PEP 538: Legacy C Locale Coercion</a></li>
  90. <li><a class="reference internal" href="#pep-540-forced-utf-8-runtime-mode">PEP 540: Forced UTF-8 Runtime Mode</a></li>
  91. <li><a class="reference internal" href="#pep-553-built-in-breakpoint">PEP 553: Built-in <code class="docutils literal notranslate"><span class="pre">breakpoint()</span></code></a></li>
  92. <li><a class="reference internal" href="#pep-539-new-c-api-for-thread-local-storage">PEP 539: New C API for Thread-Local Storage</a></li>
  93. <li><a class="reference internal" href="#pep-562-customization-of-access-to-module-attributes">PEP 562: Customization of Access to Module Attributes</a></li>
  94. <li><a class="reference internal" href="#pep-564-new-time-functions-with-nanosecond-resolution">PEP 564: New Time Functions With Nanosecond Resolution</a></li>
  95. <li><a class="reference internal" href="#pep-565-show-deprecationwarning-in-main">PEP 565: Show DeprecationWarning in <code class="docutils literal notranslate"><span class="pre">__main__</span></code></a></li>
  96. <li><a class="reference internal" href="#pep-560-core-support-for-typing-module-and-generic-types">PEP 560: Core Support for <code class="docutils literal notranslate"><span class="pre">typing</span></code> module and Generic Types</a></li>
  97. <li><a class="reference internal" href="#pep-552-hash-based-pyc-files">PEP 552: Hash-based .pyc Files</a></li>
  98. <li><a class="reference internal" href="#pep-545-python-documentation-translations">PEP 545: Python Documentation Translations</a></li>
  99. <li><a class="reference internal" href="#python-development-mode-x-dev">Python Development Mode (-X dev)</a></li>
  100. </ul>
  101. </li>
  102. <li><a class="reference internal" href="#other-language-changes">Other Language Changes</a></li>
  103. <li><a class="reference internal" href="#new-modules">New Modules</a><ul>
  104. <li><a class="reference internal" href="#contextvars">contextvars</a></li>
  105. <li><a class="reference internal" href="#dataclasses">dataclasses</a></li>
  106. <li><a class="reference internal" href="#importlib-resources">importlib.resources</a></li>
  107. </ul>
  108. </li>
  109. <li><a class="reference internal" href="#improved-modules">Improved Modules</a><ul>
  110. <li><a class="reference internal" href="#argparse">argparse</a></li>
  111. <li><a class="reference internal" href="#asyncio">asyncio</a></li>
  112. <li><a class="reference internal" href="#binascii">binascii</a></li>
  113. <li><a class="reference internal" href="#calendar">calendar</a></li>
  114. <li><a class="reference internal" href="#collections">collections</a></li>
  115. <li><a class="reference internal" href="#compileall">compileall</a></li>
  116. <li><a class="reference internal" href="#concurrent-futures">concurrent.futures</a></li>
  117. <li><a class="reference internal" href="#contextlib">contextlib</a></li>
  118. <li><a class="reference internal" href="#cprofile">cProfile</a></li>
  119. <li><a class="reference internal" href="#crypt">crypt</a></li>
  120. <li><a class="reference internal" href="#datetime">datetime</a></li>
  121. <li><a class="reference internal" href="#dbm">dbm</a></li>
  122. <li><a class="reference internal" href="#decimal">decimal</a></li>
  123. <li><a class="reference internal" href="#dis">dis</a></li>
  124. <li><a class="reference internal" href="#distutils">distutils</a></li>
  125. <li><a class="reference internal" href="#enum">enum</a></li>
  126. <li><a class="reference internal" href="#functools">functools</a></li>
  127. <li><a class="reference internal" href="#gc">gc</a></li>
  128. <li><a class="reference internal" href="#hmac">hmac</a></li>
  129. <li><a class="reference internal" href="#http-client">http.client</a></li>
  130. <li><a class="reference internal" href="#http-server">http.server</a></li>
  131. <li><a class="reference internal" href="#idlelib-and-idle">idlelib and IDLE</a></li>
  132. <li><a class="reference internal" href="#importlib">importlib</a></li>
  133. <li><a class="reference internal" href="#io">io</a></li>
  134. <li><a class="reference internal" href="#ipaddress">ipaddress</a></li>
  135. <li><a class="reference internal" href="#itertools">itertools</a></li>
  136. <li><a class="reference internal" href="#locale">locale</a></li>
  137. <li><a class="reference internal" href="#logging">logging</a></li>
  138. <li><a class="reference internal" href="#math">math</a></li>
  139. <li><a class="reference internal" href="#mimetypes">mimetypes</a></li>
  140. <li><a class="reference internal" href="#msilib">msilib</a></li>
  141. <li><a class="reference internal" href="#multiprocessing">multiprocessing</a></li>
  142. <li><a class="reference internal" href="#os">os</a></li>
  143. <li><a class="reference internal" href="#pathlib">pathlib</a></li>
  144. <li><a class="reference internal" href="#pdb">pdb</a></li>
  145. <li><a class="reference internal" href="#py-compile">py_compile</a></li>
  146. <li><a class="reference internal" href="#pydoc">pydoc</a></li>
  147. <li><a class="reference internal" href="#queue">queue</a></li>
  148. <li><a class="reference internal" href="#re">re</a></li>
  149. <li><a class="reference internal" href="#signal">signal</a></li>
  150. <li><a class="reference internal" href="#socket">socket</a></li>
  151. <li><a class="reference internal" href="#socketserver">socketserver</a></li>
  152. <li><a class="reference internal" href="#sqlite3">sqlite3</a></li>
  153. <li><a class="reference internal" href="#ssl">ssl</a></li>
  154. <li><a class="reference internal" href="#string">string</a></li>
  155. <li><a class="reference internal" href="#subprocess">subprocess</a></li>
  156. <li><a class="reference internal" href="#sys">sys</a></li>
  157. <li><a class="reference internal" href="#time">time</a></li>
  158. <li><a class="reference internal" href="#tkinter">tkinter</a></li>
  159. <li><a class="reference internal" href="#tracemalloc">tracemalloc</a></li>
  160. <li><a class="reference internal" href="#types">types</a></li>
  161. <li><a class="reference internal" href="#unicodedata">unicodedata</a></li>
  162. <li><a class="reference internal" href="#unittest">unittest</a></li>
  163. <li><a class="reference internal" href="#unittest-mock">unittest.mock</a></li>
  164. <li><a class="reference internal" href="#urllib-parse">urllib.parse</a></li>
  165. <li><a class="reference internal" href="#uu">uu</a></li>
  166. <li><a class="reference internal" href="#uuid">uuid</a></li>
  167. <li><a class="reference internal" href="#warnings">warnings</a></li>
  168. <li><a class="reference internal" href="#xml">xml</a></li>
  169. <li><a class="reference internal" href="#xml-etree">xml.etree</a></li>
  170. <li><a class="reference internal" href="#xmlrpc-server">xmlrpc.server</a></li>
  171. <li><a class="reference internal" href="#zipapp">zipapp</a></li>
  172. <li><a class="reference internal" href="#zipfile">zipfile</a></li>
  173. </ul>
  174. </li>
  175. <li><a class="reference internal" href="#c-api-changes">C API Changes</a></li>
  176. <li><a class="reference internal" href="#build-changes">Build Changes</a></li>
  177. <li><a class="reference internal" href="#optimizations">Optimizations</a></li>
  178. <li><a class="reference internal" href="#other-cpython-implementation-changes">Other CPython Implementation Changes</a></li>
  179. <li><a class="reference internal" href="#deprecated-python-behavior">Deprecated Python Behavior</a></li>
  180. <li><a class="reference internal" href="#deprecated-python-modules-functions-and-methods">Deprecated Python modules, functions and methods</a><ul>
  181. <li><a class="reference internal" href="#aifc">aifc</a></li>
  182. <li><a class="reference internal" href="#whatsnew37-asyncio-deprecated">asyncio</a></li>
  183. <li><a class="reference internal" href="#id3">collections</a></li>
  184. <li><a class="reference internal" href="#id4">dbm</a></li>
  185. <li><a class="reference internal" href="#id5">enum</a></li>
  186. <li><a class="reference internal" href="#gettext">gettext</a></li>
  187. <li><a class="reference internal" href="#id6">importlib</a></li>
  188. <li><a class="reference internal" href="#id7">locale</a></li>
  189. <li><a class="reference internal" href="#macpath">macpath</a></li>
  190. <li><a class="reference internal" href="#threading">threading</a></li>
  191. <li><a class="reference internal" href="#id8">socket</a></li>
  192. <li><a class="reference internal" href="#id9">ssl</a></li>
  193. <li><a class="reference internal" href="#sunau">sunau</a></li>
  194. <li><a class="reference internal" href="#id10">sys</a></li>
  195. <li><a class="reference internal" href="#wave">wave</a></li>
  196. </ul>
  197. </li>
  198. <li><a class="reference internal" href="#deprecated-functions-and-types-of-the-c-api">Deprecated functions and types of the C API</a></li>
  199. <li><a class="reference internal" href="#platform-support-removals">Platform Support Removals</a></li>
  200. <li><a class="reference internal" href="#api-and-feature-removals">API and Feature Removals</a></li>
  201. <li><a class="reference internal" href="#module-removals">Module Removals</a></li>
  202. <li><a class="reference internal" href="#windows-only-changes">Windows-only Changes</a></li>
  203. <li><a class="reference internal" href="#porting-to-python-3-7">Porting to Python 3.7</a><ul>
  204. <li><a class="reference internal" href="#changes-in-python-behavior">Changes in Python Behavior</a></li>
  205. <li><a class="reference internal" href="#changes-in-the-python-api">Changes in the Python API</a></li>
  206. <li><a class="reference internal" href="#changes-in-the-c-api">Changes in the C API</a></li>
  207. <li><a class="reference internal" href="#cpython-bytecode-changes">CPython bytecode changes</a></li>
  208. <li><a class="reference internal" href="#id12">Windows-only Changes</a></li>
  209. <li><a class="reference internal" href="#id13">Other CPython implementation changes</a></li>
  210. </ul>
  211. </li>
  212. <li><a class="reference internal" href="#notable-changes-in-python-3-7-1">Notable changes in Python 3.7.1</a></li>
  213. <li><a class="reference internal" href="#notable-changes-in-python-3-7-2">Notable changes in Python 3.7.2</a></li>
  214. <li><a class="reference internal" href="#notable-changes-in-python-3-7-6">Notable changes in Python 3.7.6</a></li>
  215. <li><a class="reference internal" href="#notable-changes-in-python-3-7-10">Notable changes in Python 3.7.10</a></li>
  216. <li><a class="reference internal" href="#notable-changes-in-python-3-7-11">Notable changes in Python 3.7.11</a></li>
  217. <li><a class="reference internal" href="#notable-security-feature-in-3-7-14">Notable security feature in 3.7.14</a></li>
  218. </ul>
  219. </li>
  220. </ul>
  221. </div>
  222. <div>
  223. <h4>Previous topic</h4>
  224. <p class="topless"><a href="3.8.html"
  225. title="previous chapter">What’s New In Python 3.8</a></p>
  226. </div>
  227. <div>
  228. <h4>Next topic</h4>
  229. <p class="topless"><a href="3.6.html"
  230. title="next chapter">What’s New In Python 3.6</a></p>
  231. </div>
  232. <div role="note" aria-label="source link">
  233. <h3>This Page</h3>
  234. <ul class="this-page-menu">
  235. <li><a href="../bugs.html">Report a Bug</a></li>
  236. <li>
  237. <a href="https://github.com/python/cpython/blob/main/Doc/whatsnew/3.7.rst"
  238. rel="nofollow">Show Source
  239. </a>
  240. </li>
  241. </ul>
  242. </div>
  243. </nav>
  244. </div>
  245. </div>
  246. <div class="related" role="navigation" aria-label="related navigation">
  247. <h3>Navigation</h3>
  248. <ul>
  249. <li class="right" style="margin-right: 10px">
  250. <a href="../genindex.html" title="General Index"
  251. accesskey="I">index</a></li>
  252. <li class="right" >
  253. <a href="../py-modindex.html" title="Python Module Index"
  254. >modules</a> |</li>
  255. <li class="right" >
  256. <a href="3.6.html" title="What’s New In Python 3.6"
  257. accesskey="N">next</a> |</li>
  258. <li class="right" >
  259. <a href="3.8.html" title="What’s New In Python 3.8"
  260. accesskey="P">previous</a> |</li>
  261. <li><img src="../_static/py.svg" alt="Python logo" style="vertical-align: middle; margin-top: -1px"/></li>
  262. <li><a href="https://www.python.org/">Python</a> &#187;</li>
  263. <li class="switchers">
  264. <div class="language_switcher_placeholder"></div>
  265. <div class="version_switcher_placeholder"></div>
  266. </li>
  267. <li>
  268. </li>
  269. <li id="cpython-language-and-version">
  270. <a href="../index.html">3.12.3 Documentation</a> &#187;
  271. </li>
  272. <li class="nav-item nav-item-1"><a href="index.html" accesskey="U">What’s New in Python</a> &#187;</li>
  273. <li class="nav-item nav-item-this"><a href="">What’s New In Python 3.7</a></li>
  274. <li class="right">
  275. <div class="inline-search" role="search">
  276. <form class="inline-search" action="../search.html" method="get">
  277. <input placeholder="Quick search" aria-label="Quick search" type="search" name="q" id="search-box" />
  278. <input type="submit" value="Go" />
  279. </form>
  280. </div>
  281. |
  282. </li>
  283. <li class="right">
  284. <label class="theme-selector-label">
  285. Theme
  286. <select class="theme-selector" oninput="activateTheme(this.value)">
  287. <option value="auto" selected>Auto</option>
  288. <option value="light">Light</option>
  289. <option value="dark">Dark</option>
  290. </select>
  291. </label> |</li>
  292. </ul>
  293. </div>
  294. <div class="document">
  295. <div class="documentwrapper">
  296. <div class="bodywrapper">
  297. <div class="body" role="main">
  298. <section id="what-s-new-in-python-3-7">
  299. <h1>What’s New In Python 3.7<a class="headerlink" href="#what-s-new-in-python-3-7" title="Link to this heading">¶</a></h1>
  300. <dl class="field-list simple">
  301. <dt class="field-odd">Editor<span class="colon">:</span></dt>
  302. <dd class="field-odd"><p>Elvis Pranskevichus &lt;<a class="reference external" href="mailto:elvis&#37;&#52;&#48;magic&#46;io">elvis<span>&#64;</span>magic<span>&#46;</span>io</a>&gt;</p>
  303. </dd>
  304. </dl>
  305. <p>This article explains the new features in Python 3.7, compared to 3.6.
  306. Python 3.7 was released on June 27, 2018.
  307. For full details, see the <a class="reference internal" href="changelog.html#changelog"><span class="std std-ref">changelog</span></a>.</p>
  308. <section id="summary-release-highlights">
  309. <h2>Summary – Release Highlights<a class="headerlink" href="#summary-release-highlights" title="Link to this heading">¶</a></h2>
  310. <p>New syntax features:</p>
  311. <ul class="simple">
  312. <li><p><a class="reference internal" href="#whatsnew37-pep563"><span class="std std-ref">PEP 563</span></a>, postponed evaluation of type annotations.</p></li>
  313. </ul>
  314. <p>Backwards incompatible syntax changes:</p>
  315. <ul class="simple">
  316. <li><p><a class="reference internal" href="../reference/compound_stmts.html#async"><code class="xref std std-keyword docutils literal notranslate"><span class="pre">async</span></code></a> and <a class="reference internal" href="../reference/expressions.html#await"><code class="xref std std-keyword docutils literal notranslate"><span class="pre">await</span></code></a> are now reserved keywords.</p></li>
  317. </ul>
  318. <p>New library modules:</p>
  319. <ul class="simple">
  320. <li><p><a class="reference internal" href="../library/contextvars.html#module-contextvars" title="contextvars: Context Variables"><code class="xref py py-mod docutils literal notranslate"><span class="pre">contextvars</span></code></a>: <a class="reference internal" href="#whatsnew37-pep567"><span class="std std-ref">PEP 567 – Context Variables</span></a></p></li>
  321. <li><p><a class="reference internal" href="../library/dataclasses.html#module-dataclasses" title="dataclasses: Generate special methods on user-defined classes."><code class="xref py py-mod docutils literal notranslate"><span class="pre">dataclasses</span></code></a>: <a class="reference internal" href="#whatsnew37-pep557"><span class="std std-ref">PEP 557 – Data Classes</span></a></p></li>
  322. <li><p><a class="reference internal" href="#whatsnew37-importlib-resources"><span class="std std-ref">importlib.resources</span></a></p></li>
  323. </ul>
  324. <p>New built-in features:</p>
  325. <ul class="simple">
  326. <li><p><a class="reference internal" href="#whatsnew37-pep553"><span class="std std-ref">PEP 553</span></a>, the new <a class="reference internal" href="../library/functions.html#breakpoint" title="breakpoint"><code class="xref py py-func docutils literal notranslate"><span class="pre">breakpoint()</span></code></a> function.</p></li>
  327. </ul>
  328. <p>Python data model improvements:</p>
  329. <ul class="simple">
  330. <li><p><a class="reference internal" href="#whatsnew37-pep562"><span class="std std-ref">PEP 562</span></a>, customization of access to
  331. module attributes.</p></li>
  332. <li><p><a class="reference internal" href="#whatsnew37-pep560"><span class="std std-ref">PEP 560</span></a>, core support for typing module and
  333. generic types.</p></li>
  334. <li><p>the insertion-order preservation nature of <a class="reference internal" href="../library/stdtypes.html#typesmapping"><span class="std std-ref">dict</span></a>
  335. objects <a class="reference external" href="https://mail.python.org/pipermail/python-dev/2017-December/151283.html">has been declared</a> to be an official
  336. part of the Python language spec.</p></li>
  337. </ul>
  338. <p>Significant improvements in the standard library:</p>
  339. <ul class="simple">
  340. <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
  341. <a class="reference internal" href="#whatsnew37-asyncio"><span class="std std-ref">usability and performance improvements</span></a>.</p></li>
  342. <li><p>The <a class="reference internal" href="../library/time.html#module-time" title="time: Time access and conversions."><code class="xref py py-mod docutils literal notranslate"><span class="pre">time</span></code></a> module gained support for
  343. <a class="reference internal" href="#whatsnew37-pep564"><span class="std std-ref">functions with nanosecond resolution</span></a>.</p></li>
  344. </ul>
  345. <p>CPython implementation improvements:</p>
  346. <ul class="simple">
  347. <li><p>Avoiding the use of ASCII as a default text encoding:</p>
  348. <ul>
  349. <li><p><a class="reference internal" href="#whatsnew37-pep538"><span class="std std-ref">PEP 538</span></a>, legacy C locale coercion</p></li>
  350. <li><p><a class="reference internal" href="#whatsnew37-pep540"><span class="std std-ref">PEP 540</span></a>, forced UTF-8 runtime mode</p></li>
  351. </ul>
  352. </li>
  353. <li><p><a class="reference internal" href="#whatsnew37-pep552"><span class="std std-ref">PEP 552</span></a>, deterministic .pycs</p></li>
  354. <li><p><a class="reference internal" href="#whatsnew37-devmode"><span class="std std-ref">New Python Development Mode</span></a></p></li>
  355. <li><p><a class="reference internal" href="#whatsnew37-pep565"><span class="std std-ref">PEP 565</span></a>, improved <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>
  356. handling</p></li>
  357. </ul>
  358. <p>C API improvements:</p>
  359. <ul class="simple">
  360. <li><p><a class="reference internal" href="#whatsnew37-pep539"><span class="std std-ref">PEP 539</span></a>, new C API for thread-local storage</p></li>
  361. </ul>
  362. <p>Documentation improvements:</p>
  363. <ul class="simple">
  364. <li><p><a class="reference internal" href="#whatsnew37-pep545"><span class="std std-ref">PEP 545</span></a>, Python documentation translations</p></li>
  365. <li><p>New documentation translations: <a class="reference external" href="https://docs.python.org/ja/">Japanese</a>,
  366. <a class="reference external" href="https://docs.python.org/fr/">French</a>, and
  367. <a class="reference external" href="https://docs.python.org/ko/">Korean</a>.</p></li>
  368. </ul>
  369. <p>This release features notable performance improvements in many areas.
  370. The <a class="reference internal" href="#whatsnew37-perf"><span class="std std-ref">Optimizations</span></a> section lists them in detail.</p>
  371. <p>For a list of changes that may affect compatibility with previous Python
  372. releases please refer to the <a class="reference internal" href="#porting-to-python-37"><span class="std std-ref">Porting to Python 3.7</span></a> section.</p>
  373. </section>
  374. <section id="new-features">
  375. <h2>New Features<a class="headerlink" href="#new-features" title="Link to this heading">¶</a></h2>
  376. <section id="pep-563-postponed-evaluation-of-annotations">
  377. <span id="whatsnew37-pep563"></span><h3>PEP 563: Postponed Evaluation of Annotations<a class="headerlink" href="#pep-563-postponed-evaluation-of-annotations" title="Link to this heading">¶</a></h3>
  378. <p>The advent of type hints in Python uncovered two glaring usability issues
  379. with the functionality of annotations added in <span class="target" id="index-0"></span><a class="pep reference external" href="https://peps.python.org/pep-3107/"><strong>PEP 3107</strong></a> and refined
  380. further in <span class="target" id="index-1"></span><a class="pep reference external" href="https://peps.python.org/pep-0526/"><strong>PEP 526</strong></a>:</p>
  381. <ul class="simple">
  382. <li><p>annotations could only use names which were already available in the
  383. current scope, in other words they didn’t support forward references
  384. of any kind; and</p></li>
  385. <li><p>annotating source code had adverse effects on startup time of Python
  386. programs.</p></li>
  387. </ul>
  388. <p>Both of these issues are fixed by postponing the evaluation of
  389. annotations. Instead of compiling code which executes expressions in
  390. annotations at their definition time, the compiler stores the annotation
  391. in a string form equivalent to the AST of the expression in question.
  392. If needed, annotations can be resolved at runtime using
  393. <a class="reference internal" href="../library/typing.html#typing.get_type_hints" title="typing.get_type_hints"><code class="xref py py-func docutils literal notranslate"><span class="pre">typing.get_type_hints()</span></code></a>. In the common case where this is not
  394. required, the annotations are cheaper to store (since short strings
  395. are interned by the interpreter) and make startup time faster.</p>
  396. <p>Usability-wise, annotations now support forward references, making the
  397. following syntax valid:</p>
  398. <div class="highlight-python3 notranslate"><div class="highlight"><pre><span></span><span class="k">class</span> <span class="nc">C</span><span class="p">:</span>
  399. <span class="nd">@classmethod</span>
  400. <span class="k">def</span> <span class="nf">from_string</span><span class="p">(</span><span class="bp">cls</span><span class="p">,</span> <span class="n">source</span><span class="p">:</span> <span class="nb">str</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="n">C</span><span class="p">:</span>
  401. <span class="o">...</span>
  402. <span class="k">def</span> <span class="nf">validate_b</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">obj</span><span class="p">:</span> <span class="n">B</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="nb">bool</span><span class="p">:</span>
  403. <span class="o">...</span>
  404. <span class="k">class</span> <span class="nc">B</span><span class="p">:</span>
  405. <span class="o">...</span>
  406. </pre></div>
  407. </div>
  408. <p>Since this change breaks compatibility, the new behavior needs to be enabled
  409. on a per-module basis in Python 3.7 using a <a class="reference internal" href="../library/__future__.html#module-__future__" title="__future__: Future statement definitions"><code class="xref py py-mod docutils literal notranslate"><span class="pre">__future__</span></code></a> import:</p>
  410. <div class="highlight-python3 notranslate"><div class="highlight"><pre><span></span><span class="kn">from</span> <span class="nn">__future__</span> <span class="kn">import</span> <span class="n">annotations</span>
  411. </pre></div>
  412. </div>
  413. <p>It will become the default in Python 3.10.</p>
  414. <div class="admonition seealso">
  415. <p class="admonition-title">See also</p>
  416. <dl class="simple">
  417. <dt><span class="target" id="index-2"></span><a class="pep reference external" href="https://peps.python.org/pep-0563/"><strong>PEP 563</strong></a> – Postponed evaluation of annotations</dt><dd><p>PEP written and implemented by Łukasz Langa.</p>
  418. </dd>
  419. </dl>
  420. </div>
  421. </section>
  422. <section id="pep-538-legacy-c-locale-coercion">
  423. <span id="whatsnew37-pep538"></span><h3>PEP 538: Legacy C Locale Coercion<a class="headerlink" href="#pep-538-legacy-c-locale-coercion" title="Link to this heading">¶</a></h3>
  424. <p>An ongoing challenge within the Python 3 series has been determining a sensible
  425. default strategy for handling the “7-bit ASCII” text encoding assumption
  426. currently implied by the use of the default C or POSIX locale on non-Windows
  427. platforms.</p>
  428. <p><span class="target" id="index-3"></span><a class="pep reference external" href="https://peps.python.org/pep-0538/"><strong>PEP 538</strong></a> updates the default interpreter command line interface to
  429. automatically coerce that locale to an available UTF-8 based locale as
  430. described in the documentation of the new <span class="target" id="index-4"></span><a class="reference internal" href="../using/cmdline.html#envvar-PYTHONCOERCECLOCALE"><code class="xref std std-envvar docutils literal notranslate"><span class="pre">PYTHONCOERCECLOCALE</span></code></a>
  431. environment variable. Automatically setting <code class="docutils literal notranslate"><span class="pre">LC_CTYPE</span></code> this way means that
  432. both the core interpreter and locale-aware C extensions (such as
  433. <a class="reference internal" href="../library/readline.html#module-readline" title="readline: GNU readline support for Python. (Unix)"><code class="xref py py-mod docutils literal notranslate"><span class="pre">readline</span></code></a>) will assume the use of UTF-8 as the default text encoding,
  434. rather than ASCII.</p>
  435. <p>The platform support definition in <span class="target" id="index-5"></span><a class="pep reference external" href="https://peps.python.org/pep-0011/"><strong>PEP 11</strong></a> has also been updated to limit
  436. full text handling support to suitably configured non-ASCII based locales.</p>
  437. <p>As part of this change, the default error handler for <a class="reference internal" href="../library/sys.html#sys.stdin" title="sys.stdin"><code class="xref py py-data docutils literal notranslate"><span class="pre">stdin</span></code></a> and
  438. <a class="reference internal" href="../library/sys.html#sys.stdout" title="sys.stdout"><code class="xref py py-data docutils literal notranslate"><span class="pre">stdout</span></code></a> is now <code class="docutils literal notranslate"><span class="pre">surrogateescape</span></code> (rather than <code class="docutils literal notranslate"><span class="pre">strict</span></code>) when
  439. using any of the defined coercion target locales (currently <code class="docutils literal notranslate"><span class="pre">C.UTF-8</span></code>,
  440. <code class="docutils literal notranslate"><span class="pre">C.utf8</span></code>, and <code class="docutils literal notranslate"><span class="pre">UTF-8</span></code>). The default error handler for <a class="reference internal" href="../library/sys.html#sys.stderr" title="sys.stderr"><code class="xref py py-data docutils literal notranslate"><span class="pre">stderr</span></code></a>
  441. continues to be <code class="docutils literal notranslate"><span class="pre">backslashreplace</span></code>, regardless of locale.</p>
  442. <p>Locale coercion is silent by default, but to assist in debugging potentially
  443. locale related integration problems, explicit warnings (emitted directly on
  444. <a class="reference internal" href="../library/sys.html#sys.stderr" title="sys.stderr"><code class="xref py py-data docutils literal notranslate"><span class="pre">stderr</span></code></a>) can be requested by setting <code class="docutils literal notranslate"><span class="pre">PYTHONCOERCECLOCALE=warn</span></code>.
  445. This setting will also cause the Python runtime to emit a warning if the
  446. legacy C locale remains active when the core interpreter is initialized.</p>
  447. <p>While <span class="target" id="index-6"></span><a class="pep reference external" href="https://peps.python.org/pep-0538/"><strong>PEP 538</strong></a>’s locale coercion has the benefit of also affecting extension
  448. modules (such as GNU <code class="docutils literal notranslate"><span class="pre">readline</span></code>), as well as child processes (including those
  449. running non-Python applications and older versions of Python), it has the
  450. downside of requiring that a suitable target locale be present on the running
  451. system. To better handle the case where no suitable target locale is available
  452. (as occurs on RHEL/CentOS 7, for example), Python 3.7 also implements
  453. <a class="reference internal" href="#whatsnew37-pep540"><span class="std std-ref">PEP 540: Forced UTF-8 Runtime Mode</span></a>.</p>
  454. <div class="admonition seealso">
  455. <p class="admonition-title">See also</p>
  456. <dl class="simple">
  457. <dt><span class="target" id="index-7"></span><a class="pep reference external" href="https://peps.python.org/pep-0538/"><strong>PEP 538</strong></a> – Coercing the legacy C locale to a UTF-8 based locale</dt><dd><p>PEP written and implemented by Nick Coghlan.</p>
  458. </dd>
  459. </dl>
  460. </div>
  461. </section>
  462. <section id="pep-540-forced-utf-8-runtime-mode">
  463. <span id="whatsnew37-pep540"></span><h3>PEP 540: Forced UTF-8 Runtime Mode<a class="headerlink" href="#pep-540-forced-utf-8-runtime-mode" title="Link to this heading">¶</a></h3>
  464. <p>The new <a class="reference internal" href="../using/cmdline.html#cmdoption-X"><code class="xref std std-option docutils literal notranslate"><span class="pre">-X</span></code></a> <code class="docutils literal notranslate"><span class="pre">utf8</span></code> command line option and <span class="target" id="index-8"></span><a class="reference internal" href="../using/cmdline.html#envvar-PYTHONUTF8"><code class="xref std std-envvar docutils literal notranslate"><span class="pre">PYTHONUTF8</span></code></a>
  465. environment variable can be used to enable the <a class="reference internal" href="../library/os.html#utf8-mode"><span class="std std-ref">Python UTF-8 Mode</span></a>.</p>
  466. <p>When in UTF-8 mode, CPython ignores the locale settings, and uses the
  467. UTF-8 encoding by default. The error handlers for <a class="reference internal" href="../library/sys.html#sys.stdin" title="sys.stdin"><code class="xref py py-data docutils literal notranslate"><span class="pre">sys.stdin</span></code></a> and
  468. <a class="reference internal" href="../library/sys.html#sys.stdout" title="sys.stdout"><code class="xref py py-data docutils literal notranslate"><span class="pre">sys.stdout</span></code></a> streams are set to <code class="docutils literal notranslate"><span class="pre">surrogateescape</span></code>.</p>
  469. <p>The forced UTF-8 mode can be used to change the text handling behavior in
  470. an embedded Python interpreter without changing the locale settings of
  471. an embedding application.</p>
  472. <p>While <span class="target" id="index-9"></span><a class="pep reference external" href="https://peps.python.org/pep-0540/"><strong>PEP 540</strong></a>’s UTF-8 mode has the benefit of working regardless of which
  473. locales are available on the running system, it has the downside of having no
  474. effect on extension modules (such as GNU <code class="docutils literal notranslate"><span class="pre">readline</span></code>), child processes running
  475. non-Python applications, and child processes running older versions of Python.
  476. To reduce the risk of corrupting text data when communicating with such
  477. components, Python 3.7 also implements <a class="reference internal" href="#whatsnew37-pep540"><span class="std std-ref">PEP 540: Forced UTF-8 Runtime Mode</span></a>).</p>
  478. <p>The UTF-8 mode is enabled by default when the locale is <code class="docutils literal notranslate"><span class="pre">C</span></code> or <code class="docutils literal notranslate"><span class="pre">POSIX</span></code>, and
  479. the <span class="target" id="index-10"></span><a class="pep reference external" href="https://peps.python.org/pep-0538/"><strong>PEP 538</strong></a> locale coercion feature fails to change it to a UTF-8 based
  480. alternative (whether that failure is due to <code class="docutils literal notranslate"><span class="pre">PYTHONCOERCECLOCALE=0</span></code> being set,
  481. <code class="docutils literal notranslate"><span class="pre">LC_ALL</span></code> being set, or the lack of a suitable target locale).</p>
  482. <div class="admonition seealso">
  483. <p class="admonition-title">See also</p>
  484. <dl class="simple">
  485. <dt><span class="target" id="index-11"></span><a class="pep reference external" href="https://peps.python.org/pep-0540/"><strong>PEP 540</strong></a> – Add a new UTF-8 mode</dt><dd><p>PEP written and implemented by Victor Stinner</p>
  486. </dd>
  487. </dl>
  488. </div>
  489. </section>
  490. <section id="pep-553-built-in-breakpoint">
  491. <span id="whatsnew37-pep553"></span><h3>PEP 553: Built-in <code class="docutils literal notranslate"><span class="pre">breakpoint()</span></code><a class="headerlink" href="#pep-553-built-in-breakpoint" title="Link to this heading">¶</a></h3>
  492. <p>Python 3.7 includes the new built-in <a class="reference internal" href="../library/functions.html#breakpoint" title="breakpoint"><code class="xref py py-func docutils literal notranslate"><span class="pre">breakpoint()</span></code></a> function as
  493. an easy and consistent way to enter the Python debugger.</p>
  494. <p>Built-in <code class="docutils literal notranslate"><span class="pre">breakpoint()</span></code> calls <a class="reference internal" href="../library/sys.html#sys.breakpointhook" title="sys.breakpointhook"><code class="xref py py-func docutils literal notranslate"><span class="pre">sys.breakpointhook()</span></code></a>. By default, the
  495. latter imports <a class="reference internal" href="../library/pdb.html#module-pdb" title="pdb: The Python debugger for interactive interpreters."><code class="xref py py-mod docutils literal notranslate"><span class="pre">pdb</span></code></a> and then calls <code class="docutils literal notranslate"><span class="pre">pdb.set_trace()</span></code>, but by binding
  496. <code class="docutils literal notranslate"><span class="pre">sys.breakpointhook()</span></code> to the function of your choosing, <code class="docutils literal notranslate"><span class="pre">breakpoint()</span></code> can
  497. enter any debugger. Additionally, the environment variable
  498. <span class="target" id="index-12"></span><a class="reference internal" href="../using/cmdline.html#envvar-PYTHONBREAKPOINT"><code class="xref std std-envvar docutils literal notranslate"><span class="pre">PYTHONBREAKPOINT</span></code></a> can be set to the callable of your debugger of
  499. choice. Set <code class="docutils literal notranslate"><span class="pre">PYTHONBREAKPOINT=0</span></code> to completely disable built-in
  500. <code class="docutils literal notranslate"><span class="pre">breakpoint()</span></code>.</p>
  501. <div class="admonition seealso">
  502. <p class="admonition-title">See also</p>
  503. <dl class="simple">
  504. <dt><span class="target" id="index-13"></span><a class="pep reference external" href="https://peps.python.org/pep-0553/"><strong>PEP 553</strong></a> – Built-in breakpoint()</dt><dd><p>PEP written and implemented by Barry Warsaw</p>
  505. </dd>
  506. </dl>
  507. </div>
  508. </section>
  509. <section id="pep-539-new-c-api-for-thread-local-storage">
  510. <span id="whatsnew37-pep539"></span><h3>PEP 539: New C API for Thread-Local Storage<a class="headerlink" href="#pep-539-new-c-api-for-thread-local-storage" title="Link to this heading">¶</a></h3>
  511. <p>While Python provides a C API for thread-local storage support; the existing
  512. <a class="reference internal" href="../c-api/init.html#thread-local-storage-api"><span class="std std-ref">Thread Local Storage (TLS) API</span></a> has used
  513. <span class="c-expr sig sig-inline c"><span class="kt">int</span></span> to represent TLS keys across all platforms. This has not
  514. generally been a problem for officially support platforms, but that is neither
  515. POSIX-compliant, nor portable in any practical sense.</p>
  516. <p><span class="target" id="index-14"></span><a class="pep reference external" href="https://peps.python.org/pep-0539/"><strong>PEP 539</strong></a> changes this by providing a new <a class="reference internal" href="../c-api/init.html#thread-specific-storage-api"><span class="std std-ref">Thread Specific Storage (TSS)
  517. API</span></a> to CPython which supersedes use of the
  518. existing TLS API within the CPython interpreter, while deprecating the existing
  519. API. The TSS API uses a new type <a class="reference internal" href="../c-api/init.html#c.Py_tss_t" title="Py_tss_t"><code class="xref c c-type docutils literal notranslate"><span class="pre">Py_tss_t</span></code></a> instead of <span class="c-expr sig sig-inline c"><span class="kt">int</span></span>
  520. to represent TSS keys–an opaque type the definition of which may depend on
  521. the underlying TLS implementation. Therefore, this will allow to build CPython
  522. on platforms where the native TLS key is defined in a way that cannot be safely
  523. cast to <span class="c-expr sig sig-inline c"><span class="kt">int</span></span>.</p>
  524. <p>Note that on platforms where the native TLS key is defined in a way that cannot
  525. be safely cast to <span class="c-expr sig sig-inline c"><span class="kt">int</span></span>, all functions of the existing TLS API will be
  526. no-op and immediately return failure. This indicates clearly that the old API
  527. is not supported on platforms where it cannot be used reliably, and that no
  528. effort will be made to add such support.</p>
  529. <div class="admonition seealso">
  530. <p class="admonition-title">See also</p>
  531. <dl class="simple">
  532. <dt><span class="target" id="index-15"></span><a class="pep reference external" href="https://peps.python.org/pep-0539/"><strong>PEP 539</strong></a> – A New C-API for Thread-Local Storage in CPython</dt><dd><p>PEP written by Erik M. Bray; implementation by Masayuki Yamamoto.</p>
  533. </dd>
  534. </dl>
  535. </div>
  536. </section>
  537. <section id="pep-562-customization-of-access-to-module-attributes">
  538. <span id="whatsnew37-pep562"></span><h3>PEP 562: Customization of Access to Module Attributes<a class="headerlink" href="#pep-562-customization-of-access-to-module-attributes" title="Link to this heading">¶</a></h3>
  539. <p>Python 3.7 allows defining <code class="xref py py-meth docutils literal notranslate"><span class="pre">__getattr__()</span></code> on modules and will call
  540. it whenever a module attribute is otherwise not found. Defining
  541. <code class="xref py py-meth docutils literal notranslate"><span class="pre">__dir__()</span></code> on modules is now also allowed.</p>
  542. <p>A typical example of where this may be useful is module attribute deprecation
  543. and lazy loading.</p>
  544. <div class="admonition seealso">
  545. <p class="admonition-title">See also</p>
  546. <dl class="simple">
  547. <dt><span class="target" id="index-16"></span><a class="pep reference external" href="https://peps.python.org/pep-0562/"><strong>PEP 562</strong></a> – Module <code class="docutils literal notranslate"><span class="pre">__getattr__</span></code> and <code class="docutils literal notranslate"><span class="pre">__dir__</span></code></dt><dd><p>PEP written and implemented by Ivan Levkivskyi</p>
  548. </dd>
  549. </dl>
  550. </div>
  551. </section>
  552. <section id="pep-564-new-time-functions-with-nanosecond-resolution">
  553. <span id="whatsnew37-pep564"></span><h3>PEP 564: New Time Functions With Nanosecond Resolution<a class="headerlink" href="#pep-564-new-time-functions-with-nanosecond-resolution" title="Link to this heading">¶</a></h3>
  554. <p>The resolution of clocks in modern systems can exceed the limited precision
  555. of a floating point number returned by the <a class="reference internal" href="../library/time.html#time.time" title="time.time"><code class="xref py py-func docutils literal notranslate"><span class="pre">time.time()</span></code></a> function
  556. and its variants. To avoid loss of precision, <span class="target" id="index-17"></span><a class="pep reference external" href="https://peps.python.org/pep-0564/"><strong>PEP 564</strong></a> adds six new
  557. “nanosecond” variants of the existing timer functions to the <a class="reference internal" href="../library/time.html#module-time" title="time: Time access and conversions."><code class="xref py py-mod docutils literal notranslate"><span class="pre">time</span></code></a>
  558. module:</p>
  559. <ul class="simple">
  560. <li><p><a class="reference internal" href="../library/time.html#time.clock_gettime_ns" title="time.clock_gettime_ns"><code class="xref py py-func docutils literal notranslate"><span class="pre">time.clock_gettime_ns()</span></code></a></p></li>
  561. <li><p><a class="reference internal" href="../library/time.html#time.clock_settime_ns" title="time.clock_settime_ns"><code class="xref py py-func docutils literal notranslate"><span class="pre">time.clock_settime_ns()</span></code></a></p></li>
  562. <li><p><a class="reference internal" href="../library/time.html#time.monotonic_ns" title="time.monotonic_ns"><code class="xref py py-func docutils literal notranslate"><span class="pre">time.monotonic_ns()</span></code></a></p></li>
  563. <li><p><a class="reference internal" href="../library/time.html#time.perf_counter_ns" title="time.perf_counter_ns"><code class="xref py py-func docutils literal notranslate"><span class="pre">time.perf_counter_ns()</span></code></a></p></li>
  564. <li><p><a class="reference internal" href="../library/time.html#time.process_time_ns" title="time.process_time_ns"><code class="xref py py-func docutils literal notranslate"><span class="pre">time.process_time_ns()</span></code></a></p></li>
  565. <li><p><a class="reference internal" href="../library/time.html#time.time_ns" title="time.time_ns"><code class="xref py py-func docutils literal notranslate"><span class="pre">time.time_ns()</span></code></a></p></li>
  566. </ul>
  567. <p>The new functions return the number of nanoseconds as an integer value.</p>
  568. <p><a class="reference external" href="https://peps.python.org/pep-0564/#annex-clocks-resolution-in-python">Measurements</a>
  569. show that on Linux and Windows the resolution of <a class="reference internal" href="../library/time.html#time.time_ns" title="time.time_ns"><code class="xref py py-func docutils literal notranslate"><span class="pre">time.time_ns()</span></code></a> is
  570. approximately 3 times better than that of <a class="reference internal" href="../library/time.html#time.time" title="time.time"><code class="xref py py-func docutils literal notranslate"><span class="pre">time.time()</span></code></a>.</p>
  571. <div class="admonition seealso">
  572. <p class="admonition-title">See also</p>
  573. <dl class="simple">
  574. <dt><span class="target" id="index-18"></span><a class="pep reference external" href="https://peps.python.org/pep-0564/"><strong>PEP 564</strong></a> – Add new time functions with nanosecond resolution</dt><dd><p>PEP written and implemented by Victor Stinner</p>
  575. </dd>
  576. </dl>
  577. </div>
  578. </section>
  579. <section id="pep-565-show-deprecationwarning-in-main">
  580. <span id="whatsnew37-pep565"></span><h3>PEP 565: Show DeprecationWarning in <code class="docutils literal notranslate"><span class="pre">__main__</span></code><a class="headerlink" href="#pep-565-show-deprecationwarning-in-main" title="Link to this heading">¶</a></h3>
  581. <p>The default handling of <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> has been changed such that
  582. these warnings are once more shown by default, but only when the code
  583. triggering them is running directly in the <a class="reference internal" href="../library/__main__.html#module-__main__" title="__main__: The environment where top-level code is run. Covers command-line interfaces, import-time behavior, and ``__name__ == '__main__'``."><code class="xref py py-mod docutils literal notranslate"><span class="pre">__main__</span></code></a> module. As a result,
  584. developers of single file scripts and those using Python interactively should
  585. once again start seeing deprecation warnings for the APIs they use, but
  586. deprecation warnings triggered by imported application, library and framework
  587. modules will continue to be hidden by default.</p>
  588. <p>As a result of this change, the standard library now allows developers to choose
  589. between three different deprecation warning behaviours:</p>
  590. <ul class="simple">
  591. <li><p><a class="reference internal" href="../library/exceptions.html#FutureWarning" title="FutureWarning"><code class="xref py py-exc docutils literal notranslate"><span class="pre">FutureWarning</span></code></a>: always displayed by default, recommended for warnings
  592. intended to be seen by application end users (e.g. for deprecated application
  593. configuration settings).</p></li>
  594. <li><p><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>: displayed by default only in <a class="reference internal" href="../library/__main__.html#module-__main__" title="__main__: The environment where top-level code is run. Covers command-line interfaces, import-time behavior, and ``__name__ == '__main__'``."><code class="xref py py-mod docutils literal notranslate"><span class="pre">__main__</span></code></a> and when
  595. running tests, recommended for warnings intended to be seen by other Python
  596. developers where a version upgrade may result in changed behaviour or an
  597. error.</p></li>
  598. <li><p><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>: displayed by default only when running
  599. tests, intended for cases where a future version upgrade will change the
  600. warning category to <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> or <a class="reference internal" href="../library/exceptions.html#FutureWarning" title="FutureWarning"><code class="xref py py-exc docutils literal notranslate"><span class="pre">FutureWarning</span></code></a>.</p></li>
  601. </ul>
  602. <p>Previously both <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 <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>
  603. were only visible when running tests, which meant that developers primarily
  604. writing single file scripts or using Python interactively could be surprised
  605. by breaking changes in the APIs they used.</p>
  606. <div class="admonition seealso">
  607. <p class="admonition-title">See also</p>
  608. <dl class="simple">
  609. <dt><span class="target" id="index-19"></span><a class="pep reference external" href="https://peps.python.org/pep-0565/"><strong>PEP 565</strong></a> – Show DeprecationWarning in <code class="docutils literal notranslate"><span class="pre">__main__</span></code></dt><dd><p>PEP written and implemented by Nick Coghlan</p>
  610. </dd>
  611. </dl>
  612. </div>
  613. </section>
  614. <section id="pep-560-core-support-for-typing-module-and-generic-types">
  615. <span id="whatsnew37-pep560"></span><h3>PEP 560: Core Support for <code class="docutils literal notranslate"><span class="pre">typing</span></code> module and Generic Types<a class="headerlink" href="#pep-560-core-support-for-typing-module-and-generic-types" title="Link to this heading">¶</a></h3>
  616. <p>Initially <span class="target" id="index-20"></span><a class="pep reference external" href="https://peps.python.org/pep-0484/"><strong>PEP 484</strong></a> was designed in such way that it would not introduce <em>any</em>
  617. changes to the core CPython interpreter. Now type hints and 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>
  618. module are extensively used by the community, so this restriction is removed.
  619. The PEP introduces two special methods <code class="xref py py-meth docutils literal notranslate"><span class="pre">__class_getitem__()</span></code> and
  620. <code class="docutils literal notranslate"><span class="pre">__mro_entries__</span></code>, these methods are now used by most classes and special
  621. constructs in <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>. As a result, the speed of various operations
  622. with types increased up to 7 times, the generic types can be used without
  623. metaclass conflicts, and several long standing bugs in <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 are
  624. fixed.</p>
  625. <div class="admonition seealso">
  626. <p class="admonition-title">See also</p>
  627. <dl class="simple">
  628. <dt><span class="target" id="index-21"></span><a class="pep reference external" href="https://peps.python.org/pep-0560/"><strong>PEP 560</strong></a> – Core support for typing module and generic types</dt><dd><p>PEP written and implemented by Ivan Levkivskyi</p>
  629. </dd>
  630. </dl>
  631. </div>
  632. </section>
  633. <section id="pep-552-hash-based-pyc-files">
  634. <span id="whatsnew37-pep552"></span><h3>PEP 552: Hash-based .pyc Files<a class="headerlink" href="#pep-552-hash-based-pyc-files" title="Link to this heading">¶</a></h3>
  635. <p>Python has traditionally checked the up-to-dateness of bytecode cache files
  636. (i.e., <code class="docutils literal notranslate"><span class="pre">.pyc</span></code> files) by comparing the source metadata (last-modified timestamp
  637. and size) with source metadata saved in the cache file header when it was
  638. generated. While effective, this invalidation method has its drawbacks. When
  639. filesystem timestamps are too coarse, Python can miss source updates, leading to
  640. user confusion. Additionally, having a timestamp in the cache file is
  641. problematic for <a class="reference external" href="https://reproducible-builds.org/">build reproducibility</a> and
  642. content-based build systems.</p>
  643. <p><span class="target" id="index-22"></span><a class="pep reference external" href="https://peps.python.org/pep-0552/"><strong>PEP 552</strong></a> extends the pyc format to allow the hash of the source file to be
  644. used for invalidation instead of the source timestamp. Such <code class="docutils literal notranslate"><span class="pre">.pyc</span></code> files are
  645. called “hash-based”. By default, Python still uses timestamp-based invalidation
  646. and does not generate hash-based <code class="docutils literal notranslate"><span class="pre">.pyc</span></code> files at runtime. Hash-based <code class="docutils literal notranslate"><span class="pre">.pyc</span></code>
  647. files may be generated with <a class="reference internal" href="../library/py_compile.html#module-py_compile" title="py_compile: Generate byte-code files from Python source files."><code class="xref py py-mod docutils literal notranslate"><span class="pre">py_compile</span></code></a> or <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>.</p>
  648. <p>Hash-based <code class="docutils literal notranslate"><span class="pre">.pyc</span></code> files come in two variants: checked and unchecked. Python
  649. validates checked hash-based <code class="docutils literal notranslate"><span class="pre">.pyc</span></code> files against the corresponding source
  650. files at runtime but doesn’t do so for unchecked hash-based pycs. Unchecked
  651. hash-based <code class="docutils literal notranslate"><span class="pre">.pyc</span></code> files are a useful performance optimization for environments
  652. where a system external to Python (e.g., the build system) is responsible for
  653. keeping <code class="docutils literal notranslate"><span class="pre">.pyc</span></code> files up-to-date.</p>
  654. <p>See <a class="reference internal" href="../reference/import.html#pyc-invalidation"><span class="std std-ref">Cached bytecode invalidation</span></a> for more information.</p>
  655. <div class="admonition seealso">
  656. <p class="admonition-title">See also</p>
  657. <dl class="simple">
  658. <dt><span class="target" id="index-23"></span><a class="pep reference external" href="https://peps.python.org/pep-0552/"><strong>PEP 552</strong></a> – Deterministic pycs</dt><dd><p>PEP written and implemented by Benjamin Peterson</p>
  659. </dd>
  660. </dl>
  661. </div>
  662. </section>
  663. <section id="pep-545-python-documentation-translations">
  664. <span id="whatsnew37-pep545"></span><h3>PEP 545: Python Documentation Translations<a class="headerlink" href="#pep-545-python-documentation-translations" title="Link to this heading">¶</a></h3>
  665. <p><span class="target" id="index-24"></span><a class="pep reference external" href="https://peps.python.org/pep-0545/"><strong>PEP 545</strong></a> describes the process of creating and maintaining Python
  666. documentation translations.</p>
  667. <p>Three new translations have been added:</p>
  668. <ul class="simple">
  669. <li><p>Japanese: <a class="reference external" href="https://docs.python.org/ja/">https://docs.python.org/ja/</a></p></li>
  670. <li><p>French: <a class="reference external" href="https://docs.python.org/fr/">https://docs.python.org/fr/</a></p></li>
  671. <li><p>Korean: <a class="reference external" href="https://docs.python.org/ko/">https://docs.python.org/ko/</a></p></li>
  672. </ul>
  673. <div class="admonition seealso">
  674. <p class="admonition-title">See also</p>
  675. <dl class="simple">
  676. <dt><span class="target" id="index-25"></span><a class="pep reference external" href="https://peps.python.org/pep-0545/"><strong>PEP 545</strong></a> – Python Documentation Translations</dt><dd><p>PEP written and implemented by Julien Palard, Inada Naoki, and
  677. Victor Stinner.</p>
  678. </dd>
  679. </dl>
  680. </div>
  681. </section>
  682. <section id="python-development-mode-x-dev">
  683. <span id="whatsnew37-devmode"></span><h3>Python Development Mode (-X dev)<a class="headerlink" href="#python-development-mode-x-dev" title="Link to this heading">¶</a></h3>
  684. <p>The new <a class="reference internal" href="../using/cmdline.html#cmdoption-X"><code class="xref std std-option docutils literal notranslate"><span class="pre">-X</span></code></a> <code class="docutils literal notranslate"><span class="pre">dev</span></code> command line option or the new
  685. <span class="target" id="index-26"></span><a class="reference internal" href="../using/cmdline.html#envvar-PYTHONDEVMODE"><code class="xref std std-envvar docutils literal notranslate"><span class="pre">PYTHONDEVMODE</span></code></a> environment variable can be used to enable
  686. <a class="reference internal" href="../library/devmode.html#devmode"><span class="std std-ref">Python Development Mode</span></a>. When in development mode, Python performs
  687. additional runtime checks that are too expensive to be enabled by default.
  688. See <a class="reference internal" href="../library/devmode.html#devmode"><span class="std std-ref">Python Development Mode</span></a> documentation for the full
  689. description.</p>
  690. </section>
  691. </section>
  692. <section id="other-language-changes">
  693. <h2>Other Language Changes<a class="headerlink" href="#other-language-changes" title="Link to this heading">¶</a></h2>
  694. <ul class="simple">
  695. <li><p>An <a class="reference internal" href="../reference/expressions.html#await"><code class="xref std std-keyword docutils literal notranslate"><span class="pre">await</span></code></a> expression and comprehensions containing an
  696. <a class="reference internal" href="../reference/compound_stmts.html#async-for"><code class="xref std std-keyword docutils literal notranslate"><span class="pre">async</span> <span class="pre">for</span></code></a> clause were illegal in the expressions in
  697. <a class="reference internal" href="../reference/lexical_analysis.html#f-strings"><span class="std std-ref">formatted string literals</span></a> due to a problem with the
  698. implementation. In Python 3.7 this restriction was lifted.</p></li>
  699. <li><p>More than 255 arguments can now be passed to a function, and a function can
  700. now have more than 255 parameters. (Contributed by Serhiy Storchaka in
  701. <a class="reference external" href="https://bugs.python.org/issue?&#64;action=redirect&amp;bpo=12844">bpo-12844</a> and <a class="reference external" href="https://bugs.python.org/issue?&#64;action=redirect&amp;bpo=18896">bpo-18896</a>.)</p></li>
  702. <li><p><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> now ignore all ASCII
  703. whitespace, not only spaces. (Contributed by Robert Xiao in <a class="reference external" href="https://bugs.python.org/issue?&#64;action=redirect&amp;bpo=28927">bpo-28927</a>.)</p></li>
  704. <li><p><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>, <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>, and <a class="reference internal" href="../library/stdtypes.html#bytearray" title="bytearray"><code class="xref py py-class docutils literal notranslate"><span class="pre">bytearray</span></code></a> gained support for
  705. the new <a class="reference internal" href="../library/stdtypes.html#str.isascii" title="str.isascii"><code class="xref py py-meth docutils literal notranslate"><span class="pre">isascii()</span></code></a> method, which can be used to
  706. test if a string or bytes contain only the ASCII characters.
  707. (Contributed by INADA Naoki in <a class="reference external" href="https://bugs.python.org/issue?&#64;action=redirect&amp;bpo=32677">bpo-32677</a>.)</p></li>
  708. <li><p><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> now displays module name and module <code class="docutils literal notranslate"><span class="pre">__file__</span></code> path when
  709. <code class="docutils literal notranslate"><span class="pre">from</span> <span class="pre">...</span> <span class="pre">import</span> <span class="pre">...</span></code> fails. (Contributed by Matthias Bussonnier in
  710. <a class="reference external" href="https://bugs.python.org/issue?&#64;action=redirect&amp;bpo=29546">bpo-29546</a>.)</p></li>
  711. <li><p>Circular imports involving absolute imports with binding a submodule to
  712. a name are now supported.
  713. (Contributed by Serhiy Storchaka in <a class="reference external" href="https://bugs.python.org/issue?&#64;action=redirect&amp;bpo=30024">bpo-30024</a>.)</p></li>
  714. <li><p><code class="docutils literal notranslate"><span class="pre">object.__format__(x,</span> <span class="pre">'')</span></code> is now equivalent to <code class="docutils literal notranslate"><span class="pre">str(x)</span></code> rather than
  715. <code class="docutils literal notranslate"><span class="pre">format(str(self),</span> <span class="pre">'')</span></code>.
  716. (Contributed by Serhiy Storchaka in <a class="reference external" href="https://bugs.python.org/issue?&#64;action=redirect&amp;bpo=28974">bpo-28974</a>.)</p></li>
  717. <li><p>In order to better support dynamic creation of stack traces,
  718. <a class="reference internal" href="../library/types.html#types.TracebackType" title="types.TracebackType"><code class="xref py py-class docutils literal notranslate"><span class="pre">types.TracebackType</span></code></a> can now be instantiated from Python code, and
  719. the <a class="reference internal" href="../reference/datamodel.html#traceback.tb_next" title="traceback.tb_next"><code class="xref py py-attr docutils literal notranslate"><span class="pre">tb_next</span></code></a> attribute on
  720. <a class="reference internal" href="../reference/datamodel.html#traceback-objects"><span class="std std-ref">tracebacks</span></a> is now writable.
  721. (Contributed by Nathaniel J. Smith in <a class="reference external" href="https://bugs.python.org/issue?&#64;action=redirect&amp;bpo=30579">bpo-30579</a>.)</p></li>
  722. <li><p>When using the <a class="reference internal" href="../using/cmdline.html#cmdoption-m"><code class="xref std std-option docutils literal notranslate"><span class="pre">-m</span></code></a> switch, <code class="docutils literal notranslate"><span class="pre">sys.path[0]</span></code> is now eagerly expanded
  723. to the full starting directory path, rather than being left as the empty
  724. directory (which allows imports from the <em>current</em> working directory at the
  725. time when an import occurs)
  726. (Contributed by Nick Coghlan in <a class="reference external" href="https://bugs.python.org/issue?&#64;action=redirect&amp;bpo=33053">bpo-33053</a>.)</p></li>
  727. <li><p>The new <a class="reference internal" href="../using/cmdline.html#cmdoption-X"><code class="xref std std-option docutils literal notranslate"><span class="pre">-X</span></code></a> <code class="docutils literal notranslate"><span class="pre">importtime</span></code> option or the
  728. <span class="target" id="index-27"></span><a class="reference internal" href="../using/cmdline.html#envvar-PYTHONPROFILEIMPORTTIME"><code class="xref std std-envvar docutils literal notranslate"><span class="pre">PYTHONPROFILEIMPORTTIME</span></code></a> environment variable can be used to show
  729. the timing of each module import.
  730. (Contributed by Inada Naoki in <a class="reference external" href="https://bugs.python.org/issue?&#64;action=redirect&amp;bpo=31415">bpo-31415</a>.)</p></li>
  731. </ul>
  732. </section>
  733. <section id="new-modules">
  734. <h2>New Modules<a class="headerlink" href="#new-modules" title="Link to this heading">¶</a></h2>
  735. <section id="contextvars">
  736. <span id="whatsnew37-pep567"></span><h3>contextvars<a class="headerlink" href="#contextvars" title="Link to this heading">¶</a></h3>
  737. <p>The new <a class="reference internal" href="../library/contextvars.html#module-contextvars" title="contextvars: Context Variables"><code class="xref py py-mod docutils literal notranslate"><span class="pre">contextvars</span></code></a> module and a set of
  738. <a class="reference internal" href="../c-api/contextvars.html#contextvarsobjects"><span class="std std-ref">new C APIs</span></a> introduce
  739. support for <em>context variables</em>. Context variables are conceptually
  740. similar to thread-local variables. Unlike TLS, context variables
  741. support asynchronous code correctly.</p>
  742. <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> and <a class="reference internal" href="../library/decimal.html#module-decimal" title="decimal: Implementation of the General Decimal Arithmetic Specification."><code class="xref py py-mod docutils literal notranslate"><span class="pre">decimal</span></code></a> modules have been updated to use
  743. and support context variables out of the box. Particularly the active
  744. decimal context is now stored in a context variable, which allows
  745. decimal operations to work with the correct context in asynchronous code.</p>
  746. <div class="admonition seealso">
  747. <p class="admonition-title">See also</p>
  748. <dl class="simple">
  749. <dt><span class="target" id="index-28"></span><a class="pep reference external" href="https://peps.python.org/pep-0567/"><strong>PEP 567</strong></a> – Context Variables</dt><dd><p>PEP written and implemented by Yury Selivanov</p>
  750. </dd>
  751. </dl>
  752. </div>
  753. </section>
  754. <section id="dataclasses">
  755. <span id="whatsnew37-pep557"></span><h3>dataclasses<a class="headerlink" href="#dataclasses" title="Link to this heading">¶</a></h3>
  756. <p>The new <a class="reference internal" href="../library/dataclasses.html#dataclasses.dataclass" title="dataclasses.dataclass"><code class="xref py py-func docutils literal notranslate"><span class="pre">dataclass()</span></code></a> decorator provides a way to declare
  757. <em>data classes</em>. A data class describes its attributes using class variable
  758. annotations. Its constructor and other magic methods, such as
  759. <a class="reference internal" href="../reference/datamodel.html#object.__repr__" title="object.__repr__"><code class="xref py py-meth docutils literal notranslate"><span class="pre">__repr__()</span></code></a>, <a class="reference internal" href="../reference/datamodel.html#object.__eq__" title="object.__eq__"><code class="xref py py-meth docutils literal notranslate"><span class="pre">__eq__()</span></code></a>, and
  760. <a class="reference internal" href="../reference/datamodel.html#object.__hash__" title="object.__hash__"><code class="xref py py-meth docutils literal notranslate"><span class="pre">__hash__()</span></code></a> are generated automatically.</p>
  761. <p>Example:</p>
  762. <div class="highlight-python3 notranslate"><div class="highlight"><pre><span></span><span class="nd">@dataclass</span>
  763. <span class="k">class</span> <span class="nc">Point</span><span class="p">:</span>
  764. <span class="n">x</span><span class="p">:</span> <span class="nb">float</span>
  765. <span class="n">y</span><span class="p">:</span> <span class="nb">float</span>
  766. <span class="n">z</span><span class="p">:</span> <span class="nb">float</span> <span class="o">=</span> <span class="mf">0.0</span>
  767. <span class="n">p</span> <span class="o">=</span> <span class="n">Point</span><span class="p">(</span><span class="mf">1.5</span><span class="p">,</span> <span class="mf">2.5</span><span class="p">)</span>
  768. <span class="nb">print</span><span class="p">(</span><span class="n">p</span><span class="p">)</span> <span class="c1"># produces &quot;Point(x=1.5, y=2.5, z=0.0)&quot;</span>
  769. </pre></div>
  770. </div>
  771. <div class="admonition seealso">
  772. <p class="admonition-title">See also</p>
  773. <dl class="simple">
  774. <dt><span class="target" id="index-29"></span><a class="pep reference external" href="https://peps.python.org/pep-0557/"><strong>PEP 557</strong></a> – Data Classes</dt><dd><p>PEP written and implemented by Eric V. Smith</p>
  775. </dd>
  776. </dl>
  777. </div>
  778. </section>
  779. <section id="importlib-resources">
  780. <span id="whatsnew37-importlib-resources"></span><h3>importlib.resources<a class="headerlink" href="#importlib-resources" title="Link to this heading">¶</a></h3>
  781. <p>The new <a class="reference internal" href="../library/importlib.resources.html#module-importlib.resources" title="importlib.resources: Package resource reading, opening, and access"><code class="xref py py-mod docutils literal notranslate"><span class="pre">importlib.resources</span></code></a> module provides several new APIs and one
  782. new ABC for access to, opening, and reading <em>resources</em> inside packages.
  783. Resources are roughly similar to files inside packages, but they needn’t
  784. be actual files on the physical file system. Module loaders can provide a
  785. <code class="xref py py-meth docutils literal notranslate"><span class="pre">get_resource_reader()</span></code> function which returns
  786. a <a class="reference internal" href="../library/importlib.html#importlib.abc.ResourceReader" title="importlib.abc.ResourceReader"><code class="xref py py-class docutils literal notranslate"><span class="pre">importlib.abc.ResourceReader</span></code></a> instance to support this
  787. new API. Built-in file path loaders and zip file loaders both support this.</p>
  788. <p>Contributed by Barry Warsaw and Brett Cannon in <a class="reference external" href="https://bugs.python.org/issue?&#64;action=redirect&amp;bpo=32248">bpo-32248</a>.</p>
  789. <div class="admonition seealso">
  790. <p class="admonition-title">See also</p>
  791. <p><a class="reference external" href="https://importlib-resources.readthedocs.io/en/latest/">importlib_resources</a>
  792. – a PyPI backport for earlier Python versions.</p>
  793. </div>
  794. </section>
  795. </section>
  796. <section id="improved-modules">
  797. <h2>Improved Modules<a class="headerlink" href="#improved-modules" title="Link to this heading">¶</a></h2>
  798. <section id="argparse">
  799. <h3>argparse<a class="headerlink" href="#argparse" title="Link to this heading">¶</a></h3>
  800. <p>The new <a class="reference internal" href="../library/argparse.html#argparse.ArgumentParser.parse_intermixed_args" title="argparse.ArgumentParser.parse_intermixed_args"><code class="xref py py-meth docutils literal notranslate"><span class="pre">ArgumentParser.parse_intermixed_args()</span></code></a>
  801. method allows intermixing options and positional arguments.
  802. (Contributed by paul.j3 in <a class="reference external" href="https://bugs.python.org/issue?&#64;action=redirect&amp;bpo=14191">bpo-14191</a>.)</p>
  803. </section>
  804. <section id="asyncio">
  805. <span id="whatsnew37-asyncio"></span><h3>asyncio<a class="headerlink" href="#asyncio" title="Link to this heading">¶</a></h3>
  806. <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 many new features, usability and
  807. <a class="reference internal" href="#whatsnew37-asyncio-perf"><span class="std std-ref">performance improvements</span></a>. Notable changes
  808. include:</p>
  809. <ul>
  810. <li><p>The new <a class="reference internal" href="../glossary.html#term-provisional-API"><span class="xref std std-term">provisional</span></a> <a class="reference internal" href="../library/asyncio-runner.html#asyncio.run" title="asyncio.run"><code class="xref py py-func docutils literal notranslate"><span class="pre">asyncio.run()</span></code></a> function can
  811. be used to run a coroutine from synchronous code by automatically creating and
  812. destroying the event loop.
  813. (Contributed by Yury Selivanov in <a class="reference external" href="https://bugs.python.org/issue?&#64;action=redirect&amp;bpo=32314">bpo-32314</a>.)</p></li>
  814. <li><p>asyncio gained support for <a class="reference internal" href="../library/contextvars.html#module-contextvars" title="contextvars: Context Variables"><code class="xref py py-mod docutils literal notranslate"><span class="pre">contextvars</span></code></a>.
  815. <a class="reference internal" href="../library/asyncio-eventloop.html#asyncio.loop.call_soon" title="asyncio.loop.call_soon"><code class="xref py py-meth docutils literal notranslate"><span class="pre">loop.call_soon()</span></code></a>,
  816. <a class="reference internal" href="../library/asyncio-eventloop.html#asyncio.loop.call_soon_threadsafe" title="asyncio.loop.call_soon_threadsafe"><code class="xref py py-meth docutils literal notranslate"><span class="pre">loop.call_soon_threadsafe()</span></code></a>,
  817. <a class="reference internal" href="../library/asyncio-eventloop.html#asyncio.loop.call_later" title="asyncio.loop.call_later"><code class="xref py py-meth docutils literal notranslate"><span class="pre">loop.call_later()</span></code></a>,
  818. <a class="reference internal" href="../library/asyncio-eventloop.html#asyncio.loop.call_at" title="asyncio.loop.call_at"><code class="xref py py-meth docutils literal notranslate"><span class="pre">loop.call_at()</span></code></a>, and
  819. <a class="reference internal" href="../library/asyncio-future.html#asyncio.Future.add_done_callback" title="asyncio.Future.add_done_callback"><code class="xref py py-meth docutils literal notranslate"><span class="pre">Future.add_done_callback()</span></code></a>
  820. have a new optional keyword-only <em>context</em> parameter.
  821. <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">Tasks</span></code></a> now track their context automatically.
  822. See <span class="target" id="index-30"></span><a class="pep reference external" href="https://peps.python.org/pep-0567/"><strong>PEP 567</strong></a> for more details.
  823. (Contributed by Yury Selivanov in <a class="reference external" href="https://bugs.python.org/issue?&#64;action=redirect&amp;bpo=32436">bpo-32436</a>.)</p></li>
  824. <li><p>The new <a class="reference internal" href="../library/asyncio-task.html#asyncio.create_task" title="asyncio.create_task"><code class="xref py py-func docutils literal notranslate"><span class="pre">asyncio.create_task()</span></code></a> function has been added as a shortcut
  825. to <code class="docutils literal notranslate"><span class="pre">asyncio.get_event_loop().create_task()</span></code>.
  826. (Contributed by Andrew Svetlov in <a class="reference external" href="https://bugs.python.org/issue?&#64;action=redirect&amp;bpo=32311">bpo-32311</a>.)</p></li>
  827. <li><p>The new <a class="reference internal" href="../library/asyncio-eventloop.html#asyncio.loop.start_tls" title="asyncio.loop.start_tls"><code class="xref py py-meth docutils literal notranslate"><span class="pre">loop.start_tls()</span></code></a>
  828. method can be used to upgrade an existing connection to TLS.
  829. (Contributed by Yury Selivanov in <a class="reference external" href="https://bugs.python.org/issue?&#64;action=redirect&amp;bpo=23749">bpo-23749</a>.)</p></li>
  830. <li><p>The new <a class="reference internal" href="../library/asyncio-eventloop.html#asyncio.loop.sock_recv_into" title="asyncio.loop.sock_recv_into"><code class="xref py py-meth docutils literal notranslate"><span class="pre">loop.sock_recv_into()</span></code></a>
  831. method allows reading data from a socket directly into a provided buffer making
  832. it possible to reduce data copies.
  833. (Contributed by Antoine Pitrou in <a class="reference external" href="https://bugs.python.org/issue?&#64;action=redirect&amp;bpo=31819">bpo-31819</a>.)</p></li>
  834. <li><p>The new <a class="reference internal" href="../library/asyncio-task.html#asyncio.current_task" title="asyncio.current_task"><code class="xref py py-func docutils literal notranslate"><span class="pre">asyncio.current_task()</span></code></a> function returns the currently running
  835. <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> instance, and the new <a class="reference internal" href="../library/asyncio-task.html#asyncio.all_tasks" title="asyncio.all_tasks"><code class="xref py py-func docutils literal notranslate"><span class="pre">asyncio.all_tasks()</span></code></a>
  836. function returns a set of all existing <code class="docutils literal notranslate"><span class="pre">Task</span></code> instances in a given loop.
  837. The <code class="xref py py-meth docutils literal notranslate"><span class="pre">Task.current_task()</span></code> and
  838. <code class="xref py py-meth docutils literal notranslate"><span class="pre">Task.all_tasks()</span></code> methods have been deprecated.
  839. (Contributed by Andrew Svetlov in <a class="reference external" href="https://bugs.python.org/issue?&#64;action=redirect&amp;bpo=32250">bpo-32250</a>.)</p></li>
  840. <li><p>The new <em>provisional</em> <a class="reference internal" href="../library/asyncio-protocol.html#asyncio.BufferedProtocol" title="asyncio.BufferedProtocol"><code class="xref py py-class docutils literal notranslate"><span class="pre">BufferedProtocol</span></code></a> class allows
  841. implementing streaming protocols with manual control over the receive buffer.
  842. (Contributed by Yury Selivanov in <a class="reference external" href="https://bugs.python.org/issue?&#64;action=redirect&amp;bpo=32251">bpo-32251</a>.)</p></li>
  843. <li><p>The new <a class="reference internal" href="../library/asyncio-eventloop.html#asyncio.get_running_loop" title="asyncio.get_running_loop"><code class="xref py py-func docutils literal notranslate"><span class="pre">asyncio.get_running_loop()</span></code></a> function returns the currently
  844. running loop, and raises 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> if no loop is running.
  845. This is in contrast with <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">asyncio.get_event_loop()</span></code></a>, which will <em>create</em>
  846. a new event loop if none is running.
  847. (Contributed by Yury Selivanov in <a class="reference external" href="https://bugs.python.org/issue?&#64;action=redirect&amp;bpo=32269">bpo-32269</a>.)</p></li>
  848. <li><p>The new <a class="reference internal" href="../library/asyncio-stream.html#asyncio.StreamWriter.wait_closed" title="asyncio.StreamWriter.wait_closed"><code class="xref py py-meth docutils literal notranslate"><span class="pre">StreamWriter.wait_closed()</span></code></a>
  849. coroutine method allows waiting until the stream writer is closed. The new
  850. <a class="reference internal" href="../library/asyncio-stream.html#asyncio.StreamWriter.is_closing" title="asyncio.StreamWriter.is_closing"><code class="xref py py-meth docutils literal notranslate"><span class="pre">StreamWriter.is_closing()</span></code></a> method
  851. can be used to determine if the writer is closing.
  852. (Contributed by Andrew Svetlov in <a class="reference external" href="https://bugs.python.org/issue?&#64;action=redirect&amp;bpo=32391">bpo-32391</a>.)</p></li>
  853. <li><p>The new <a class="reference internal" href="../library/asyncio-eventloop.html#asyncio.loop.sock_sendfile" title="asyncio.loop.sock_sendfile"><code class="xref py py-meth docutils literal notranslate"><span class="pre">loop.sock_sendfile()</span></code></a>
  854. coroutine method allows sending files using <a class="reference internal" href="../library/os.html#os.sendfile" title="os.sendfile"><code class="xref py py-mod docutils literal notranslate"><span class="pre">os.sendfile</span></code></a> when possible.
  855. (Contributed by Andrew Svetlov in <a class="reference external" href="https://bugs.python.org/issue?&#64;action=redirect&amp;bpo=32410">bpo-32410</a>.)</p></li>
  856. <li><p>The new <a class="reference internal" href="../library/asyncio-future.html#asyncio.Future.get_loop" title="asyncio.Future.get_loop"><code class="xref py py-meth docutils literal notranslate"><span class="pre">Future.get_loop()</span></code></a> and
  857. <code class="docutils literal notranslate"><span class="pre">Task.get_loop()</span></code> methods return the instance of the loop on which a task or
  858. a future were created.
  859. <a class="reference internal" href="../library/asyncio-eventloop.html#asyncio.Server.get_loop" title="asyncio.Server.get_loop"><code class="xref py py-meth docutils literal notranslate"><span class="pre">Server.get_loop()</span></code></a> allows doing the same for
  860. <a class="reference internal" href="../library/asyncio-eventloop.html#asyncio.Server" title="asyncio.Server"><code class="xref py py-class docutils literal notranslate"><span class="pre">asyncio.Server</span></code></a> objects.
  861. (Contributed by Yury Selivanov in <a class="reference external" href="https://bugs.python.org/issue?&#64;action=redirect&amp;bpo=32415">bpo-32415</a> and
  862. Srinivas Reddy Thatiparthy in <a class="reference external" href="https://bugs.python.org/issue?&#64;action=redirect&amp;bpo=32418">bpo-32418</a>.)</p></li>
  863. <li><p>It is now possible to control how instances of <a class="reference internal" href="../library/asyncio-eventloop.html#asyncio.Server" title="asyncio.Server"><code class="xref py py-class docutils literal notranslate"><span class="pre">asyncio.Server</span></code></a> begin
  864. serving. Previously, the server would start serving immediately when created.
  865. The new <em>start_serving</em> keyword argument to
  866. <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> and
  867. <a class="reference internal" href="../library/asyncio-eventloop.html#asyncio.loop.create_unix_server" title="asyncio.loop.create_unix_server"><code class="xref py py-meth docutils literal notranslate"><span class="pre">loop.create_unix_server()</span></code></a>,
  868. as well as <a class="reference internal" href="../library/asyncio-eventloop.html#asyncio.Server.start_serving" title="asyncio.Server.start_serving"><code class="xref py py-meth docutils literal notranslate"><span class="pre">Server.start_serving()</span></code></a>, and
  869. <a class="reference internal" href="../library/asyncio-eventloop.html#asyncio.Server.serve_forever" title="asyncio.Server.serve_forever"><code class="xref py py-meth docutils literal notranslate"><span class="pre">Server.serve_forever()</span></code></a>
  870. can be used to decouple server instantiation and serving. The new
  871. <a class="reference internal" href="../library/asyncio-eventloop.html#asyncio.Server.is_serving" title="asyncio.Server.is_serving"><code class="xref py py-meth docutils literal notranslate"><span class="pre">Server.is_serving()</span></code></a> method returns <code class="docutils literal notranslate"><span class="pre">True</span></code>
  872. if the server is serving. <a class="reference internal" href="../library/asyncio-eventloop.html#asyncio.Server" title="asyncio.Server"><code class="xref py py-class docutils literal notranslate"><span class="pre">Server</span></code></a> objects are now
  873. asynchronous context managers:</p>
  874. <div class="highlight-python3 notranslate"><div class="highlight"><pre><span></span><span class="n">srv</span> <span class="o">=</span> <span class="k">await</span> <span class="n">loop</span><span class="o">.</span><span class="n">create_server</span><span class="p">(</span><span class="o">...</span><span class="p">)</span>
  875. <span class="k">async</span> <span class="k">with</span> <span class="n">srv</span><span class="p">:</span>
  876. <span class="c1"># some code</span>
  877. <span class="c1"># At this point, srv is closed and no longer accepts new connections.</span>
  878. </pre></div>
  879. </div>
  880. <p>(Contributed by Yury Selivanov in <a class="reference external" href="https://bugs.python.org/issue?&#64;action=redirect&amp;bpo=32662">bpo-32662</a>.)</p>
  881. </li>
  882. <li><p>Callback objects returned by
  883. <a class="reference internal" href="../library/asyncio-eventloop.html#asyncio.loop.call_later" title="asyncio.loop.call_later"><code class="xref py py-func docutils literal notranslate"><span class="pre">loop.call_later()</span></code></a>
  884. gained the new <a class="reference internal" href="../library/asyncio-eventloop.html#asyncio.TimerHandle.when" title="asyncio.TimerHandle.when"><code class="xref py py-meth docutils literal notranslate"><span class="pre">when()</span></code></a> method which
  885. returns an absolute scheduled callback timestamp.
  886. (Contributed by Andrew Svetlov in <a class="reference external" href="https://bugs.python.org/issue?&#64;action=redirect&amp;bpo=32741">bpo-32741</a>.)</p></li>
  887. <li><p>The <a class="reference internal" href="../library/asyncio-eventloop.html#asyncio.loop.create_datagram_endpoint" title="asyncio.loop.create_datagram_endpoint"><code class="xref py py-meth docutils literal notranslate"><span class="pre">loop.create_datagram_endpoint()</span> </code></a> method
  888. gained support for Unix sockets.
  889. (Contributed by Quentin Dawans in <a class="reference external" href="https://bugs.python.org/issue?&#64;action=redirect&amp;bpo=31245">bpo-31245</a>.)</p></li>
  890. <li><p>The <a class="reference internal" href="../library/asyncio-stream.html#asyncio.open_connection" title="asyncio.open_connection"><code class="xref py py-func docutils literal notranslate"><span class="pre">asyncio.open_connection()</span></code></a>, <a class="reference internal" href="../library/asyncio-stream.html#asyncio.start_server" title="asyncio.start_server"><code class="xref py py-func docutils literal notranslate"><span class="pre">asyncio.start_server()</span></code></a> functions,
  891. <a class="reference internal" href="../library/asyncio-eventloop.html#asyncio.loop.create_connection" title="asyncio.loop.create_connection"><code class="xref py py-meth docutils literal notranslate"><span class="pre">loop.create_connection()</span></code></a>,
  892. <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>,
  893. <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.create_accepted_socket()</span></code></a>
  894. methods and their corresponding UNIX socket variants now accept the
  895. <em>ssl_handshake_timeout</em> keyword argument.
  896. (Contributed by Neil Aspinall in <a class="reference external" href="https://bugs.python.org/issue?&#64;action=redirect&amp;bpo=29970">bpo-29970</a>.)</p></li>
  897. <li><p>The new <a class="reference internal" href="../library/asyncio-eventloop.html#asyncio.Handle.cancelled" title="asyncio.Handle.cancelled"><code class="xref py py-meth docutils literal notranslate"><span class="pre">Handle.cancelled()</span></code></a> method returns
  898. <code class="docutils literal notranslate"><span class="pre">True</span></code> if the callback was cancelled.
  899. (Contributed by Marat Sharafutdinov in <a class="reference external" href="https://bugs.python.org/issue?&#64;action=redirect&amp;bpo=31943">bpo-31943</a>.)</p></li>
  900. <li><p>The asyncio source has been converted to use the
  901. <a class="reference internal" href="../reference/compound_stmts.html#async"><code class="xref std std-keyword docutils literal notranslate"><span class="pre">async</span></code></a>/<a class="reference internal" href="../reference/expressions.html#await"><code class="xref std std-keyword docutils literal notranslate"><span class="pre">await</span></code></a> syntax.
  902. (Contributed by Andrew Svetlov in <a class="reference external" href="https://bugs.python.org/issue?&#64;action=redirect&amp;bpo=32193">bpo-32193</a>.)</p></li>
  903. <li><p>The new <a class="reference internal" href="../library/asyncio-protocol.html#asyncio.ReadTransport.is_reading" title="asyncio.ReadTransport.is_reading"><code class="xref py py-meth docutils literal notranslate"><span class="pre">ReadTransport.is_reading()</span></code></a>
  904. method can be used to determine the reading state of the transport.
  905. Additionally, calls to
  906. <a class="reference internal" href="../library/asyncio-protocol.html#asyncio.ReadTransport.resume_reading" title="asyncio.ReadTransport.resume_reading"><code class="xref py py-meth docutils literal notranslate"><span class="pre">ReadTransport.resume_reading()</span></code></a>
  907. and <a class="reference internal" href="../library/asyncio-protocol.html#asyncio.ReadTransport.pause_reading" title="asyncio.ReadTransport.pause_reading"><code class="xref py py-meth docutils literal notranslate"><span class="pre">ReadTransport.pause_reading()</span></code></a>
  908. are now idempotent.
  909. (Contributed by Yury Selivanov in <a class="reference external" href="https://bugs.python.org/issue?&#64;action=redirect&amp;bpo=32356">bpo-32356</a>.)</p></li>
  910. <li><p>Loop methods which accept socket paths now support passing
  911. <a class="reference internal" href="../glossary.html#term-path-like-object"><span class="xref std std-term">path-like objects</span></a>.
  912. (Contributed by Yury Selivanov in <a class="reference external" href="https://bugs.python.org/issue?&#64;action=redirect&amp;bpo=32066">bpo-32066</a>.)</p></li>
  913. <li><p>In <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> TCP sockets on Linux are now created with <code class="docutils literal notranslate"><span class="pre">TCP_NODELAY</span></code>
  914. flag set by default.
  915. (Contributed by Yury Selivanov and Victor Stinner in <a class="reference external" href="https://bugs.python.org/issue?&#64;action=redirect&amp;bpo=27456">bpo-27456</a>.)</p></li>
  916. <li><p>Exceptions occurring in cancelled tasks are no longer logged.
  917. (Contributed by Yury Selivanov in <a class="reference external" href="https://bugs.python.org/issue?&#64;action=redirect&amp;bpo=30508">bpo-30508</a>.)</p></li>
  918. <li><p>New <code class="docutils literal notranslate"><span class="pre">WindowsSelectorEventLoopPolicy</span></code> and
  919. <code class="docutils literal notranslate"><span class="pre">WindowsProactorEventLoopPolicy</span></code> classes.
  920. (Contributed by Yury Selivanov in <a class="reference external" href="https://bugs.python.org/issue?&#64;action=redirect&amp;bpo=33792">bpo-33792</a>.)</p></li>
  921. </ul>
  922. <p>Several <code class="docutils literal notranslate"><span class="pre">asyncio</span></code> APIs have been
  923. <a class="reference internal" href="#whatsnew37-asyncio-deprecated"><span class="std std-ref">deprecated</span></a>.</p>
  924. </section>
  925. <section id="binascii">
  926. <h3>binascii<a class="headerlink" href="#binascii" title="Link to this heading">¶</a></h3>
  927. <p>The <a class="reference internal" href="../library/binascii.html#binascii.b2a_uu" title="binascii.b2a_uu"><code class="xref py py-func docutils literal notranslate"><span class="pre">b2a_uu()</span></code></a> function now accepts an optional <em>backtick</em>
  928. keyword argument. When it’s true, zeros are represented by <code class="docutils literal notranslate"><span class="pre">'`'</span></code>
  929. instead of spaces. (Contributed by Xiang Zhang in <a class="reference external" href="https://bugs.python.org/issue?&#64;action=redirect&amp;bpo=30103">bpo-30103</a>.)</p>
  930. </section>
  931. <section id="calendar">
  932. <h3>calendar<a class="headerlink" href="#calendar" title="Link to this heading">¶</a></h3>
  933. <p>The <a class="reference internal" href="../library/calendar.html#calendar.HTMLCalendar" title="calendar.HTMLCalendar"><code class="xref py py-class docutils literal notranslate"><span class="pre">HTMLCalendar</span></code></a> class has new class attributes which ease
  934. the customization of CSS classes in the produced HTML calendar.
  935. (Contributed by Oz Tiram in <a class="reference external" href="https://bugs.python.org/issue?&#64;action=redirect&amp;bpo=30095">bpo-30095</a>.)</p>
  936. </section>
  937. <section id="collections">
  938. <h3>collections<a class="headerlink" href="#collections" title="Link to this heading">¶</a></h3>
  939. <p><code class="docutils literal notranslate"><span class="pre">collections.namedtuple()</span></code> now supports default values.
  940. (Contributed by Raymond Hettinger in <a class="reference external" href="https://bugs.python.org/issue?&#64;action=redirect&amp;bpo=32320">bpo-32320</a>.)</p>
  941. </section>
  942. <section id="compileall">
  943. <h3>compileall<a class="headerlink" href="#compileall" title="Link to this heading">¶</a></h3>
  944. <p><a class="reference internal" href="../library/compileall.html#compileall.compile_dir" title="compileall.compile_dir"><code class="xref py py-func docutils literal notranslate"><span class="pre">compileall.compile_dir()</span></code></a> learned the new <em>invalidation_mode</em> parameter,
  945. which can be used to enable
  946. <a class="reference internal" href="#whatsnew37-pep552"><span class="std std-ref">hash-based .pyc invalidation</span></a>. The invalidation
  947. mode can also be specified on the command line using the new
  948. <code class="docutils literal notranslate"><span class="pre">--invalidation-mode</span></code> argument.
  949. (Contributed by Benjamin Peterson in <a class="reference external" href="https://bugs.python.org/issue?&#64;action=redirect&amp;bpo=31650">bpo-31650</a>.)</p>
  950. </section>
  951. <section id="concurrent-futures">
  952. <h3>concurrent.futures<a class="headerlink" href="#concurrent-futures" title="Link to this heading">¶</a></h3>
  953. <p><a class="reference internal" href="../library/concurrent.futures.html#concurrent.futures.ProcessPoolExecutor" title="concurrent.futures.ProcessPoolExecutor"><code class="xref py py-class docutils literal notranslate"><span class="pre">ProcessPoolExecutor</span></code></a> and
  954. <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> now
  955. support the new <em>initializer</em> and <em>initargs</em> constructor arguments.
  956. (Contributed by Antoine Pitrou in <a class="reference external" href="https://bugs.python.org/issue?&#64;action=redirect&amp;bpo=21423">bpo-21423</a>.)</p>
  957. <p>The <a class="reference internal" href="../library/concurrent.futures.html#concurrent.futures.ProcessPoolExecutor" title="concurrent.futures.ProcessPoolExecutor"><code class="xref py py-class docutils literal notranslate"><span class="pre">ProcessPoolExecutor</span></code></a>
  958. can now take the multiprocessing context via the new <em>mp_context</em> argument.
  959. (Contributed by Thomas Moreau in <a class="reference external" href="https://bugs.python.org/issue?&#64;action=redirect&amp;bpo=31540">bpo-31540</a>.)</p>
  960. </section>
  961. <section id="contextlib">
  962. <h3>contextlib<a class="headerlink" href="#contextlib" title="Link to this heading">¶</a></h3>
  963. <p>The new <a class="reference internal" href="../library/contextlib.html#contextlib.nullcontext" title="contextlib.nullcontext"><code class="xref py py-func docutils literal notranslate"><span class="pre">nullcontext()</span></code></a> is a simpler and faster no-op
  964. context manager than <a class="reference internal" href="../library/contextlib.html#contextlib.ExitStack" title="contextlib.ExitStack"><code class="xref py py-class docutils literal notranslate"><span class="pre">ExitStack</span></code></a>.
  965. (Contributed by Jesse-Bakker in <a class="reference external" href="https://bugs.python.org/issue?&#64;action=redirect&amp;bpo=10049">bpo-10049</a>.)</p>
  966. <p>The new <a class="reference internal" href="../library/contextlib.html#contextlib.asynccontextmanager" title="contextlib.asynccontextmanager"><code class="xref py py-func docutils literal notranslate"><span class="pre">asynccontextmanager()</span></code></a>,
  967. <a class="reference internal" href="../library/contextlib.html#contextlib.AbstractAsyncContextManager" title="contextlib.AbstractAsyncContextManager"><code class="xref py py-class docutils literal notranslate"><span class="pre">AbstractAsyncContextManager</span></code></a>, and
  968. <a class="reference internal" href="../library/contextlib.html#contextlib.AsyncExitStack" title="contextlib.AsyncExitStack"><code class="xref py py-class docutils literal notranslate"><span class="pre">AsyncExitStack</span></code></a> have been added to
  969. complement their synchronous counterparts. (Contributed
  970. by Jelle Zijlstra in <a class="reference external" href="https://bugs.python.org/issue?&#64;action=redirect&amp;bpo=29679">bpo-29679</a> and <a class="reference external" href="https://bugs.python.org/issue?&#64;action=redirect&amp;bpo=30241">bpo-30241</a>,
  971. and by Alexander Mohr and Ilya Kulakov in <a class="reference external" href="https://bugs.python.org/issue?&#64;action=redirect&amp;bpo=29302">bpo-29302</a>.)</p>
  972. </section>
  973. <section id="cprofile">
  974. <h3>cProfile<a class="headerlink" href="#cprofile" title="Link to this heading">¶</a></h3>
  975. <p>The <a class="reference internal" href="../library/profile.html#module-cProfile" title="cProfile"><code class="xref py py-mod docutils literal notranslate"><span class="pre">cProfile</span></code></a> command line now accepts <code class="docutils literal notranslate"><span class="pre">-m</span> <span class="pre">module_name</span></code> as an
  976. alternative to script path. (Contributed by Sanyam Khurana in <a class="reference external" href="https://bugs.python.org/issue?&#64;action=redirect&amp;bpo=21862">bpo-21862</a>.)</p>
  977. </section>
  978. <section id="crypt">
  979. <h3>crypt<a class="headerlink" href="#crypt" title="Link to this heading">¶</a></h3>
  980. <p>The <a class="reference internal" href="../library/crypt.html#module-crypt" title="crypt: The crypt() function used to check Unix passwords. (deprecated) (Unix)"><code class="xref py py-mod docutils literal notranslate"><span class="pre">crypt</span></code></a> module now supports the Blowfish hashing method.
  981. (Contributed by Serhiy Storchaka in <a class="reference external" href="https://bugs.python.org/issue?&#64;action=redirect&amp;bpo=31664">bpo-31664</a>.)</p>
  982. <p>The <a class="reference internal" href="../library/crypt.html#crypt.mksalt" title="crypt.mksalt"><code class="xref py py-func docutils literal notranslate"><span class="pre">mksalt()</span></code></a> function now allows specifying the number of rounds
  983. for hashing. (Contributed by Serhiy Storchaka in <a class="reference external" href="https://bugs.python.org/issue?&#64;action=redirect&amp;bpo=31702">bpo-31702</a>.)</p>
  984. </section>
  985. <section id="datetime">
  986. <h3>datetime<a class="headerlink" href="#datetime" title="Link to this heading">¶</a></h3>
  987. <p>The new <a class="reference internal" href="../library/datetime.html#datetime.datetime.fromisoformat" title="datetime.datetime.fromisoformat"><code class="xref py py-meth docutils literal notranslate"><span class="pre">datetime.fromisoformat()</span></code></a>
  988. method constructs a <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> object from a string
  989. in one of the formats output by
  990. <a class="reference internal" href="../library/datetime.html#datetime.datetime.isoformat" title="datetime.datetime.isoformat"><code class="xref py py-meth docutils literal notranslate"><span class="pre">datetime.isoformat()</span></code></a>.
  991. (Contributed by Paul Ganssle in <a class="reference external" href="https://bugs.python.org/issue?&#64;action=redirect&amp;bpo=15873">bpo-15873</a>.)</p>
  992. <p>The <a class="reference internal" href="../library/datetime.html#datetime.tzinfo" title="datetime.tzinfo"><code class="xref py py-class docutils literal notranslate"><span class="pre">tzinfo</span></code></a> class now supports sub-minute offsets.
  993. (Contributed by Alexander Belopolsky in <a class="reference external" href="https://bugs.python.org/issue?&#64;action=redirect&amp;bpo=5288">bpo-5288</a>.)</p>
  994. </section>
  995. <section id="dbm">
  996. <h3>dbm<a class="headerlink" href="#dbm" title="Link to this heading">¶</a></h3>
  997. <p><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> now supports reading read-only files and no longer writes the
  998. index file when it is not changed.</p>
  999. </section>
  1000. <section id="decimal">
  1001. <h3>decimal<a class="headerlink" href="#decimal" title="Link to this heading">¶</a></h3>
  1002. <p>The <a class="reference internal" href="../library/decimal.html#module-decimal" title="decimal: Implementation of the General Decimal Arithmetic Specification."><code class="xref py py-mod docutils literal notranslate"><span class="pre">decimal</span></code></a> module now uses <a class="reference internal" href="#whatsnew37-pep567"><span class="std std-ref">context variables</span></a>
  1003. to store the decimal context.
  1004. (Contributed by Yury Selivanov in <a class="reference external" href="https://bugs.python.org/issue?&#64;action=redirect&amp;bpo=32630">bpo-32630</a>.)</p>
  1005. </section>
  1006. <section id="dis">
  1007. <h3>dis<a class="headerlink" href="#dis" title="Link to this heading">¶</a></h3>
  1008. <p>The <a class="reference internal" href="../library/dis.html#dis.dis" title="dis.dis"><code class="xref py py-func docutils literal notranslate"><span class="pre">dis()</span></code></a> function is now able to
  1009. disassemble nested code objects (the code of comprehensions, generator
  1010. expressions and nested functions, and the code used for building nested
  1011. classes). The maximum depth of disassembly recursion is controlled by
  1012. the new <em>depth</em> parameter.
  1013. (Contributed by Serhiy Storchaka in <a class="reference external" href="https://bugs.python.org/issue?&#64;action=redirect&amp;bpo=11822">bpo-11822</a>.)</p>
  1014. </section>
  1015. <section id="distutils">
  1016. <h3>distutils<a class="headerlink" href="#distutils" title="Link to this heading">¶</a></h3>
  1017. <p><code class="docutils literal notranslate"><span class="pre">README.rst</span></code> is now included in the list of distutils standard READMEs and
  1018. therefore included in source distributions.
  1019. (Contributed by Ryan Gonzalez in <a class="reference external" href="https://bugs.python.org/issue?&#64;action=redirect&amp;bpo=11913">bpo-11913</a>.)</p>
  1020. </section>
  1021. <section id="enum">
  1022. <h3>enum<a class="headerlink" href="#enum" title="Link to this heading">¶</a></h3>
  1023. <p>The <a class="reference internal" href="../library/enum.html#enum.Enum" title="enum.Enum"><code class="xref py py-class docutils literal notranslate"><span class="pre">Enum</span></code></a> learned the new <code class="docutils literal notranslate"><span class="pre">_ignore_</span></code> class property,
  1024. which allows listing the names of properties which should not become
  1025. enum members.
  1026. (Contributed by Ethan Furman in <a class="reference external" href="https://bugs.python.org/issue?&#64;action=redirect&amp;bpo=31801">bpo-31801</a>.)</p>
  1027. <p>In Python 3.8, attempting to check for non-Enum objects in <code class="xref py py-class docutils literal notranslate"><span class="pre">Enum</span></code>
  1028. classes will raise a <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> (e.g. <code class="docutils literal notranslate"><span class="pre">1</span> <span class="pre">in</span> <span class="pre">Color</span></code>); similarly,
  1029. attempting to check for non-Flag objects in a <code class="xref py py-class docutils literal notranslate"><span class="pre">Flag</span></code> member will
  1030. 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> (e.g. <code class="docutils literal notranslate"><span class="pre">1</span> <span class="pre">in</span> <span class="pre">Perm.RW</span></code>); currently, both operations
  1031. return <a class="reference internal" href="../library/constants.html#False" title="False"><code class="xref py py-const docutils literal notranslate"><span class="pre">False</span></code></a> instead and are deprecated.
  1032. (Contributed by Ethan Furman in <a class="reference external" href="https://bugs.python.org/issue?&#64;action=redirect&amp;bpo=33217">bpo-33217</a>.)</p>
  1033. </section>
  1034. <section id="functools">
  1035. <h3>functools<a class="headerlink" href="#functools" title="Link to this heading">¶</a></h3>
  1036. <p><a class="reference internal" href="../library/functools.html#functools.singledispatch" title="functools.singledispatch"><code class="xref py py-func docutils literal notranslate"><span class="pre">functools.singledispatch()</span></code></a> now supports registering implementations
  1037. using type annotations.
  1038. (Contributed by Łukasz Langa in <a class="reference external" href="https://bugs.python.org/issue?&#64;action=redirect&amp;bpo=32227">bpo-32227</a>.)</p>
  1039. </section>
  1040. <section id="gc">
  1041. <h3>gc<a class="headerlink" href="#gc" title="Link to this heading">¶</a></h3>
  1042. <p>The new <a class="reference internal" href="../library/gc.html#gc.freeze" title="gc.freeze"><code class="xref py py-func docutils literal notranslate"><span class="pre">gc.freeze()</span></code></a> function allows freezing all objects tracked
  1043. by the garbage collector and excluding them from future collections.
  1044. This can be used before a POSIX <code class="docutils literal notranslate"><span class="pre">fork()</span></code> call to make the GC copy-on-write
  1045. friendly or to speed up collection. The new <a class="reference internal" href="../library/gc.html#gc.unfreeze" title="gc.unfreeze"><code class="xref py py-func docutils literal notranslate"><span class="pre">gc.unfreeze()</span></code></a> functions
  1046. reverses this operation. Additionally, <a class="reference internal" href="../library/gc.html#gc.get_freeze_count" title="gc.get_freeze_count"><code class="xref py py-func docutils literal notranslate"><span class="pre">gc.get_freeze_count()</span></code></a> can
  1047. be used to obtain the number of frozen objects.
  1048. (Contributed by Li Zekun in <a class="reference external" href="https://bugs.python.org/issue?&#64;action=redirect&amp;bpo=31558">bpo-31558</a>.)</p>
  1049. </section>
  1050. <section id="hmac">
  1051. <h3>hmac<a class="headerlink" href="#hmac" title="Link to this heading">¶</a></h3>
  1052. <p>The <a class="reference internal" href="../library/hmac.html#module-hmac" title="hmac: Keyed-Hashing for Message Authentication (HMAC) implementation"><code class="xref py py-mod docutils literal notranslate"><span class="pre">hmac</span></code></a> module now has an optimized one-shot <a class="reference internal" href="../library/hmac.html#hmac.digest" title="hmac.digest"><code class="xref py py-func docutils literal notranslate"><span class="pre">digest()</span></code></a>
  1053. function, which is up to three times faster than <code class="xref py py-func docutils literal notranslate"><span class="pre">HMAC()</span></code>.
  1054. (Contributed by Christian Heimes in <a class="reference external" href="https://bugs.python.org/issue?&#64;action=redirect&amp;bpo=32433">bpo-32433</a>.)</p>
  1055. </section>
  1056. <section id="http-client">
  1057. <h3>http.client<a class="headerlink" href="#http-client" title="Link to this heading">¶</a></h3>
  1058. <p><a class="reference internal" href="../library/http.client.html#http.client.HTTPConnection" title="http.client.HTTPConnection"><code class="xref py py-class docutils literal notranslate"><span class="pre">HTTPConnection</span></code></a> and <a class="reference internal" href="../library/http.client.html#http.client.HTTPSConnection" title="http.client.HTTPSConnection"><code class="xref py py-class docutils literal notranslate"><span class="pre">HTTPSConnection</span></code></a>
  1059. now support the new <em>blocksize</em> argument for improved upload throughput.
  1060. (Contributed by Nir Soffer in <a class="reference external" href="https://bugs.python.org/issue?&#64;action=redirect&amp;bpo=31945">bpo-31945</a>.)</p>
  1061. </section>
  1062. <section id="http-server">
  1063. <h3>http.server<a class="headerlink" href="#http-server" title="Link to this heading">¶</a></h3>
  1064. <p><a class="reference internal" href="../library/http.server.html#http.server.SimpleHTTPRequestHandler" title="http.server.SimpleHTTPRequestHandler"><code class="xref py py-class docutils literal notranslate"><span class="pre">SimpleHTTPRequestHandler</span></code></a> now supports the HTTP
  1065. <code class="docutils literal notranslate"><span class="pre">If-Modified-Since</span></code> header. The server returns the 304 response status if
  1066. the target file was not modified after the time specified in the header.
  1067. (Contributed by Pierre Quentel in <a class="reference external" href="https://bugs.python.org/issue?&#64;action=redirect&amp;bpo=29654">bpo-29654</a>.)</p>
  1068. <p><a class="reference internal" href="../library/http.server.html#http.server.SimpleHTTPRequestHandler" title="http.server.SimpleHTTPRequestHandler"><code class="xref py py-class docutils literal notranslate"><span class="pre">SimpleHTTPRequestHandler</span></code></a> accepts the new <em>directory</em>
  1069. argument, in addition to the new <code class="docutils literal notranslate"><span class="pre">--directory</span></code> command line argument.
  1070. With this parameter, the server serves the specified directory, by default it
  1071. uses the current working directory.
  1072. (Contributed by Stéphane Wirtel and Julien Palard in <a class="reference external" href="https://bugs.python.org/issue?&#64;action=redirect&amp;bpo=28707">bpo-28707</a>.)</p>
  1073. <p>The new <a class="reference internal" href="../library/http.server.html#http.server.ThreadingHTTPServer" title="http.server.ThreadingHTTPServer"><code class="xref py py-class docutils literal notranslate"><span class="pre">ThreadingHTTPServer</span></code></a> class
  1074. uses threads to handle requests using <code class="xref py py-class docutils literal notranslate"><span class="pre">ThreadingMixin</span></code>.
  1075. It is used when <code class="docutils literal notranslate"><span class="pre">http.server</span></code> is run with <code class="docutils literal notranslate"><span class="pre">-m</span></code>.
  1076. (Contributed by Julien Palard in <a class="reference external" href="https://bugs.python.org/issue?&#64;action=redirect&amp;bpo=31639">bpo-31639</a>.)</p>
  1077. </section>
  1078. <section id="idlelib-and-idle">
  1079. <h3>idlelib and IDLE<a class="headerlink" href="#idlelib-and-idle" title="Link to this heading">¶</a></h3>
  1080. <p>Multiple fixes for autocompletion. (Contributed by Louie Lu in <a class="reference external" href="https://bugs.python.org/issue?&#64;action=redirect&amp;bpo=15786">bpo-15786</a>.)</p>
  1081. <p>Module Browser (on the File menu, formerly called Class Browser),
  1082. now displays nested functions and classes in addition to top-level
  1083. functions and classes.
  1084. (Contributed by Guilherme Polo, Cheryl Sabella, and Terry Jan Reedy
  1085. in <a class="reference external" href="https://bugs.python.org/issue?&#64;action=redirect&amp;bpo=1612262">bpo-1612262</a>.)</p>
  1086. <p>The Settings dialog (Options, Configure IDLE) has been partly rewritten
  1087. to improve both appearance and function.
  1088. (Contributed by Cheryl Sabella and Terry Jan Reedy in multiple issues.)</p>
  1089. <p>The font sample now includes a selection of non-Latin characters so that
  1090. users can better see the effect of selecting a particular font.
  1091. (Contributed by Terry Jan Reedy in <a class="reference external" href="https://bugs.python.org/issue?&#64;action=redirect&amp;bpo=13802">bpo-13802</a>.)
  1092. The sample can be edited to include other characters.
  1093. (Contributed by Serhiy Storchaka in <a class="reference external" href="https://bugs.python.org/issue?&#64;action=redirect&amp;bpo=31860">bpo-31860</a>.)</p>
  1094. <p>The IDLE features formerly implemented as extensions have been reimplemented
  1095. as normal features. Their settings have been moved from the Extensions tab
  1096. to other dialog tabs.
  1097. (Contributed by Charles Wohlganger and Terry Jan Reedy in <a class="reference external" href="https://bugs.python.org/issue?&#64;action=redirect&amp;bpo=27099">bpo-27099</a>.)</p>
  1098. <p>Editor code context option revised. Box displays all context lines up to
  1099. maxlines. Clicking on a context line jumps the editor to that line. Context
  1100. colors for custom themes is added to Highlights tab of Settings dialog.
  1101. (Contributed by Cheryl Sabella and Terry Jan Reedy in <a class="reference external" href="https://bugs.python.org/issue?&#64;action=redirect&amp;bpo=33642">bpo-33642</a>,
  1102. <a class="reference external" href="https://bugs.python.org/issue?&#64;action=redirect&amp;bpo=33768">bpo-33768</a>, and <a class="reference external" href="https://bugs.python.org/issue?&#64;action=redirect&amp;bpo=33679">bpo-33679</a>.)</p>
  1103. <p>On Windows, a new API call tells Windows that tk scales for DPI. On Windows
  1104. 8.1+ or 10, with DPI compatibility properties of the Python binary
  1105. unchanged, and a monitor resolution greater than 96 DPI, this should
  1106. make text and lines sharper. It should otherwise have no effect.
  1107. (Contributed by Terry Jan Reedy in <a class="reference external" href="https://bugs.python.org/issue?&#64;action=redirect&amp;bpo=33656">bpo-33656</a>.)</p>
  1108. <p>New in 3.7.1:</p>
  1109. <p>Output over N lines (50 by default) is squeezed down to a button.
  1110. N can be changed in the PyShell section of the General page of the
  1111. Settings dialog. Fewer, but possibly extra long, lines can be squeezed by
  1112. right clicking on the output. Squeezed output can be expanded in place
  1113. by double-clicking the button or into the clipboard or a separate window
  1114. by right-clicking the button. (Contributed by Tal Einat in <a class="reference external" href="https://bugs.python.org/issue?&#64;action=redirect&amp;bpo=1529353">bpo-1529353</a>.)</p>
  1115. <p>The changes above have been backported to 3.6 maintenance releases.</p>
  1116. <p>NEW in 3.7.4:</p>
  1117. <p>Add “Run Customized” to the Run menu to run a module with customized
  1118. settings. Any command line arguments entered are added to sys.argv.
  1119. They re-appear in the box for the next customized run. One can also
  1120. suppress the normal Shell main module restart. (Contributed by Cheryl
  1121. Sabella, Terry Jan Reedy, and others in <a class="reference external" href="https://bugs.python.org/issue?&#64;action=redirect&amp;bpo=5680">bpo-5680</a> and <a class="reference external" href="https://bugs.python.org/issue?&#64;action=redirect&amp;bpo=37627">bpo-37627</a>.)</p>
  1122. <p>New in 3.7.5:</p>
  1123. <p>Add optional line numbers for IDLE editor windows. Windows
  1124. open without line numbers unless set otherwise in the General
  1125. tab of the configuration dialog. Line numbers for an existing
  1126. window are shown and hidden in the Options menu.
  1127. (Contributed by Tal Einat and Saimadhav Heblikar in <a class="reference external" href="https://bugs.python.org/issue?&#64;action=redirect&amp;bpo=17535">bpo-17535</a>.)</p>
  1128. </section>
  1129. <section id="importlib">
  1130. <h3>importlib<a class="headerlink" href="#importlib" title="Link to this heading">¶</a></h3>
  1131. <p>The <a class="reference internal" href="../library/importlib.html#importlib.abc.ResourceReader" title="importlib.abc.ResourceReader"><code class="xref py py-class docutils literal notranslate"><span class="pre">importlib.abc.ResourceReader</span></code></a> ABC was introduced to
  1132. support the loading of resources from packages. See also
  1133. <a class="reference internal" href="#whatsnew37-importlib-resources"><span class="std std-ref">importlib.resources</span></a>.
  1134. (Contributed by Barry Warsaw, Brett Cannon in <a class="reference external" href="https://bugs.python.org/issue?&#64;action=redirect&amp;bpo=32248">bpo-32248</a>.)</p>
  1135. <p><a class="reference internal" href="../library/importlib.html#importlib.reload" title="importlib.reload"><code class="xref py py-func docutils literal notranslate"><span class="pre">importlib.reload()</span></code></a> now raises <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> if the module
  1136. lacks a spec.
  1137. (Contributed by Garvit Khatri in <a class="reference external" href="https://bugs.python.org/issue?&#64;action=redirect&amp;bpo=29851">bpo-29851</a>.)</p>
  1138. <p><code class="xref py py-func docutils literal notranslate"><span class="pre">importlib.find_spec()</span></code> now raises <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> instead of
  1139. <a class="reference internal" href="../library/exceptions.html#AttributeError" title="AttributeError"><code class="xref py py-exc docutils literal notranslate"><span class="pre">AttributeError</span></code></a> if the specified parent module is not a package (i.e.
  1140. lacks a <code class="docutils literal notranslate"><span class="pre">__path__</span></code> attribute).
  1141. (Contributed by Milan Oberkirch in <a class="reference external" href="https://bugs.python.org/issue?&#64;action=redirect&amp;bpo=30436">bpo-30436</a>.)</p>
  1142. <p>The new <code class="xref py py-func docutils literal notranslate"><span class="pre">importlib.source_hash()</span></code> can be used to compute the hash of
  1143. the passed source. A <a class="reference internal" href="#whatsnew37-pep552"><span class="std std-ref">hash-based .pyc file</span></a>
  1144. embeds the value returned by this function.</p>
  1145. </section>
  1146. <section id="io">
  1147. <h3>io<a class="headerlink" href="#io" title="Link to this heading">¶</a></h3>
  1148. <p>The new <a class="reference internal" href="../library/io.html#io.TextIOWrapper.reconfigure" title="io.TextIOWrapper.reconfigure"><code class="xref py py-meth docutils literal notranslate"><span class="pre">TextIOWrapper.reconfigure()</span></code></a>
  1149. method can be used to reconfigure the text stream with the new settings.
  1150. (Contributed by Antoine Pitrou in <a class="reference external" href="https://bugs.python.org/issue?&#64;action=redirect&amp;bpo=30526">bpo-30526</a> and
  1151. INADA Naoki in <a class="reference external" href="https://bugs.python.org/issue?&#64;action=redirect&amp;bpo=15216">bpo-15216</a>.)</p>
  1152. </section>
  1153. <section id="ipaddress">
  1154. <h3>ipaddress<a class="headerlink" href="#ipaddress" title="Link to this heading">¶</a></h3>
  1155. <p>The new <code class="docutils literal notranslate"><span class="pre">subnet_of()</span></code> and <code class="docutils literal notranslate"><span class="pre">supernet_of()</span></code> methods of
  1156. <a class="reference internal" href="../library/ipaddress.html#ipaddress.IPv6Network" title="ipaddress.IPv6Network"><code class="xref py py-class docutils literal notranslate"><span class="pre">ipaddress.IPv6Network</span></code></a> and <a class="reference internal" href="../library/ipaddress.html#ipaddress.IPv4Network" title="ipaddress.IPv4Network"><code class="xref py py-class docutils literal notranslate"><span class="pre">ipaddress.IPv4Network</span></code></a> can
  1157. be used for network containment tests.
  1158. (Contributed by Michel Albert and Cheryl Sabella in <a class="reference external" href="https://bugs.python.org/issue?&#64;action=redirect&amp;bpo=20825">bpo-20825</a>.)</p>
  1159. </section>
  1160. <section id="itertools">
  1161. <h3>itertools<a class="headerlink" href="#itertools" title="Link to this heading">¶</a></h3>
  1162. <p><a class="reference internal" href="../library/itertools.html#itertools.islice" title="itertools.islice"><code class="xref py py-func docutils literal notranslate"><span class="pre">itertools.islice()</span></code></a> now accepts
  1163. <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">integer-like</span> <span class="pre">objects</span></code></a> as start, stop,
  1164. and slice arguments.
  1165. (Contributed by Will Roberts in <a class="reference external" href="https://bugs.python.org/issue?&#64;action=redirect&amp;bpo=30537">bpo-30537</a>.)</p>
  1166. </section>
  1167. <section id="locale">
  1168. <h3>locale<a class="headerlink" href="#locale" title="Link to this heading">¶</a></h3>
  1169. <p>The new <em>monetary</em> argument to <a class="reference internal" href="../library/locale.html#locale.format_string" title="locale.format_string"><code class="xref py py-func docutils literal notranslate"><span class="pre">locale.format_string()</span></code></a> can be used
  1170. to make the conversion use monetary thousands separators and
  1171. grouping strings. (Contributed by Garvit in <a class="reference external" href="https://bugs.python.org/issue?&#64;action=redirect&amp;bpo=10379">bpo-10379</a>.)</p>
  1172. <p>The <a class="reference internal" href="../library/locale.html#locale.getpreferredencoding" title="locale.getpreferredencoding"><code class="xref py py-func docutils literal notranslate"><span class="pre">locale.getpreferredencoding()</span></code></a> function now always returns <code class="docutils literal notranslate"><span class="pre">'UTF-8'</span></code>
  1173. on Android or when in the <a class="reference internal" href="#whatsnew37-pep540"><span class="std std-ref">forced UTF-8 mode</span></a>.</p>
  1174. </section>
  1175. <section id="logging">
  1176. <h3>logging<a class="headerlink" href="#logging" title="Link to this heading">¶</a></h3>
  1177. <p><a class="reference internal" href="../library/logging.html#logging.Logger" title="logging.Logger"><code class="xref py py-class docutils literal notranslate"><span class="pre">Logger</span></code></a> instances can now be pickled.
  1178. (Contributed by Vinay Sajip in <a class="reference external" href="https://bugs.python.org/issue?&#64;action=redirect&amp;bpo=30520">bpo-30520</a>.)</p>
  1179. <p>The new <a class="reference internal" href="../library/logging.handlers.html#logging.StreamHandler.setStream" title="logging.StreamHandler.setStream"><code class="xref py py-meth docutils literal notranslate"><span class="pre">StreamHandler.setStream()</span></code></a>
  1180. method can be used to replace the logger stream after handler creation.
  1181. (Contributed by Vinay Sajip in <a class="reference external" href="https://bugs.python.org/issue?&#64;action=redirect&amp;bpo=30522">bpo-30522</a>.)</p>
  1182. <p>It is now possible to specify keyword arguments to handler constructors in
  1183. configuration passed to <a class="reference internal" href="../library/logging.config.html#logging.config.fileConfig" title="logging.config.fileConfig"><code class="xref py py-func docutils literal notranslate"><span class="pre">logging.config.fileConfig()</span></code></a>.
  1184. (Contributed by Preston Landers in <a class="reference external" href="https://bugs.python.org/issue?&#64;action=redirect&amp;bpo=31080">bpo-31080</a>.)</p>
  1185. </section>
  1186. <section id="math">
  1187. <h3>math<a class="headerlink" href="#math" title="Link to this heading">¶</a></h3>
  1188. <p>The new <a class="reference internal" href="../library/math.html#math.remainder" title="math.remainder"><code class="xref py py-func docutils literal notranslate"><span class="pre">math.remainder()</span></code></a> function implements the IEEE 754-style remainder
  1189. operation. (Contributed by Mark Dickinson in <a class="reference external" href="https://bugs.python.org/issue?&#64;action=redirect&amp;bpo=29962">bpo-29962</a>.)</p>
  1190. </section>
  1191. <section id="mimetypes">
  1192. <h3>mimetypes<a class="headerlink" href="#mimetypes" title="Link to this heading">¶</a></h3>
  1193. <p>The MIME type of .bmp has been changed from <code class="docutils literal notranslate"><span class="pre">'image/x-ms-bmp'</span></code> to
  1194. <code class="docutils literal notranslate"><span class="pre">'image/bmp'</span></code>.
  1195. (Contributed by Nitish Chandra in <a class="reference external" href="https://bugs.python.org/issue?&#64;action=redirect&amp;bpo=22589">bpo-22589</a>.)</p>
  1196. </section>
  1197. <section id="msilib">
  1198. <h3>msilib<a class="headerlink" href="#msilib" title="Link to this heading">¶</a></h3>
  1199. <p>The new <a class="reference internal" href="../library/msilib.html#msilib.Database.Close" title="msilib.Database.Close"><code class="xref py py-meth docutils literal notranslate"><span class="pre">Database.Close()</span></code></a> method can be used
  1200. to close the <abbr>MSI</abbr> database.
  1201. (Contributed by Berker Peksag in <a class="reference external" href="https://bugs.python.org/issue?&#64;action=redirect&amp;bpo=20486">bpo-20486</a>.)</p>
  1202. </section>
  1203. <section id="multiprocessing">
  1204. <h3>multiprocessing<a class="headerlink" href="#multiprocessing" title="Link to this heading">¶</a></h3>
  1205. <p>The new <a class="reference internal" href="../library/multiprocessing.html#multiprocessing.Process.close" title="multiprocessing.Process.close"><code class="xref py py-meth docutils literal notranslate"><span class="pre">Process.close()</span></code></a> method
  1206. explicitly closes the process object and releases all resources associated
  1207. with it. <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> is raised if the underlying process is still
  1208. running.
  1209. (Contributed by Antoine Pitrou in <a class="reference external" href="https://bugs.python.org/issue?&#64;action=redirect&amp;bpo=30596">bpo-30596</a>.)</p>
  1210. <p>The new <a class="reference internal" href="../library/multiprocessing.html#multiprocessing.Process.kill" title="multiprocessing.Process.kill"><code class="xref py py-meth docutils literal notranslate"><span class="pre">Process.kill()</span></code></a> method can
  1211. be used to terminate the process using the <code class="xref py py-data docutils literal notranslate"><span class="pre">SIGKILL</span></code> signal on Unix.
  1212. (Contributed by Vitor Pereira in <a class="reference external" href="https://bugs.python.org/issue?&#64;action=redirect&amp;bpo=30794">bpo-30794</a>.)</p>
  1213. <p>Non-daemonic threads created by <a class="reference internal" href="../library/multiprocessing.html#multiprocessing.Process" title="multiprocessing.Process"><code class="xref py py-class docutils literal notranslate"><span class="pre">Process</span></code></a> are now
  1214. joined on process exit.
  1215. (Contributed by Antoine Pitrou in <a class="reference external" href="https://bugs.python.org/issue?&#64;action=redirect&amp;bpo=18966">bpo-18966</a>.)</p>
  1216. </section>
  1217. <section id="os">
  1218. <h3>os<a class="headerlink" href="#os" title="Link to this heading">¶</a></h3>
  1219. <p><a class="reference internal" href="../library/os.html#os.fwalk" title="os.fwalk"><code class="xref py py-func docutils literal notranslate"><span class="pre">os.fwalk()</span></code></a> now accepts the <em>path</em> argument as <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>.
  1220. (Contributed by Serhiy Storchaka in <a class="reference external" href="https://bugs.python.org/issue?&#64;action=redirect&amp;bpo=28682">bpo-28682</a>.)</p>
  1221. <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">os.scandir()</span></code></a> gained support for <a class="reference internal" href="../library/os.html#path-fd"><span class="std std-ref">file descriptors</span></a>.
  1222. (Contributed by Serhiy Storchaka in <a class="reference external" href="https://bugs.python.org/issue?&#64;action=redirect&amp;bpo=25996">bpo-25996</a>.)</p>
  1223. <p>The new <a class="reference internal" href="../library/os.html#os.register_at_fork" title="os.register_at_fork"><code class="xref py py-func docutils literal notranslate"><span class="pre">register_at_fork()</span></code></a> function allows registering Python
  1224. callbacks to be executed at process fork.
  1225. (Contributed by Antoine Pitrou in <a class="reference external" href="https://bugs.python.org/issue?&#64;action=redirect&amp;bpo=16500">bpo-16500</a>.)</p>
  1226. <p>Added <a class="reference internal" href="../library/os.html#os.preadv" title="os.preadv"><code class="xref py py-func docutils literal notranslate"><span class="pre">os.preadv()</span></code></a> (combine the functionality of <a class="reference internal" href="../library/os.html#os.readv" title="os.readv"><code class="xref py py-func docutils literal notranslate"><span class="pre">os.readv()</span></code></a> and
  1227. <a class="reference internal" href="../library/os.html#os.pread" title="os.pread"><code class="xref py py-func docutils literal notranslate"><span class="pre">os.pread()</span></code></a>) and <a class="reference internal" href="../library/os.html#os.pwritev" title="os.pwritev"><code class="xref py py-func docutils literal notranslate"><span class="pre">os.pwritev()</span></code></a> functions (combine the functionality
  1228. of <a class="reference internal" href="../library/os.html#os.writev" title="os.writev"><code class="xref py py-func docutils literal notranslate"><span class="pre">os.writev()</span></code></a> and <a class="reference internal" href="../library/os.html#os.pwrite" title="os.pwrite"><code class="xref py py-func docutils literal notranslate"><span class="pre">os.pwrite()</span></code></a>). (Contributed by Pablo Galindo in
  1229. <a class="reference external" href="https://bugs.python.org/issue?&#64;action=redirect&amp;bpo=31368">bpo-31368</a>.)</p>
  1230. <p>The mode argument of <a class="reference internal" href="../library/os.html#os.makedirs" title="os.makedirs"><code class="xref py py-func docutils literal notranslate"><span class="pre">os.makedirs()</span></code></a> no longer affects the file
  1231. permission bits of newly created intermediate-level directories.
  1232. (Contributed by Serhiy Storchaka in <a class="reference external" href="https://bugs.python.org/issue?&#64;action=redirect&amp;bpo=19930">bpo-19930</a>.)</p>
  1233. <p><a class="reference internal" href="../library/os.html#os.dup2" title="os.dup2"><code class="xref py py-func docutils literal notranslate"><span class="pre">os.dup2()</span></code></a> now returns the new file descriptor. Previously, <code class="docutils literal notranslate"><span class="pre">None</span></code>
  1234. was always returned.
  1235. (Contributed by Benjamin Peterson in <a class="reference external" href="https://bugs.python.org/issue?&#64;action=redirect&amp;bpo=32441">bpo-32441</a>.)</p>
  1236. <p>The structure returned by <a class="reference internal" href="../library/os.html#os.stat" title="os.stat"><code class="xref py py-func docutils literal notranslate"><span class="pre">os.stat()</span></code></a> now contains the
  1237. <a class="reference internal" href="../library/os.html#os.stat_result.st_fstype" title="os.stat_result.st_fstype"><code class="xref py py-attr docutils literal notranslate"><span class="pre">st_fstype</span></code></a> attribute on Solaris and its derivatives.
  1238. (Contributed by Jesús Cea Avión in <a class="reference external" href="https://bugs.python.org/issue?&#64;action=redirect&amp;bpo=32659">bpo-32659</a>.)</p>
  1239. </section>
  1240. <section id="pathlib">
  1241. <h3>pathlib<a class="headerlink" href="#pathlib" title="Link to this heading">¶</a></h3>
  1242. <p>The new <a class="reference internal" href="../library/pathlib.html#pathlib.Path.is_mount" title="pathlib.Path.is_mount"><code class="xref py py-meth docutils literal notranslate"><span class="pre">Path.is_mount()</span></code></a> method is now available
  1243. on POSIX systems and can be used to determine whether a path is a mount point.
  1244. (Contributed by Cooper Ry Lees in <a class="reference external" href="https://bugs.python.org/issue?&#64;action=redirect&amp;bpo=30897">bpo-30897</a>.)</p>
  1245. </section>
  1246. <section id="pdb">
  1247. <h3>pdb<a class="headerlink" href="#pdb" title="Link to this heading">¶</a></h3>
  1248. <p><a class="reference internal" href="../library/pdb.html#pdb.set_trace" title="pdb.set_trace"><code class="xref py py-func docutils literal notranslate"><span class="pre">pdb.set_trace()</span></code></a> now takes an optional <em>header</em> keyword-only
  1249. argument. If given, it is printed to the console just before debugging
  1250. begins. (Contributed by Barry Warsaw in <a class="reference external" href="https://bugs.python.org/issue?&#64;action=redirect&amp;bpo=31389">bpo-31389</a>.)</p>
  1251. <p><a class="reference internal" href="../library/pdb.html#module-pdb" title="pdb: The Python debugger for interactive interpreters."><code class="xref py py-mod docutils literal notranslate"><span class="pre">pdb</span></code></a> command line now accepts <code class="docutils literal notranslate"><span class="pre">-m</span> <span class="pre">module_name</span></code> as an alternative to
  1252. script file. (Contributed by Mario Corchero in <a class="reference external" href="https://bugs.python.org/issue?&#64;action=redirect&amp;bpo=32206">bpo-32206</a>.)</p>
  1253. </section>
  1254. <section id="py-compile">
  1255. <h3>py_compile<a class="headerlink" href="#py-compile" title="Link to this heading">¶</a></h3>
  1256. <p><a class="reference internal" href="../library/py_compile.html#py_compile.compile" title="py_compile.compile"><code class="xref py py-func docutils literal notranslate"><span class="pre">py_compile.compile()</span></code></a> – and by extension, <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> – now
  1257. respects the <span class="target" id="index-31"></span><code class="xref std std-envvar docutils literal notranslate"><span class="pre">SOURCE_DATE_EPOCH</span></code> environment variable by
  1258. unconditionally creating <code class="docutils literal notranslate"><span class="pre">.pyc</span></code> files for hash-based validation.
  1259. This allows for guaranteeing
  1260. <a class="reference external" href="https://reproducible-builds.org/">reproducible builds</a> of <code class="docutils literal notranslate"><span class="pre">.pyc</span></code>
  1261. files when they are created eagerly. (Contributed by Bernhard M. Wiedemann
  1262. in <a class="reference external" href="https://bugs.python.org/issue?&#64;action=redirect&amp;bpo=29708">bpo-29708</a>.)</p>
  1263. </section>
  1264. <section id="pydoc">
  1265. <h3>pydoc<a class="headerlink" href="#pydoc" title="Link to this heading">¶</a></h3>
  1266. <p>The pydoc server can now bind to an arbitrary hostname specified by the
  1267. new <code class="docutils literal notranslate"><span class="pre">-n</span></code> command-line argument.
  1268. (Contributed by Feanil Patel in <a class="reference external" href="https://bugs.python.org/issue?&#64;action=redirect&amp;bpo=31128">bpo-31128</a>.)</p>
  1269. </section>
  1270. <section id="queue">
  1271. <h3>queue<a class="headerlink" href="#queue" title="Link to this heading">¶</a></h3>
  1272. <p>The new <a class="reference internal" href="../library/queue.html#queue.SimpleQueue" title="queue.SimpleQueue"><code class="xref py py-class docutils literal notranslate"><span class="pre">SimpleQueue</span></code></a> class is an unbounded <abbr>FIFO</abbr> queue.
  1273. (Contributed by Antoine Pitrou in <a class="reference external" href="https://bugs.python.org/issue?&#64;action=redirect&amp;bpo=14976">bpo-14976</a>.)</p>
  1274. </section>
  1275. <section id="re">
  1276. <h3>re<a class="headerlink" href="#re" title="Link to this heading">¶</a></h3>
  1277. <p>The flags <a class="reference internal" href="../library/re.html#re.ASCII" title="re.ASCII"><code class="xref py py-const docutils literal notranslate"><span class="pre">re.ASCII</span></code></a>, <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> and <a class="reference internal" href="../library/re.html#re.UNICODE" title="re.UNICODE"><code class="xref py py-const docutils literal notranslate"><span class="pre">re.UNICODE</span></code></a>
  1278. can be set within the scope of a group.
  1279. (Contributed by Serhiy Storchaka in <a class="reference external" href="https://bugs.python.org/issue?&#64;action=redirect&amp;bpo=31690">bpo-31690</a>.)</p>
  1280. <p><a class="reference internal" href="../library/re.html#re.split" title="re.split"><code class="xref py py-func docutils literal notranslate"><span class="pre">re.split()</span></code></a> now supports splitting on a pattern like <code class="docutils literal notranslate"><span class="pre">r'\b'</span></code>,
  1281. <code class="docutils literal notranslate"><span class="pre">'^$'</span></code> or <code class="docutils literal notranslate"><span class="pre">(?=-)</span></code> that matches an empty string.
  1282. (Contributed by Serhiy Storchaka in <a class="reference external" href="https://bugs.python.org/issue?&#64;action=redirect&amp;bpo=25054">bpo-25054</a>.)</p>
  1283. <p>Regular expressions compiled with 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 no longer
  1284. depend on the locale at compile time. Locale settings are applied only
  1285. when the compiled regular expression is used.
  1286. (Contributed by Serhiy Storchaka in <a class="reference external" href="https://bugs.python.org/issue?&#64;action=redirect&amp;bpo=30215">bpo-30215</a>.)</p>
  1287. <p><a class="reference internal" href="../library/exceptions.html#FutureWarning" title="FutureWarning"><code class="xref py py-exc docutils literal notranslate"><span class="pre">FutureWarning</span></code></a> is now emitted if a regular expression contains
  1288. character set constructs that will change semantically in the future,
  1289. such as nested sets and set operations.
  1290. (Contributed by Serhiy Storchaka in <a class="reference external" href="https://bugs.python.org/issue?&#64;action=redirect&amp;bpo=30349">bpo-30349</a>.)</p>
  1291. <p>Compiled regular expression and match objects can now be copied
  1292. using <a class="reference internal" href="../library/copy.html#copy.copy" title="copy.copy"><code class="xref py py-func docutils literal notranslate"><span class="pre">copy.copy()</span></code></a> and <a class="reference internal" href="../library/copy.html#copy.deepcopy" title="copy.deepcopy"><code class="xref py py-func docutils literal notranslate"><span class="pre">copy.deepcopy()</span></code></a>.
  1293. (Contributed by Serhiy Storchaka in <a class="reference external" href="https://bugs.python.org/issue?&#64;action=redirect&amp;bpo=10076">bpo-10076</a>.)</p>
  1294. </section>
  1295. <section id="signal">
  1296. <h3>signal<a class="headerlink" href="#signal" title="Link to this heading">¶</a></h3>
  1297. <p>The new <em>warn_on_full_buffer</em> argument to the <a class="reference internal" href="../library/signal.html#signal.set_wakeup_fd" title="signal.set_wakeup_fd"><code class="xref py py-func docutils literal notranslate"><span class="pre">signal.set_wakeup_fd()</span></code></a>
  1298. function makes it possible to specify whether Python prints a warning on
  1299. stderr when the wakeup buffer overflows.
  1300. (Contributed by Nathaniel J. Smith in <a class="reference external" href="https://bugs.python.org/issue?&#64;action=redirect&amp;bpo=30050">bpo-30050</a>.)</p>
  1301. </section>
  1302. <section id="socket">
  1303. <h3>socket<a class="headerlink" href="#socket" title="Link to this heading">¶</a></h3>
  1304. <p>The new <a class="reference internal" href="../library/socket.html#socket.socket.getblocking" title="socket.socket.getblocking"><code class="xref py py-func docutils literal notranslate"><span class="pre">socket.getblocking()</span></code></a> method
  1305. returns <code class="docutils literal notranslate"><span class="pre">True</span></code> if the socket is in blocking mode and <code class="docutils literal notranslate"><span class="pre">False</span></code> otherwise.
  1306. (Contributed by Yury Selivanov in <a class="reference external" href="https://bugs.python.org/issue?&#64;action=redirect&amp;bpo=32373">bpo-32373</a>.)</p>
  1307. <p>The new <a class="reference internal" href="../library/socket.html#socket.close" title="socket.close"><code class="xref py py-func docutils literal notranslate"><span class="pre">socket.close()</span></code></a> function closes the passed socket file descriptor.
  1308. This function should be used instead of <a class="reference internal" href="../library/os.html#os.close" title="os.close"><code class="xref py py-func docutils literal notranslate"><span class="pre">os.close()</span></code></a> for better
  1309. compatibility across platforms.
  1310. (Contributed by Christian Heimes in <a class="reference external" href="https://bugs.python.org/issue?&#64;action=redirect&amp;bpo=32454">bpo-32454</a>.)</p>
  1311. <p>The <a class="reference internal" href="../library/socket.html#module-socket" title="socket: Low-level networking interface."><code class="xref py py-mod docutils literal notranslate"><span class="pre">socket</span></code></a> module now exposes the <code class="xref py py-const docutils literal notranslate"><span class="pre">socket.TCP_CONGESTION</span></code>
  1312. (Linux 2.6.13), <code class="xref py py-const docutils literal notranslate"><span class="pre">socket.TCP_USER_TIMEOUT</span></code> (Linux 2.6.37), and
  1313. <code class="xref py py-const docutils literal notranslate"><span class="pre">socket.TCP_NOTSENT_LOWAT</span></code> (Linux 3.12) constants.
  1314. (Contributed by Omar Sandoval in <a class="reference external" href="https://bugs.python.org/issue?&#64;action=redirect&amp;bpo=26273">bpo-26273</a> and
  1315. Nathaniel J. Smith in <a class="reference external" href="https://bugs.python.org/issue?&#64;action=redirect&amp;bpo=29728">bpo-29728</a>.)</p>
  1316. <p>Support for <a class="reference internal" href="../library/socket.html#socket.AF_VSOCK" title="socket.AF_VSOCK"><code class="xref py py-const docutils literal notranslate"><span class="pre">socket.AF_VSOCK</span></code></a> sockets has been added to allow
  1317. communication between virtual machines and their hosts.
  1318. (Contributed by Cathy Avery in <a class="reference external" href="https://bugs.python.org/issue?&#64;action=redirect&amp;bpo=27584">bpo-27584</a>.)</p>
  1319. <p>Sockets now auto-detect family, type and protocol from file descriptor
  1320. by default.
  1321. (Contributed by Christian Heimes in <a class="reference external" href="https://bugs.python.org/issue?&#64;action=redirect&amp;bpo=28134">bpo-28134</a>.)</p>
  1322. </section>
  1323. <section id="socketserver">
  1324. <h3>socketserver<a class="headerlink" href="#socketserver" title="Link to this heading">¶</a></h3>
  1325. <p><code class="xref py py-meth docutils literal notranslate"><span class="pre">socketserver.ThreadingMixIn.server_close()</span></code> now waits until all non-daemon
  1326. threads complete. <code class="xref py py-meth docutils literal notranslate"><span class="pre">socketserver.ForkingMixIn.server_close()</span></code> now waits
  1327. until all child processes complete.</p>
  1328. <p>Add a new <code class="xref py py-attr docutils literal notranslate"><span class="pre">socketserver.ForkingMixIn.block_on_close</span></code> class attribute to
  1329. <a class="reference internal" href="../library/socketserver.html#socketserver.ForkingMixIn" title="socketserver.ForkingMixIn"><code class="xref py py-class docutils literal notranslate"><span class="pre">socketserver.ForkingMixIn</span></code></a> and <a class="reference internal" href="../library/socketserver.html#socketserver.ThreadingMixIn" title="socketserver.ThreadingMixIn"><code class="xref py py-class docutils literal notranslate"><span class="pre">socketserver.ThreadingMixIn</span></code></a>
  1330. classes. Set the class attribute to <code class="docutils literal notranslate"><span class="pre">False</span></code> to get the pre-3.7 behaviour.</p>
  1331. </section>
  1332. <section id="sqlite3">
  1333. <h3>sqlite3<a class="headerlink" href="#sqlite3" title="Link to this heading">¶</a></h3>
  1334. <p><a class="reference internal" href="../library/sqlite3.html#sqlite3.Connection" title="sqlite3.Connection"><code class="xref py py-class docutils literal notranslate"><span class="pre">sqlite3.Connection</span></code></a> now exposes the <a class="reference internal" href="../library/sqlite3.html#sqlite3.Connection.backup" title="sqlite3.Connection.backup"><code class="xref py py-meth docutils literal notranslate"><span class="pre">backup()</span></code></a>
  1335. method when the underlying SQLite library is at version 3.6.11 or higher.
  1336. (Contributed by Lele Gaifax in <a class="reference external" href="https://bugs.python.org/issue?&#64;action=redirect&amp;bpo=27645">bpo-27645</a>.)</p>
  1337. <p>The <em>database</em> argument of <a class="reference internal" href="../library/sqlite3.html#sqlite3.connect" title="sqlite3.connect"><code class="xref py py-func docutils literal notranslate"><span class="pre">sqlite3.connect()</span></code></a> now accepts any
  1338. <a class="reference internal" href="../glossary.html#term-path-like-object"><span class="xref std std-term">path-like object</span></a>, instead of just a string.
  1339. (Contributed by Anders Lorentsen in <a class="reference external" href="https://bugs.python.org/issue?&#64;action=redirect&amp;bpo=31843">bpo-31843</a>.)</p>
  1340. </section>
  1341. <section id="ssl">
  1342. <h3>ssl<a class="headerlink" href="#ssl" title="Link to this heading">¶</a></h3>
  1343. <p>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 now uses OpenSSL’s builtin API instead of
  1344. <code class="xref py py-func docutils literal notranslate"><span class="pre">match_hostname()</span></code> to check a host name or an IP address. Values
  1345. are validated during TLS handshake. Any certificate validation error
  1346. including failing the host name check now raises
  1347. <a class="reference internal" href="../library/ssl.html#ssl.SSLCertVerificationError" title="ssl.SSLCertVerificationError"><code class="xref py py-exc docutils literal notranslate"><span class="pre">SSLCertVerificationError</span></code></a> and aborts the handshake with a proper
  1348. TLS Alert message. The new exception contains additional information.
  1349. Host name validation can be customized with
  1350. <a class="reference internal" href="../library/ssl.html#ssl.SSLContext.hostname_checks_common_name" title="ssl.SSLContext.hostname_checks_common_name"><code class="xref py py-attr docutils literal notranslate"><span class="pre">SSLContext.hostname_checks_common_name</span></code></a>.
  1351. (Contributed by Christian Heimes in <a class="reference external" href="https://bugs.python.org/issue?&#64;action=redirect&amp;bpo=31399">bpo-31399</a>.)</p>
  1352. <div class="admonition note">
  1353. <p class="admonition-title">Note</p>
  1354. <p>The improved host name check requires a <em>libssl</em> implementation compatible
  1355. with OpenSSL 1.0.2 or 1.1. Consequently, OpenSSL 0.9.8 and 1.0.1 are no
  1356. longer supported (see <a class="reference internal" href="#platform-support-removals"><span class="std std-ref">Platform Support Removals</span></a> for more details).
  1357. The ssl module is mostly compatible with LibreSSL 2.7.2 and newer.</p>
  1358. </div>
  1359. <p>The <code class="docutils literal notranslate"><span class="pre">ssl</span></code> module no longer sends IP addresses in SNI TLS extension.
  1360. (Contributed by Christian Heimes in <a class="reference external" href="https://bugs.python.org/issue?&#64;action=redirect&amp;bpo=32185">bpo-32185</a>.)</p>
  1361. <p><code class="xref py py-func docutils literal notranslate"><span class="pre">match_hostname()</span></code> no longer supports partial wildcards like
  1362. <code class="docutils literal notranslate"><span class="pre">www*.example.org</span></code>.
  1363. (Contributed by Mandeep Singh in <a class="reference external" href="https://bugs.python.org/issue?&#64;action=redirect&amp;bpo=23033">bpo-23033</a> and Christian Heimes in
  1364. <a class="reference external" href="https://bugs.python.org/issue?&#64;action=redirect&amp;bpo=31399">bpo-31399</a>.)</p>
  1365. <p>The default cipher suite selection of the <code class="docutils literal notranslate"><span class="pre">ssl</span></code> module now uses a blacklist
  1366. approach rather than a hard-coded whitelist. Python no longer re-enables
  1367. ciphers that have been blocked by OpenSSL security updates. Default cipher
  1368. suite selection can be configured at compile time.
  1369. (Contributed by Christian Heimes in <a class="reference external" href="https://bugs.python.org/issue?&#64;action=redirect&amp;bpo=31429">bpo-31429</a>.)</p>
  1370. <p>Validation of server certificates containing internationalized domain names
  1371. (IDNs) is now supported. As part of this change, the
  1372. <a class="reference internal" href="../library/ssl.html#ssl.SSLSocket.server_hostname" title="ssl.SSLSocket.server_hostname"><code class="xref py py-attr docutils literal notranslate"><span class="pre">SSLSocket.server_hostname</span></code></a> attribute
  1373. now stores the expected hostname in A-label form (<code class="docutils literal notranslate"><span class="pre">&quot;xn--pythn-mua.org&quot;</span></code>),
  1374. rather than the U-label form (<code class="docutils literal notranslate"><span class="pre">&quot;pythön.org&quot;</span></code>). (Contributed by
  1375. Nathaniel J. Smith and Christian Heimes in <a class="reference external" href="https://bugs.python.org/issue?&#64;action=redirect&amp;bpo=28414">bpo-28414</a>.)</p>
  1376. <p>The <code class="docutils literal notranslate"><span class="pre">ssl</span></code> module has preliminary and experimental support for TLS 1.3 and
  1377. OpenSSL 1.1.1. At the time of Python 3.7.0 release, OpenSSL 1.1.1 is still
  1378. under development and TLS 1.3 hasn’t been finalized yet. The TLS 1.3
  1379. handshake and protocol behaves slightly differently than TLS 1.2 and earlier,
  1380. see <a class="reference internal" href="../library/ssl.html#ssl-tlsv1-3"><span class="std std-ref">TLS 1.3</span></a>.
  1381. (Contributed by Christian Heimes in <a class="reference external" href="https://bugs.python.org/issue?&#64;action=redirect&amp;bpo=32947">bpo-32947</a>, <a class="reference external" href="https://bugs.python.org/issue?&#64;action=redirect&amp;bpo=20995">bpo-20995</a>,
  1382. <a class="reference external" href="https://bugs.python.org/issue?&#64;action=redirect&amp;bpo=29136">bpo-29136</a>, <a class="reference external" href="https://bugs.python.org/issue?&#64;action=redirect&amp;bpo=30622">bpo-30622</a> and <a class="reference external" href="https://bugs.python.org/issue?&#64;action=redirect&amp;bpo=33618">bpo-33618</a>)</p>
  1383. <p><a class="reference internal" href="../library/ssl.html#ssl.SSLSocket" title="ssl.SSLSocket"><code class="xref py py-class docutils literal notranslate"><span class="pre">SSLSocket</span></code></a> and <a class="reference internal" href="../library/ssl.html#ssl.SSLObject" title="ssl.SSLObject"><code class="xref py py-class docutils literal notranslate"><span class="pre">SSLObject</span></code></a> no longer have a public
  1384. constructor. Direct instantiation was never a documented and supported
  1385. feature. Instances must be created with <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> methods
  1386. <a class="reference internal" href="../library/ssl.html#ssl.SSLContext.wrap_socket" title="ssl.SSLContext.wrap_socket"><code class="xref py py-meth docutils literal notranslate"><span class="pre">wrap_socket()</span></code></a> and <a class="reference internal" href="../library/ssl.html#ssl.SSLContext.wrap_bio" title="ssl.SSLContext.wrap_bio"><code class="xref py py-meth docutils literal notranslate"><span class="pre">wrap_bio()</span></code></a>.
  1387. (Contributed by Christian Heimes in <a class="reference external" href="https://bugs.python.org/issue?&#64;action=redirect&amp;bpo=32951">bpo-32951</a>)</p>
  1388. <p>OpenSSL 1.1 APIs for setting the minimum and maximum TLS protocol version are
  1389. available as <a class="reference internal" href="../library/ssl.html#ssl.SSLContext.minimum_version" title="ssl.SSLContext.minimum_version"><code class="xref py py-attr docutils literal notranslate"><span class="pre">SSLContext.minimum_version</span></code></a>
  1390. and <a class="reference internal" href="../library/ssl.html#ssl.SSLContext.maximum_version" title="ssl.SSLContext.maximum_version"><code class="xref py py-attr docutils literal notranslate"><span class="pre">SSLContext.maximum_version</span></code></a>.
  1391. Supported protocols are indicated by several new flags, such as
  1392. <a class="reference internal" href="../library/ssl.html#ssl.HAS_TLSv1_1" title="ssl.HAS_TLSv1_1"><code class="xref py py-data docutils literal notranslate"><span class="pre">HAS_TLSv1_1</span></code></a>.
  1393. (Contributed by Christian Heimes in <a class="reference external" href="https://bugs.python.org/issue?&#64;action=redirect&amp;bpo=32609">bpo-32609</a>.)</p>
  1394. <p>Added <a class="reference internal" href="../library/ssl.html#ssl.SSLContext.post_handshake_auth" title="ssl.SSLContext.post_handshake_auth"><code class="xref py py-attr docutils literal notranslate"><span class="pre">ssl.SSLContext.post_handshake_auth</span></code></a> to enable and
  1395. <a class="reference internal" href="../library/ssl.html#ssl.SSLSocket.verify_client_post_handshake" title="ssl.SSLSocket.verify_client_post_handshake"><code class="xref py py-meth docutils literal notranslate"><span class="pre">ssl.SSLSocket.verify_client_post_handshake()</span></code></a> to initiate TLS 1.3
  1396. post-handshake authentication.
  1397. (Contributed by Christian Heimes in <a class="reference external" href="https://github.com/python/cpython/issues/78851">gh-78851</a>.)</p>
  1398. </section>
  1399. <section id="string">
  1400. <h3>string<a class="headerlink" href="#string" title="Link to this heading">¶</a></h3>
  1401. <p><a class="reference internal" href="../library/string.html#string.Template" title="string.Template"><code class="xref py py-class docutils literal notranslate"><span class="pre">string.Template</span></code></a> now lets you to optionally modify the regular
  1402. expression pattern for braced placeholders and non-braced placeholders
  1403. separately. (Contributed by Barry Warsaw in <a class="reference external" href="https://bugs.python.org/issue?&#64;action=redirect&amp;bpo=1198569">bpo-1198569</a>.)</p>
  1404. </section>
  1405. <section id="subprocess">
  1406. <h3>subprocess<a class="headerlink" href="#subprocess" title="Link to this heading">¶</a></h3>
  1407. <p>The <a class="reference internal" href="../library/subprocess.html#subprocess.run" title="subprocess.run"><code class="xref py py-func docutils literal notranslate"><span class="pre">subprocess.run()</span></code></a> function accepts the new <em>capture_output</em>
  1408. keyword argument. When true, stdout and stderr will be captured.
  1409. This is equivalent to passing <a class="reference internal" href="../library/subprocess.html#subprocess.PIPE" title="subprocess.PIPE"><code class="xref py py-const docutils literal notranslate"><span class="pre">subprocess.PIPE</span></code></a> as <em>stdout</em> and
  1410. <em>stderr</em> arguments.
  1411. (Contributed by Bo Bayles in <a class="reference external" href="https://bugs.python.org/issue?&#64;action=redirect&amp;bpo=32102">bpo-32102</a>.)</p>
  1412. <p>The <code class="docutils literal notranslate"><span class="pre">subprocess.run</span></code> function and 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
  1413. now accept the <em>text</em> keyword argument as an alias
  1414. to <em>universal_newlines</em>.
  1415. (Contributed by Andrew Clegg in <a class="reference external" href="https://bugs.python.org/issue?&#64;action=redirect&amp;bpo=31756">bpo-31756</a>.)</p>
  1416. <p>On Windows the default for <em>close_fds</em> was changed from <code class="docutils literal notranslate"><span class="pre">False</span></code> to
  1417. <code class="docutils literal notranslate"><span class="pre">True</span></code> when redirecting the standard handles. It’s now possible to set
  1418. <em>close_fds</em> to true when redirecting the standard handles. See
  1419. <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>. This means that <em>close_fds</em> now defaults to
  1420. <code class="docutils literal notranslate"><span class="pre">True</span></code> on all supported platforms.
  1421. (Contributed by Segev Finer in <a class="reference external" href="https://bugs.python.org/issue?&#64;action=redirect&amp;bpo=19764">bpo-19764</a>.)</p>
  1422. <p>The subprocess module is now more graceful when handling
  1423. <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> during <a class="reference internal" href="../library/subprocess.html#subprocess.call" title="subprocess.call"><code class="xref py py-func docutils literal notranslate"><span class="pre">subprocess.call()</span></code></a>,
  1424. <a class="reference internal" href="../library/subprocess.html#subprocess.run" title="subprocess.run"><code class="xref py py-func docutils literal notranslate"><span class="pre">subprocess.run()</span></code></a>, or in a <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">Popen</span></code></a>
  1425. context manager. It now waits a short amount of time for the child
  1426. to exit, before continuing the handling of the <code class="docutils literal notranslate"><span class="pre">KeyboardInterrupt</span></code>
  1427. exception.
  1428. (Contributed by Gregory P. Smith in <a class="reference external" href="https://bugs.python.org/issue?&#64;action=redirect&amp;bpo=25942">bpo-25942</a>.)</p>
  1429. </section>
  1430. <section id="sys">
  1431. <h3>sys<a class="headerlink" href="#sys" title="Link to this heading">¶</a></h3>
  1432. <p>The new <a class="reference internal" href="../library/sys.html#sys.breakpointhook" title="sys.breakpointhook"><code class="xref py py-func docutils literal notranslate"><span class="pre">sys.breakpointhook()</span></code></a> hook function is called by the
  1433. built-in <a class="reference internal" href="../library/functions.html#breakpoint" title="breakpoint"><code class="xref py py-func docutils literal notranslate"><span class="pre">breakpoint()</span></code></a>.
  1434. (Contributed by Barry Warsaw in <a class="reference external" href="https://bugs.python.org/issue?&#64;action=redirect&amp;bpo=31353">bpo-31353</a>.)</p>
  1435. <p>On Android, the new <a class="reference internal" href="../library/sys.html#sys.getandroidapilevel" title="sys.getandroidapilevel"><code class="xref py py-func docutils literal notranslate"><span class="pre">sys.getandroidapilevel()</span></code></a> returns the build-time
  1436. Android API version.
  1437. (Contributed by Victor Stinner in <a class="reference external" href="https://bugs.python.org/issue?&#64;action=redirect&amp;bpo=28740">bpo-28740</a>.)</p>
  1438. <p>The new <a class="reference internal" href="../library/sys.html#sys.get_coroutine_origin_tracking_depth" title="sys.get_coroutine_origin_tracking_depth"><code class="xref py py-func docutils literal notranslate"><span class="pre">sys.get_coroutine_origin_tracking_depth()</span></code></a> function returns
  1439. the current coroutine origin tracking depth, as set by
  1440. the new <a class="reference internal" href="../library/sys.html#sys.set_coroutine_origin_tracking_depth" title="sys.set_coroutine_origin_tracking_depth"><code class="xref py py-func docutils literal notranslate"><span class="pre">sys.set_coroutine_origin_tracking_depth()</span></code></a>. <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>
  1441. has been converted to use this new API instead of
  1442. the deprecated <code class="xref py py-func docutils literal notranslate"><span class="pre">sys.set_coroutine_wrapper()</span></code>.
  1443. (Contributed by Nathaniel J. Smith in <a class="reference external" href="https://bugs.python.org/issue?&#64;action=redirect&amp;bpo=32591">bpo-32591</a>.)</p>
  1444. </section>
  1445. <section id="time">
  1446. <h3>time<a class="headerlink" href="#time" title="Link to this heading">¶</a></h3>
  1447. <p><span class="target" id="index-32"></span><a class="pep reference external" href="https://peps.python.org/pep-0564/"><strong>PEP 564</strong></a> adds six new functions with nanosecond resolution to the
  1448. <a class="reference internal" href="../library/time.html#module-time" title="time: Time access and conversions."><code class="xref py py-mod docutils literal notranslate"><span class="pre">time</span></code></a> module:</p>
  1449. <ul class="simple">
  1450. <li><p><a class="reference internal" href="../library/time.html#time.clock_gettime_ns" title="time.clock_gettime_ns"><code class="xref py py-func docutils literal notranslate"><span class="pre">time.clock_gettime_ns()</span></code></a></p></li>
  1451. <li><p><a class="reference internal" href="../library/time.html#time.clock_settime_ns" title="time.clock_settime_ns"><code class="xref py py-func docutils literal notranslate"><span class="pre">time.clock_settime_ns()</span></code></a></p></li>
  1452. <li><p><a class="reference internal" href="../library/time.html#time.monotonic_ns" title="time.monotonic_ns"><code class="xref py py-func docutils literal notranslate"><span class="pre">time.monotonic_ns()</span></code></a></p></li>
  1453. <li><p><a class="reference internal" href="../library/time.html#time.perf_counter_ns" title="time.perf_counter_ns"><code class="xref py py-func docutils literal notranslate"><span class="pre">time.perf_counter_ns()</span></code></a></p></li>
  1454. <li><p><a class="reference internal" href="../library/time.html#time.process_time_ns" title="time.process_time_ns"><code class="xref py py-func docutils literal notranslate"><span class="pre">time.process_time_ns()</span></code></a></p></li>
  1455. <li><p><a class="reference internal" href="../library/time.html#time.time_ns" title="time.time_ns"><code class="xref py py-func docutils literal notranslate"><span class="pre">time.time_ns()</span></code></a></p></li>
  1456. </ul>
  1457. <p>New clock identifiers have been added:</p>
  1458. <ul class="simple">
  1459. <li><p><a class="reference internal" href="../library/time.html#time.CLOCK_BOOTTIME" title="time.CLOCK_BOOTTIME"><code class="xref py py-const docutils literal notranslate"><span class="pre">time.CLOCK_BOOTTIME</span></code></a> (Linux): Identical to
  1460. <a class="reference internal" href="../library/time.html#time.CLOCK_MONOTONIC" title="time.CLOCK_MONOTONIC"><code class="xref py py-const docutils literal notranslate"><span class="pre">time.CLOCK_MONOTONIC</span></code></a>, except it also includes any time that the
  1461. system is suspended.</p></li>
  1462. <li><p><a class="reference internal" href="../library/time.html#time.CLOCK_PROF" title="time.CLOCK_PROF"><code class="xref py py-const docutils literal notranslate"><span class="pre">time.CLOCK_PROF</span></code></a> (FreeBSD, NetBSD and OpenBSD): High-resolution
  1463. per-process CPU timer.</p></li>
  1464. <li><p><a class="reference internal" href="../library/time.html#time.CLOCK_UPTIME" title="time.CLOCK_UPTIME"><code class="xref py py-const docutils literal notranslate"><span class="pre">time.CLOCK_UPTIME</span></code></a> (FreeBSD, OpenBSD): Time whose absolute value is
  1465. the time the system has been running and not suspended, providing accurate
  1466. uptime measurement.</p></li>
  1467. </ul>
  1468. <p>The new <a class="reference internal" href="../library/time.html#time.thread_time" title="time.thread_time"><code class="xref py py-func docutils literal notranslate"><span class="pre">time.thread_time()</span></code></a> and <a class="reference internal" href="../library/time.html#time.thread_time_ns" title="time.thread_time_ns"><code class="xref py py-func docutils literal notranslate"><span class="pre">time.thread_time_ns()</span></code></a> functions
  1469. can be used to get per-thread CPU time measurements.
  1470. (Contributed by Antoine Pitrou in <a class="reference external" href="https://bugs.python.org/issue?&#64;action=redirect&amp;bpo=32025">bpo-32025</a>.)</p>
  1471. <p>The new <a class="reference internal" href="../library/time.html#time.pthread_getcpuclockid" title="time.pthread_getcpuclockid"><code class="xref py py-func docutils literal notranslate"><span class="pre">time.pthread_getcpuclockid()</span></code></a> function returns the clock ID
  1472. of the thread-specific CPU-time clock.</p>
  1473. </section>
  1474. <section id="tkinter">
  1475. <h3>tkinter<a class="headerlink" href="#tkinter" title="Link to this heading">¶</a></h3>
  1476. <p>The new <a class="reference internal" href="../library/tkinter.ttk.html#tkinter.ttk.Spinbox" title="tkinter.ttk.Spinbox"><code class="xref py py-class docutils literal notranslate"><span class="pre">tkinter.ttk.Spinbox</span></code></a> class is now available.
  1477. (Contributed by Alan Moore in <a class="reference external" href="https://bugs.python.org/issue?&#64;action=redirect&amp;bpo=32585">bpo-32585</a>.)</p>
  1478. </section>
  1479. <section id="tracemalloc">
  1480. <h3>tracemalloc<a class="headerlink" href="#tracemalloc" title="Link to this heading">¶</a></h3>
  1481. <p><a class="reference internal" href="../library/tracemalloc.html#tracemalloc.Traceback" title="tracemalloc.Traceback"><code class="xref py py-class docutils literal notranslate"><span class="pre">tracemalloc.Traceback</span></code></a> behaves more like regular tracebacks,
  1482. sorting the frames from oldest to most recent.
  1483. <a class="reference internal" href="../library/tracemalloc.html#tracemalloc.Traceback.format" title="tracemalloc.Traceback.format"><code class="xref py py-meth docutils literal notranslate"><span class="pre">Traceback.format()</span></code></a>
  1484. now accepts negative <em>limit</em>, truncating the result to the
  1485. <code class="docutils literal notranslate"><span class="pre">abs(limit)</span></code> oldest frames. To get the old behaviour, use
  1486. the new <em>most_recent_first</em> argument to <code class="docutils literal notranslate"><span class="pre">Traceback.format()</span></code>.
  1487. (Contributed by Jesse Bakker in <a class="reference external" href="https://bugs.python.org/issue?&#64;action=redirect&amp;bpo=32121">bpo-32121</a>.)</p>
  1488. </section>
  1489. <section id="types">
  1490. <h3>types<a class="headerlink" href="#types" title="Link to this heading">¶</a></h3>
  1491. <p>The new <a class="reference internal" href="../library/types.html#types.WrapperDescriptorType" title="types.WrapperDescriptorType"><code class="xref py py-class docutils literal notranslate"><span class="pre">WrapperDescriptorType</span></code></a>,
  1492. <a class="reference internal" href="../library/types.html#types.MethodWrapperType" title="types.MethodWrapperType"><code class="xref py py-class docutils literal notranslate"><span class="pre">MethodWrapperType</span></code></a>, <a class="reference internal" href="../library/types.html#types.MethodDescriptorType" title="types.MethodDescriptorType"><code class="xref py py-class docutils literal notranslate"><span class="pre">MethodDescriptorType</span></code></a>,
  1493. and <a class="reference internal" href="../library/types.html#types.ClassMethodDescriptorType" title="types.ClassMethodDescriptorType"><code class="xref py py-class docutils literal notranslate"><span class="pre">ClassMethodDescriptorType</span></code></a> classes are now available.
  1494. (Contributed by Manuel Krebber and Guido van Rossum in <a class="reference external" href="https://bugs.python.org/issue?&#64;action=redirect&amp;bpo=29377">bpo-29377</a>,
  1495. and Serhiy Storchaka in <a class="reference external" href="https://bugs.python.org/issue?&#64;action=redirect&amp;bpo=32265">bpo-32265</a>.)</p>
  1496. <p>The new <a class="reference internal" href="../library/types.html#types.resolve_bases" title="types.resolve_bases"><code class="xref py py-func docutils literal notranslate"><span class="pre">types.resolve_bases()</span></code></a> function resolves MRO entries
  1497. dynamically as specified by <span class="target" id="index-33"></span><a class="pep reference external" href="https://peps.python.org/pep-0560/"><strong>PEP 560</strong></a>.
  1498. (Contributed by Ivan Levkivskyi in <a class="reference external" href="https://bugs.python.org/issue?&#64;action=redirect&amp;bpo=32717">bpo-32717</a>.)</p>
  1499. </section>
  1500. <section id="unicodedata">
  1501. <h3>unicodedata<a class="headerlink" href="#unicodedata" title="Link to this heading">¶</a></h3>
  1502. <p>The internal <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> database has been upgraded to use <a class="reference external" href="https://www.unicode.org/versions/Unicode11.0.0/">Unicode 11</a>. (Contributed by Benjamin
  1503. Peterson.)</p>
  1504. </section>
  1505. <section id="unittest">
  1506. <h3>unittest<a class="headerlink" href="#unittest" title="Link to this heading">¶</a></h3>
  1507. <p>The new <code class="docutils literal notranslate"><span class="pre">-k</span></code> command-line option allows filtering tests by a name
  1508. substring or a Unix shell-like pattern.
  1509. For example, <code class="docutils literal notranslate"><span class="pre">python</span> <span class="pre">-m</span> <span class="pre">unittest</span> <span class="pre">-k</span> <span class="pre">foo</span></code> runs
  1510. <code class="docutils literal notranslate"><span class="pre">foo_tests.SomeTest.test_something</span></code>, <code class="docutils literal notranslate"><span class="pre">bar_tests.SomeTest.test_foo</span></code>,
  1511. but not <code class="docutils literal notranslate"><span class="pre">bar_tests.FooTest.test_something</span></code>.
  1512. (Contributed by Jonas Haag in <a class="reference external" href="https://bugs.python.org/issue?&#64;action=redirect&amp;bpo=32071">bpo-32071</a>.)</p>
  1513. </section>
  1514. <section id="unittest-mock">
  1515. <h3>unittest.mock<a class="headerlink" href="#unittest-mock" title="Link to this heading">¶</a></h3>
  1516. <p>The <a class="reference internal" href="../library/unittest.mock.html#unittest.mock.sentinel" title="unittest.mock.sentinel"><code class="xref py py-const docutils literal notranslate"><span class="pre">sentinel</span></code></a> attributes now preserve their identity
  1517. when they are <a class="reference internal" href="../library/copy.html#module-copy" title="copy: Shallow and deep copy operations."><code class="xref py py-mod docutils literal notranslate"><span class="pre">copied</span></code></a> or <a class="reference internal" href="../library/pickle.html#module-pickle" title="pickle: Convert Python objects to streams of bytes and back."><code class="xref py py-mod docutils literal notranslate"><span class="pre">pickled</span></code></a>. (Contributed by
  1518. Serhiy Storchaka in <a class="reference external" href="https://bugs.python.org/issue?&#64;action=redirect&amp;bpo=20804">bpo-20804</a>.)</p>
  1519. <p>The new <a class="reference internal" href="../library/unittest.mock.html#unittest.mock.seal" title="unittest.mock.seal"><code class="xref py py-func docutils literal notranslate"><span class="pre">seal()</span></code></a> function allows sealing
  1520. <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> instances, which will disallow further creation
  1521. of attribute mocks. The seal is applied recursively to all attributes that
  1522. are themselves mocks.
  1523. (Contributed by Mario Corchero in <a class="reference external" href="https://bugs.python.org/issue?&#64;action=redirect&amp;bpo=30541">bpo-30541</a>.)</p>
  1524. </section>
  1525. <section id="urllib-parse">
  1526. <h3>urllib.parse<a class="headerlink" href="#urllib-parse" title="Link to this heading">¶</a></h3>
  1527. <p><a class="reference internal" href="../library/urllib.parse.html#urllib.parse.quote" title="urllib.parse.quote"><code class="xref py py-func docutils literal notranslate"><span class="pre">urllib.parse.quote()</span></code></a> has been updated from <span class="target" id="index-34"></span><a class="rfc reference external" href="https://datatracker.ietf.org/doc/html/rfc2396.html"><strong>RFC 2396</strong></a> to <span class="target" id="index-35"></span><a class="rfc reference external" href="https://datatracker.ietf.org/doc/html/rfc3986.html"><strong>RFC 3986</strong></a>,
  1528. adding <code class="docutils literal notranslate"><span class="pre">~</span></code> to the set of characters that are never quoted by default.
  1529. (Contributed by Christian Theune and Ratnadeep Debnath in <a class="reference external" href="https://bugs.python.org/issue?&#64;action=redirect&amp;bpo=16285">bpo-16285</a>.)</p>
  1530. </section>
  1531. <section id="uu">
  1532. <h3>uu<a class="headerlink" href="#uu" title="Link to this heading">¶</a></h3>
  1533. <p>The <a class="reference internal" href="../library/uu.html#uu.encode" title="uu.encode"><code class="xref py py-func docutils literal notranslate"><span class="pre">uu.encode()</span></code></a> function now accepts an optional <em>backtick</em>
  1534. keyword argument. When it’s true, zeros are represented by <code class="docutils literal notranslate"><span class="pre">'`'</span></code>
  1535. instead of spaces. (Contributed by Xiang Zhang in <a class="reference external" href="https://bugs.python.org/issue?&#64;action=redirect&amp;bpo=30103">bpo-30103</a>.)</p>
  1536. </section>
  1537. <section id="uuid">
  1538. <h3>uuid<a class="headerlink" href="#uuid" title="Link to this heading">¶</a></h3>
  1539. <p>The new <a class="reference internal" href="../library/uuid.html#uuid.UUID.is_safe" title="uuid.UUID.is_safe"><code class="xref py py-attr docutils literal notranslate"><span class="pre">UUID.is_safe</span></code></a> attribute relays information
  1540. from the platform about whether generated UUIDs are generated with a
  1541. multiprocessing-safe method.
  1542. (Contributed by Barry Warsaw in <a class="reference external" href="https://bugs.python.org/issue?&#64;action=redirect&amp;bpo=22807">bpo-22807</a>.)</p>
  1543. <p><a class="reference internal" href="../library/uuid.html#uuid.getnode" title="uuid.getnode"><code class="xref py py-func docutils literal notranslate"><span class="pre">uuid.getnode()</span></code></a> now prefers universally administered
  1544. MAC addresses over locally administered MAC addresses.
  1545. This makes a better guarantee for global uniqueness of UUIDs returned
  1546. from <a class="reference internal" href="../library/uuid.html#uuid.uuid1" title="uuid.uuid1"><code class="xref py py-func docutils literal notranslate"><span class="pre">uuid.uuid1()</span></code></a>. If only locally administered MAC addresses are
  1547. available, the first such one found is returned.
  1548. (Contributed by Barry Warsaw in <a class="reference external" href="https://bugs.python.org/issue?&#64;action=redirect&amp;bpo=32107">bpo-32107</a>.)</p>
  1549. </section>
  1550. <section id="warnings">
  1551. <h3>warnings<a class="headerlink" href="#warnings" title="Link to this heading">¶</a></h3>
  1552. <p>The initialization of the default warnings filters has changed as follows:</p>
  1553. <ul class="simple">
  1554. <li><p>warnings enabled via command line options (including those for <a class="reference internal" href="../using/cmdline.html#cmdoption-b"><code class="xref std std-option docutils literal notranslate"><span class="pre">-b</span></code></a>
  1555. and the new CPython-specific <a class="reference internal" href="../using/cmdline.html#cmdoption-X"><code class="xref std std-option docutils literal notranslate"><span class="pre">-X</span></code></a> <code class="docutils literal notranslate"><span class="pre">dev</span></code> option) are always passed
  1556. to the warnings machinery via the <a class="reference internal" href="../library/sys.html#sys.warnoptions" title="sys.warnoptions"><code class="xref py py-data docutils literal notranslate"><span class="pre">sys.warnoptions</span></code></a> attribute.</p></li>
  1557. <li><p>warnings filters enabled via the command line or the environment now have the
  1558. following order of precedence:</p>
  1559. <ul>
  1560. <li><p>the <code class="docutils literal notranslate"><span class="pre">BytesWarning</span></code> filter for <a class="reference internal" href="../using/cmdline.html#cmdoption-b"><code class="xref std std-option docutils literal notranslate"><span class="pre">-b</span></code></a> (or <code class="docutils literal notranslate"><span class="pre">-bb</span></code>)</p></li>
  1561. <li><p>any filters specified with the <a class="reference internal" href="../using/cmdline.html#cmdoption-W"><code class="xref std std-option docutils literal notranslate"><span class="pre">-W</span></code></a> option</p></li>
  1562. <li><p>any filters specified with the <span class="target" id="index-36"></span><a class="reference internal" href="../using/cmdline.html#envvar-PYTHONWARNINGS"><code class="xref std std-envvar docutils literal notranslate"><span class="pre">PYTHONWARNINGS</span></code></a> environment
  1563. variable</p></li>
  1564. <li><p>any other CPython specific filters (e.g. the <code class="docutils literal notranslate"><span class="pre">default</span></code> filter added
  1565. for the new <code class="docutils literal notranslate"><span class="pre">-X</span> <span class="pre">dev</span></code> mode)</p></li>
  1566. <li><p>any implicit filters defined directly by the warnings machinery</p></li>
  1567. </ul>
  1568. </li>
  1569. <li><p>in <a class="reference internal" href="../using/configure.html#debug-build"><span class="std std-ref">CPython debug builds</span></a>, all warnings are now displayed
  1570. by default (the implicit filter list is empty)</p></li>
  1571. </ul>
  1572. <p>(Contributed by Nick Coghlan and Victor Stinner in <a class="reference external" href="https://bugs.python.org/issue?&#64;action=redirect&amp;bpo=20361">bpo-20361</a>,
  1573. <a class="reference external" href="https://bugs.python.org/issue?&#64;action=redirect&amp;bpo=32043">bpo-32043</a>, and <a class="reference external" href="https://bugs.python.org/issue?&#64;action=redirect&amp;bpo=32230">bpo-32230</a>.)</p>
  1574. <p>Deprecation warnings are once again shown by default in single-file scripts and
  1575. at the interactive prompt. See <a class="reference internal" href="#whatsnew37-pep565"><span class="std std-ref">PEP 565: Show DeprecationWarning in __main__</span></a> for details.
  1576. (Contributed by Nick Coghlan in <a class="reference external" href="https://bugs.python.org/issue?&#64;action=redirect&amp;bpo=31975">bpo-31975</a>.)</p>
  1577. </section>
  1578. <section id="xml">
  1579. <h3>xml<a class="headerlink" href="#xml" title="Link to this heading">¶</a></h3>
  1580. <p>As mitigation against DTD and external entity retrieval, the
  1581. <a class="reference internal" href="../library/xml.dom.minidom.html#module-xml.dom.minidom" title="xml.dom.minidom: Minimal Document Object Model (DOM) implementation."><code class="xref py py-mod docutils literal notranslate"><span class="pre">xml.dom.minidom</span></code></a> and <a class="reference internal" href="../library/xml.sax.html#module-xml.sax" title="xml.sax: Package containing SAX2 base classes and convenience functions."><code class="xref py py-mod docutils literal notranslate"><span class="pre">xml.sax</span></code></a> modules no longer process
  1582. external entities by default.
  1583. (Contributed by Christian Heimes in <a class="reference external" href="https://github.com/python/cpython/issues/61441">gh-61441</a>.)</p>
  1584. </section>
  1585. <section id="xml-etree">
  1586. <h3>xml.etree<a class="headerlink" href="#xml-etree" title="Link to this heading">¶</a></h3>
  1587. <p><a class="reference internal" href="../library/xml.etree.elementtree.html#elementtree-xpath"><span class="std std-ref">ElementPath</span></a> predicates in the <code class="xref py py-meth docutils literal notranslate"><span class="pre">find()</span></code>
  1588. methods can now compare text of the current node with <code class="docutils literal notranslate"><span class="pre">[.</span> <span class="pre">=</span> <span class="pre">&quot;text&quot;]</span></code>,
  1589. not only text in children. Predicates also allow adding spaces for
  1590. better readability. (Contributed by Stefan Behnel in <a class="reference external" href="https://bugs.python.org/issue?&#64;action=redirect&amp;bpo=31648">bpo-31648</a>.)</p>
  1591. </section>
  1592. <section id="xmlrpc-server">
  1593. <h3>xmlrpc.server<a class="headerlink" href="#xmlrpc-server" title="Link to this heading">¶</a></h3>
  1594. <p><code class="xref py py-meth docutils literal notranslate"><span class="pre">SimpleXMLRPCDispatcher.register_function</span></code>
  1595. can now be used as a decorator. (Contributed by Xiang Zhang in
  1596. <a class="reference external" href="https://bugs.python.org/issue?&#64;action=redirect&amp;bpo=7769">bpo-7769</a>.)</p>
  1597. </section>
  1598. <section id="zipapp">
  1599. <h3>zipapp<a class="headerlink" href="#zipapp" title="Link to this heading">¶</a></h3>
  1600. <p>Function <a class="reference internal" href="../library/zipapp.html#zipapp.create_archive" title="zipapp.create_archive"><code class="xref py py-func docutils literal notranslate"><span class="pre">create_archive()</span></code></a> now accepts an optional <em>filter</em>
  1601. argument to allow the user to select which files should be included in the
  1602. archive. (Contributed by Irmen de Jong in <a class="reference external" href="https://bugs.python.org/issue?&#64;action=redirect&amp;bpo=31072">bpo-31072</a>.)</p>
  1603. <p>Function <a class="reference internal" href="../library/zipapp.html#zipapp.create_archive" title="zipapp.create_archive"><code class="xref py py-func docutils literal notranslate"><span class="pre">create_archive()</span></code></a> now accepts an optional <em>compressed</em>
  1604. argument to generate a compressed archive. A command line option
  1605. <code class="docutils literal notranslate"><span class="pre">--compress</span></code> has also been added to support compression.
  1606. (Contributed by Zhiming Wang in <a class="reference external" href="https://bugs.python.org/issue?&#64;action=redirect&amp;bpo=31638">bpo-31638</a>.)</p>
  1607. </section>
  1608. <section id="zipfile">
  1609. <h3>zipfile<a class="headerlink" href="#zipfile" title="Link to this heading">¶</a></h3>
  1610. <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</span></code></a> now accepts the new <em>compresslevel</em> parameter to
  1611. control the compression level.
  1612. (Contributed by Bo Bayles in <a class="reference external" href="https://bugs.python.org/issue?&#64;action=redirect&amp;bpo=21417">bpo-21417</a>.)</p>
  1613. <p>Subdirectories in archives created by <code class="docutils literal notranslate"><span class="pre">ZipFile</span></code> are now stored in
  1614. alphabetical order.
  1615. (Contributed by Bernhard M. Wiedemann in <a class="reference external" href="https://bugs.python.org/issue?&#64;action=redirect&amp;bpo=30693">bpo-30693</a>.)</p>
  1616. </section>
  1617. </section>
  1618. <section id="c-api-changes">
  1619. <h2>C API Changes<a class="headerlink" href="#c-api-changes" title="Link to this heading">¶</a></h2>
  1620. <p>A new API for thread-local storage has been implemented. See
  1621. <a class="reference internal" href="#whatsnew37-pep539"><span class="std std-ref">PEP 539: New C API for Thread-Local Storage</span></a> for an overview and
  1622. <a class="reference internal" href="../c-api/init.html#thread-specific-storage-api"><span class="std std-ref">Thread Specific Storage (TSS) API</span></a> for a complete reference.
  1623. (Contributed by Masayuki Yamamoto in <a class="reference external" href="https://bugs.python.org/issue?&#64;action=redirect&amp;bpo=25658">bpo-25658</a>.)</p>
  1624. <p>The new <a class="reference internal" href="#whatsnew37-pep567"><span class="std std-ref">context variables</span></a> functionality
  1625. exposes a number of <a class="reference internal" href="../c-api/contextvars.html#contextvarsobjects"><span class="std std-ref">new C APIs</span></a>.</p>
  1626. <p>The new <a class="reference internal" href="../c-api/import.html#c.PyImport_GetModule" title="PyImport_GetModule"><code class="xref c c-func docutils literal notranslate"><span class="pre">PyImport_GetModule()</span></code></a> function returns the previously
  1627. imported module with the given name.
  1628. (Contributed by Eric Snow in <a class="reference external" href="https://bugs.python.org/issue?&#64;action=redirect&amp;bpo=28411">bpo-28411</a>.)</p>
  1629. <p>The new <a class="reference internal" href="../c-api/typeobj.html#c.Py_RETURN_RICHCOMPARE" title="Py_RETURN_RICHCOMPARE"><code class="xref c c-macro docutils literal notranslate"><span class="pre">Py_RETURN_RICHCOMPARE</span></code></a> macro eases writing rich
  1630. comparison functions.
  1631. (Contributed by Petr Victorin in <a class="reference external" href="https://bugs.python.org/issue?&#64;action=redirect&amp;bpo=23699">bpo-23699</a>.)</p>
  1632. <p>The new <a class="reference internal" href="../c-api/intro.html#c.Py_UNREACHABLE" title="Py_UNREACHABLE"><code class="xref c c-macro docutils literal notranslate"><span class="pre">Py_UNREACHABLE</span></code></a> macro can be used to mark unreachable
  1633. code paths.
  1634. (Contributed by Barry Warsaw in <a class="reference external" href="https://bugs.python.org/issue?&#64;action=redirect&amp;bpo=31338">bpo-31338</a>.)</p>
  1635. <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> now exposes a C API through the new
  1636. <a class="reference internal" href="../c-api/memory.html#c.PyTraceMalloc_Track" title="PyTraceMalloc_Track"><code class="xref c c-func docutils literal notranslate"><span class="pre">PyTraceMalloc_Track()</span></code></a> and <a class="reference internal" href="../c-api/memory.html#c.PyTraceMalloc_Untrack" title="PyTraceMalloc_Untrack"><code class="xref c c-func docutils literal notranslate"><span class="pre">PyTraceMalloc_Untrack()</span></code></a>
  1637. functions.
  1638. (Contributed by Victor Stinner in <a class="reference external" href="https://bugs.python.org/issue?&#64;action=redirect&amp;bpo=30054">bpo-30054</a>.)</p>
  1639. <p>The new <code class="xref c c-func docutils literal notranslate"><span class="pre">import__find__load__start()</span></code> and
  1640. <code class="xref c c-func docutils literal notranslate"><span class="pre">import__find__load__done()</span></code> static markers can be used to trace
  1641. module imports.
  1642. (Contributed by Christian Heimes in <a class="reference external" href="https://bugs.python.org/issue?&#64;action=redirect&amp;bpo=31574">bpo-31574</a>.)</p>
  1643. <p>The fields <code class="xref c c-member docutils literal notranslate"><span class="pre">name</span></code> and <code class="xref c c-member docutils literal notranslate"><span class="pre">doc</span></code> of structures
  1644. <a class="reference internal" href="../c-api/structures.html#c.PyMemberDef" title="PyMemberDef"><code class="xref c c-type docutils literal notranslate"><span class="pre">PyMemberDef</span></code></a>, <a class="reference internal" href="../c-api/structures.html#c.PyGetSetDef" title="PyGetSetDef"><code class="xref c c-type docutils literal notranslate"><span class="pre">PyGetSetDef</span></code></a>,
  1645. <a class="reference internal" href="../c-api/tuple.html#c.PyStructSequence_Field" title="PyStructSequence_Field"><code class="xref c c-type docutils literal notranslate"><span class="pre">PyStructSequence_Field</span></code></a>, <a class="reference internal" href="../c-api/tuple.html#c.PyStructSequence_Desc" title="PyStructSequence_Desc"><code class="xref c c-type docutils literal notranslate"><span class="pre">PyStructSequence_Desc</span></code></a>,
  1646. and <code class="xref c c-struct docutils literal notranslate"><span class="pre">wrapperbase</span></code> are now of type <code class="docutils literal notranslate"><span class="pre">const</span> <span class="pre">char</span> <span class="pre">*</span></code> rather of
  1647. <code class="docutils literal notranslate"><span class="pre">char</span> <span class="pre">*</span></code>. (Contributed by Serhiy Storchaka in <a class="reference external" href="https://bugs.python.org/issue?&#64;action=redirect&amp;bpo=28761">bpo-28761</a>.)</p>
  1648. <p>The result of <a class="reference internal" href="../c-api/unicode.html#c.PyUnicode_AsUTF8AndSize" title="PyUnicode_AsUTF8AndSize"><code class="xref c c-func docutils literal notranslate"><span class="pre">PyUnicode_AsUTF8AndSize()</span></code></a> and <a class="reference internal" href="../c-api/unicode.html#c.PyUnicode_AsUTF8" title="PyUnicode_AsUTF8"><code class="xref c c-func docutils literal notranslate"><span class="pre">PyUnicode_AsUTF8()</span></code></a>
  1649. is now of type <code class="docutils literal notranslate"><span class="pre">const</span> <span class="pre">char</span> <span class="pre">*</span></code> rather of <code class="docutils literal notranslate"><span class="pre">char</span> <span class="pre">*</span></code>. (Contributed by Serhiy
  1650. Storchaka in <a class="reference external" href="https://bugs.python.org/issue?&#64;action=redirect&amp;bpo=28769">bpo-28769</a>.)</p>
  1651. <p>The result of <a class="reference internal" href="../c-api/mapping.html#c.PyMapping_Keys" title="PyMapping_Keys"><code class="xref c c-func docutils literal notranslate"><span class="pre">PyMapping_Keys()</span></code></a>, <a class="reference internal" href="../c-api/mapping.html#c.PyMapping_Values" title="PyMapping_Values"><code class="xref c c-func docutils literal notranslate"><span class="pre">PyMapping_Values()</span></code></a> and
  1652. <a class="reference internal" href="../c-api/mapping.html#c.PyMapping_Items" title="PyMapping_Items"><code class="xref c c-func docutils literal notranslate"><span class="pre">PyMapping_Items()</span></code></a> is now always a list, rather than a list or a
  1653. tuple. (Contributed by Oren Milman in <a class="reference external" href="https://bugs.python.org/issue?&#64;action=redirect&amp;bpo=28280">bpo-28280</a>.)</p>
  1654. <p>Added functions <a class="reference internal" href="../c-api/slice.html#c.PySlice_Unpack" title="PySlice_Unpack"><code class="xref c c-func docutils literal notranslate"><span class="pre">PySlice_Unpack()</span></code></a> and <a class="reference internal" href="../c-api/slice.html#c.PySlice_AdjustIndices" title="PySlice_AdjustIndices"><code class="xref c c-func docutils literal notranslate"><span class="pre">PySlice_AdjustIndices()</span></code></a>.
  1655. (Contributed by Serhiy Storchaka in <a class="reference external" href="https://bugs.python.org/issue?&#64;action=redirect&amp;bpo=27867">bpo-27867</a>.)</p>
  1656. <p><a class="reference internal" href="../c-api/sys.html#c.PyOS_AfterFork" title="PyOS_AfterFork"><code class="xref c c-func docutils literal notranslate"><span class="pre">PyOS_AfterFork()</span></code></a> is deprecated in favour of the new functions
  1657. <a class="reference internal" href="../c-api/sys.html#c.PyOS_BeforeFork" title="PyOS_BeforeFork"><code class="xref c c-func docutils literal notranslate"><span class="pre">PyOS_BeforeFork()</span></code></a>, <a class="reference internal" href="../c-api/sys.html#c.PyOS_AfterFork_Parent" title="PyOS_AfterFork_Parent"><code class="xref c c-func docutils literal notranslate"><span class="pre">PyOS_AfterFork_Parent()</span></code></a> and
  1658. <a class="reference internal" href="../c-api/sys.html#c.PyOS_AfterFork_Child" title="PyOS_AfterFork_Child"><code class="xref c c-func docutils literal notranslate"><span class="pre">PyOS_AfterFork_Child()</span></code></a>. (Contributed by Antoine Pitrou in
  1659. <a class="reference external" href="https://bugs.python.org/issue?&#64;action=redirect&amp;bpo=16500">bpo-16500</a>.)</p>
  1660. <p>The <code class="docutils literal notranslate"><span class="pre">PyExc_RecursionErrorInst</span></code> singleton that was part of the public API
  1661. has been removed as its members being never cleared may cause a segfault
  1662. during finalization of the interpreter. Contributed by Xavier de Gaye in
  1663. <a class="reference external" href="https://bugs.python.org/issue?&#64;action=redirect&amp;bpo=22898">bpo-22898</a> and <a class="reference external" href="https://bugs.python.org/issue?&#64;action=redirect&amp;bpo=30697">bpo-30697</a>.</p>
  1664. <p>Added C API support for timezones with timezone constructors
  1665. <a class="reference internal" href="../c-api/datetime.html#c.PyTimeZone_FromOffset" title="PyTimeZone_FromOffset"><code class="xref c c-func docutils literal notranslate"><span class="pre">PyTimeZone_FromOffset()</span></code></a> and <a class="reference internal" href="../c-api/datetime.html#c.PyTimeZone_FromOffsetAndName" title="PyTimeZone_FromOffsetAndName"><code class="xref c c-func docutils literal notranslate"><span class="pre">PyTimeZone_FromOffsetAndName()</span></code></a>,
  1666. and access to the UTC singleton with <a class="reference internal" href="../c-api/datetime.html#c.PyDateTime_TimeZone_UTC" title="PyDateTime_TimeZone_UTC"><code class="xref c c-data docutils literal notranslate"><span class="pre">PyDateTime_TimeZone_UTC</span></code></a>.
  1667. Contributed by Paul Ganssle in <a class="reference external" href="https://bugs.python.org/issue?&#64;action=redirect&amp;bpo=10381">bpo-10381</a>.</p>
  1668. <p>The type of results of <code class="xref c c-func docutils literal notranslate"><span class="pre">PyThread_start_new_thread()</span></code> and
  1669. <code class="xref c c-func docutils literal notranslate"><span class="pre">PyThread_get_thread_ident()</span></code>, and the <em>id</em> parameter of
  1670. <a class="reference internal" href="../c-api/init.html#c.PyThreadState_SetAsyncExc" title="PyThreadState_SetAsyncExc"><code class="xref c c-func docutils literal notranslate"><span class="pre">PyThreadState_SetAsyncExc()</span></code></a> changed from <span class="c-expr sig sig-inline c"><span class="kt">long</span></span> to
  1671. <span class="c-expr sig sig-inline c"><span class="kt">unsigned</span><span class="w"> </span><span class="kt">long</span></span>.
  1672. (Contributed by Serhiy Storchaka in <a class="reference external" href="https://bugs.python.org/issue?&#64;action=redirect&amp;bpo=6532">bpo-6532</a>.)</p>
  1673. <p><a class="reference internal" href="../c-api/unicode.html#c.PyUnicode_AsWideCharString" title="PyUnicode_AsWideCharString"><code class="xref c c-func docutils literal notranslate"><span class="pre">PyUnicode_AsWideCharString()</span></code></a> now raises 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> if the
  1674. second argument is <code class="docutils literal notranslate"><span class="pre">NULL</span></code> and the <span class="c-expr sig sig-inline c"><span class="n">wchar_t</span><span class="p">*</span></span> string contains null
  1675. characters. (Contributed by Serhiy Storchaka in <a class="reference external" href="https://bugs.python.org/issue?&#64;action=redirect&amp;bpo=30708">bpo-30708</a>.)</p>
  1676. <p>Changes to the startup sequence and the management of dynamic memory
  1677. allocators mean that the long documented requirement to call
  1678. <a class="reference internal" href="../c-api/init.html#c.Py_Initialize" title="Py_Initialize"><code class="xref c c-func docutils literal notranslate"><span class="pre">Py_Initialize()</span></code></a> before calling most C API functions is now
  1679. relied on more heavily, and failing to abide by it may lead to segfaults in
  1680. embedding applications. See the <a class="reference internal" href="#porting-to-python-37"><span class="std std-ref">Porting to Python 3.7</span></a> section in this
  1681. document and the <a class="reference internal" href="../c-api/init.html#pre-init-safe"><span class="std std-ref">Before Python Initialization</span></a> section in the C API documentation
  1682. for more details.</p>
  1683. <p>The new <a class="reference internal" href="../c-api/init.html#c.PyInterpreterState_GetID" title="PyInterpreterState_GetID"><code class="xref c c-func docutils literal notranslate"><span class="pre">PyInterpreterState_GetID()</span></code></a> returns the unique ID for a
  1684. given interpreter.
  1685. (Contributed by Eric Snow in <a class="reference external" href="https://bugs.python.org/issue?&#64;action=redirect&amp;bpo=29102">bpo-29102</a>.)</p>
  1686. <p><a class="reference internal" href="../c-api/sys.html#c.Py_DecodeLocale" title="Py_DecodeLocale"><code class="xref c c-func docutils literal notranslate"><span class="pre">Py_DecodeLocale()</span></code></a>, <a class="reference internal" href="../c-api/sys.html#c.Py_EncodeLocale" title="Py_EncodeLocale"><code class="xref c c-func docutils literal notranslate"><span class="pre">Py_EncodeLocale()</span></code></a> now use the UTF-8
  1687. encoding when the <a class="reference internal" href="#whatsnew37-pep540"><span class="std std-ref">UTF-8 mode</span></a> is enabled.
  1688. (Contributed by Victor Stinner in <a class="reference external" href="https://bugs.python.org/issue?&#64;action=redirect&amp;bpo=29240">bpo-29240</a>.)</p>
  1689. <p><a class="reference internal" href="../c-api/unicode.html#c.PyUnicode_DecodeLocaleAndSize" title="PyUnicode_DecodeLocaleAndSize"><code class="xref c c-func docutils literal notranslate"><span class="pre">PyUnicode_DecodeLocaleAndSize()</span></code></a> and <a class="reference internal" href="../c-api/unicode.html#c.PyUnicode_EncodeLocale" title="PyUnicode_EncodeLocale"><code class="xref c c-func docutils literal notranslate"><span class="pre">PyUnicode_EncodeLocale()</span></code></a>
  1690. now use the current locale encoding for <code class="docutils literal notranslate"><span class="pre">surrogateescape</span></code> error handler.
  1691. (Contributed by Victor Stinner in <a class="reference external" href="https://bugs.python.org/issue?&#64;action=redirect&amp;bpo=29240">bpo-29240</a>.)</p>
  1692. <p>The <em>start</em> and <em>end</em> parameters of <a class="reference internal" href="../c-api/unicode.html#c.PyUnicode_FindChar" title="PyUnicode_FindChar"><code class="xref c c-func docutils literal notranslate"><span class="pre">PyUnicode_FindChar()</span></code></a> are
  1693. now adjusted to behave like string slices.
  1694. (Contributed by Xiang Zhang in <a class="reference external" href="https://bugs.python.org/issue?&#64;action=redirect&amp;bpo=28822">bpo-28822</a>.)</p>
  1695. </section>
  1696. <section id="build-changes">
  1697. <h2>Build Changes<a class="headerlink" href="#build-changes" title="Link to this heading">¶</a></h2>
  1698. <p>Support for building <code class="docutils literal notranslate"><span class="pre">--without-threads</span></code> has been removed. The
  1699. <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> module is now always available.
  1700. (Contributed by Antoine Pitrou in <a class="reference external" href="https://bugs.python.org/issue?&#64;action=redirect&amp;bpo=31370">bpo-31370</a>.).</p>
  1701. <p>A full copy of libffi is no longer bundled for use when building the
  1702. <a class="reference internal" href="../library/ctypes.html#module-ctypes" title="ctypes: A foreign function library for Python."><code class="xref py py-mod docutils literal notranslate"><span class="pre">_ctypes</span></code></a> module on non-OSX UNIX platforms. An installed copy
  1703. of libffi is now required when building <code class="docutils literal notranslate"><span class="pre">_ctypes</span></code> on such platforms.
  1704. (Contributed by Zachary Ware in <a class="reference external" href="https://bugs.python.org/issue?&#64;action=redirect&amp;bpo=27979">bpo-27979</a>.)</p>
  1705. <p>The Windows build process no longer depends on Subversion to pull in external
  1706. sources, a Python script is used to download zipfiles from GitHub instead.
  1707. If Python 3.6 is not found on the system (via <code class="docutils literal notranslate"><span class="pre">py</span> <span class="pre">-3.6</span></code>), NuGet is used to
  1708. download a copy of 32-bit Python for this purpose. (Contributed by Zachary
  1709. Ware in <a class="reference external" href="https://bugs.python.org/issue?&#64;action=redirect&amp;bpo=30450">bpo-30450</a>.)</p>
  1710. <p>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 requires OpenSSL 1.0.2 or 1.1 compatible libssl.
  1711. OpenSSL 1.0.1 has reached end of lifetime on 2016-12-31 and is no longer
  1712. supported. LibreSSL is temporarily not supported as well. LibreSSL releases
  1713. up to version 2.6.4 are missing required OpenSSL 1.0.2 APIs.</p>
  1714. </section>
  1715. <section id="optimizations">
  1716. <span id="whatsnew37-perf"></span><h2>Optimizations<a class="headerlink" href="#optimizations" title="Link to this heading">¶</a></h2>
  1717. <p>The overhead of calling many methods of various standard library classes
  1718. implemented in C has been significantly reduced by porting more code
  1719. to use the <code class="docutils literal notranslate"><span class="pre">METH_FASTCALL</span></code> convention.
  1720. (Contributed by Victor Stinner in <a class="reference external" href="https://bugs.python.org/issue?&#64;action=redirect&amp;bpo=29300">bpo-29300</a>, <a class="reference external" href="https://bugs.python.org/issue?&#64;action=redirect&amp;bpo=29507">bpo-29507</a>,
  1721. <a class="reference external" href="https://bugs.python.org/issue?&#64;action=redirect&amp;bpo=29452">bpo-29452</a>, and <a class="reference external" href="https://bugs.python.org/issue?&#64;action=redirect&amp;bpo=29286">bpo-29286</a>.)</p>
  1722. <p>Various optimizations have reduced Python startup time by 10% on Linux and
  1723. up to 30% on macOS.
  1724. (Contributed by Victor Stinner, INADA Naoki in <a class="reference external" href="https://bugs.python.org/issue?&#64;action=redirect&amp;bpo=29585">bpo-29585</a>, and
  1725. Ivan Levkivskyi in <a class="reference external" href="https://bugs.python.org/issue?&#64;action=redirect&amp;bpo=31333">bpo-31333</a>.)</p>
  1726. <p>Method calls are now up to 20% faster due to the bytecode changes which
  1727. avoid creating bound method instances.
  1728. (Contributed by Yury Selivanov and INADA Naoki in <a class="reference external" href="https://bugs.python.org/issue?&#64;action=redirect&amp;bpo=26110">bpo-26110</a>.)</p>
  1729. <p id="whatsnew37-asyncio-perf">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 received a number of notable optimizations for
  1730. commonly used functions:</p>
  1731. <ul class="simple">
  1732. <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">asyncio.get_event_loop()</span></code></a> function has been reimplemented in C to
  1733. make it up to 15 times faster.
  1734. (Contributed by Yury Selivanov in <a class="reference external" href="https://bugs.python.org/issue?&#64;action=redirect&amp;bpo=32296">bpo-32296</a>.)</p></li>
  1735. <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">asyncio.Future</span></code></a> callback management has been optimized.
  1736. (Contributed by Yury Selivanov in <a class="reference external" href="https://bugs.python.org/issue?&#64;action=redirect&amp;bpo=32348">bpo-32348</a>.)</p></li>
  1737. <li><p><a class="reference internal" href="../library/asyncio-task.html#asyncio.gather" title="asyncio.gather"><code class="xref py py-func docutils literal notranslate"><span class="pre">asyncio.gather()</span></code></a> is now up to 15% faster.
  1738. (Contributed by Yury Selivanov in <a class="reference external" href="https://bugs.python.org/issue?&#64;action=redirect&amp;bpo=32355">bpo-32355</a>.)</p></li>
  1739. <li><p><a class="reference internal" href="../library/asyncio-task.html#asyncio.sleep" title="asyncio.sleep"><code class="xref py py-func docutils literal notranslate"><span class="pre">asyncio.sleep()</span></code></a> is now up to 2 times faster when the <em>delay</em>
  1740. argument is zero or negative.
  1741. (Contributed by Andrew Svetlov in <a class="reference external" href="https://bugs.python.org/issue?&#64;action=redirect&amp;bpo=32351">bpo-32351</a>.)</p></li>
  1742. <li><p>The performance overhead of asyncio debug mode has been reduced.
  1743. (Contributed by Antoine Pitrou in <a class="reference external" href="https://bugs.python.org/issue?&#64;action=redirect&amp;bpo=31970">bpo-31970</a>.)</p></li>
  1744. </ul>
  1745. <p>As a result of <a class="reference internal" href="#whatsnew37-pep560"><span class="std std-ref">PEP 560 work</span></a>, the import time
  1746. of <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> has been reduced by a factor of 7, and many typing operations
  1747. are now faster.
  1748. (Contributed by Ivan Levkivskyi in <a class="reference external" href="https://bugs.python.org/issue?&#64;action=redirect&amp;bpo=32226">bpo-32226</a>.)</p>
  1749. <p><a class="reference internal" href="../library/functions.html#sorted" title="sorted"><code class="xref py py-func docutils literal notranslate"><span class="pre">sorted()</span></code></a> and <a class="reference internal" href="../library/stdtypes.html#list.sort" title="list.sort"><code class="xref py py-meth docutils literal notranslate"><span class="pre">list.sort()</span></code></a> have been optimized for common cases
  1750. to be up to 40-75% faster.
  1751. (Contributed by Elliot Gorokhovsky in <a class="reference external" href="https://bugs.python.org/issue?&#64;action=redirect&amp;bpo=28685">bpo-28685</a>.)</p>
  1752. <p><a class="reference internal" href="../library/stdtypes.html#dict.copy" title="dict.copy"><code class="xref py py-meth docutils literal notranslate"><span class="pre">dict.copy()</span></code></a> is now up to 5.5 times faster.
  1753. (Contributed by Yury Selivanov in <a class="reference external" href="https://bugs.python.org/issue?&#64;action=redirect&amp;bpo=31179">bpo-31179</a>.)</p>
  1754. <p><a class="reference internal" href="../library/functions.html#hasattr" title="hasattr"><code class="xref py py-func docutils literal notranslate"><span class="pre">hasattr()</span></code></a> and <a class="reference internal" href="../library/functions.html#getattr" title="getattr"><code class="xref py py-func docutils literal notranslate"><span class="pre">getattr()</span></code></a> are now about 4 times faster when
  1755. <em>name</em> is not found and <em>obj</em> does not override <a class="reference internal" href="../reference/datamodel.html#object.__getattr__" title="object.__getattr__"><code class="xref py py-meth docutils literal notranslate"><span class="pre">object.__getattr__()</span></code></a>
  1756. or <a class="reference internal" href="../reference/datamodel.html#object.__getattribute__" title="object.__getattribute__"><code class="xref py py-meth docutils literal notranslate"><span class="pre">object.__getattribute__()</span></code></a>.
  1757. (Contributed by INADA Naoki in <a class="reference external" href="https://bugs.python.org/issue?&#64;action=redirect&amp;bpo=32544">bpo-32544</a>.)</p>
  1758. <p>Searching for certain Unicode characters (like Ukrainian capital “Є”)
  1759. in a string was up to 25 times slower than searching for other characters.
  1760. It is now only 3 times slower in the worst case.
  1761. (Contributed by Serhiy Storchaka in <a class="reference external" href="https://bugs.python.org/issue?&#64;action=redirect&amp;bpo=24821">bpo-24821</a>.)</p>
  1762. <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">collections.namedtuple()</span></code></a> factory has been reimplemented to
  1763. make the creation of named tuples 4 to 6 times faster.
  1764. (Contributed by Jelle Zijlstra with further improvements by INADA Naoki,
  1765. Serhiy Storchaka, and Raymond Hettinger in <a class="reference external" href="https://bugs.python.org/issue?&#64;action=redirect&amp;bpo=28638">bpo-28638</a>.)</p>
  1766. <p><code class="xref py py-meth docutils literal notranslate"><span class="pre">date.fromordinal()</span></code> and <code class="xref py py-meth docutils literal notranslate"><span class="pre">date.fromtimestamp()</span></code> are now up to
  1767. 30% faster in the common case.
  1768. (Contributed by Paul Ganssle in <a class="reference external" href="https://bugs.python.org/issue?&#64;action=redirect&amp;bpo=32403">bpo-32403</a>.)</p>
  1769. <p>The <a class="reference internal" href="../library/os.html#os.fwalk" title="os.fwalk"><code class="xref py py-func docutils literal notranslate"><span class="pre">os.fwalk()</span></code></a> function is now up to 2 times faster thanks to
  1770. the use of <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>.
  1771. (Contributed by Serhiy Storchaka in <a class="reference external" href="https://bugs.python.org/issue?&#64;action=redirect&amp;bpo=25996">bpo-25996</a>.)</p>
  1772. <p>The speed of the <a class="reference internal" href="../library/shutil.html#shutil.rmtree" title="shutil.rmtree"><code class="xref py py-func docutils literal notranslate"><span class="pre">shutil.rmtree()</span></code></a> function has been improved by
  1773. 20–40% thanks to the use of 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">os.scandir()</span></code></a> function.
  1774. (Contributed by Serhiy Storchaka in <a class="reference external" href="https://bugs.python.org/issue?&#64;action=redirect&amp;bpo=28564">bpo-28564</a>.)</p>
  1775. <p>Optimized case-insensitive matching and searching of <a class="reference internal" href="../library/re.html#module-re" title="re: Regular expression operations."><code class="xref py py-mod docutils literal notranslate"><span class="pre">regular</span>
  1776. <span class="pre">expressions</span></code></a>. Searching some patterns can now be up to 20 times faster.
  1777. (Contributed by Serhiy Storchaka in <a class="reference external" href="https://bugs.python.org/issue?&#64;action=redirect&amp;bpo=30285">bpo-30285</a>.)</p>
  1778. <p><a class="reference internal" href="../library/re.html#re.compile" title="re.compile"><code class="xref py py-func docutils literal notranslate"><span class="pre">re.compile()</span></code></a> now converts <code class="docutils literal notranslate"><span class="pre">flags</span></code> parameter to int object if
  1779. it is <code class="docutils literal notranslate"><span class="pre">RegexFlag</span></code>. It is now as fast as Python 3.5, and faster than
  1780. Python 3.6 by about 10% depending on the pattern.
  1781. (Contributed by INADA Naoki in <a class="reference external" href="https://bugs.python.org/issue?&#64;action=redirect&amp;bpo=31671">bpo-31671</a>.)</p>
  1782. <p>The <a class="reference internal" href="../library/selectors.html#selectors.BaseSelector.modify" title="selectors.BaseSelector.modify"><code class="xref py py-meth docutils literal notranslate"><span class="pre">modify()</span></code></a> methods of classes
  1783. <a class="reference internal" href="../library/selectors.html#selectors.EpollSelector" title="selectors.EpollSelector"><code class="xref py py-class docutils literal notranslate"><span class="pre">selectors.EpollSelector</span></code></a>, <a class="reference internal" href="../library/selectors.html#selectors.PollSelector" title="selectors.PollSelector"><code class="xref py py-class docutils literal notranslate"><span class="pre">selectors.PollSelector</span></code></a>
  1784. and <a class="reference internal" href="../library/selectors.html#selectors.DevpollSelector" title="selectors.DevpollSelector"><code class="xref py py-class docutils literal notranslate"><span class="pre">selectors.DevpollSelector</span></code></a> may be around 10% faster under
  1785. heavy loads. (Contributed by Giampaolo Rodola’ in <a class="reference external" href="https://bugs.python.org/issue?&#64;action=redirect&amp;bpo=30014">bpo-30014</a>)</p>
  1786. <p>Constant folding has been moved from the peephole optimizer to the new AST
  1787. optimizer, which is able perform optimizations more consistently.
  1788. (Contributed by Eugene Toder and INADA Naoki in <a class="reference external" href="https://bugs.python.org/issue?&#64;action=redirect&amp;bpo=29469">bpo-29469</a> and
  1789. <a class="reference external" href="https://bugs.python.org/issue?&#64;action=redirect&amp;bpo=11549">bpo-11549</a>.)</p>
  1790. <p>Most functions and methods in <a class="reference internal" href="../library/abc.html#module-abc" title="abc: Abstract base classes according to :pep:`3119`."><code class="xref py py-mod docutils literal notranslate"><span class="pre">abc</span></code></a> have been rewritten in C.
  1791. This makes creation of abstract base classes, and calling <a class="reference internal" href="../library/functions.html#isinstance" title="isinstance"><code class="xref py py-func docutils literal notranslate"><span class="pre">isinstance()</span></code></a>
  1792. and <a class="reference internal" href="../library/functions.html#issubclass" title="issubclass"><code class="xref py py-func docutils literal notranslate"><span class="pre">issubclass()</span></code></a> on them 1.5x faster. This also reduces Python
  1793. start-up time by up to 10%. (Contributed by Ivan Levkivskyi and INADA Naoki
  1794. in <a class="reference external" href="https://bugs.python.org/issue?&#64;action=redirect&amp;bpo=31333">bpo-31333</a>)</p>
  1795. <p>Significant speed improvements to alternate constructors for
  1796. <a class="reference internal" href="../library/datetime.html#datetime.date" title="datetime.date"><code class="xref py py-class docutils literal notranslate"><span class="pre">datetime.date</span></code></a> and <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> by using fast-path
  1797. constructors when not constructing subclasses. (Contributed by Paul Ganssle
  1798. in <a class="reference external" href="https://bugs.python.org/issue?&#64;action=redirect&amp;bpo=32403">bpo-32403</a>)</p>
  1799. <p>The speed of comparison 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> instances has been
  1800. improved considerably in certain cases. It is now from 10x to 70x faster
  1801. when comparing arrays holding values of the same integer type.
  1802. (Contributed by Adrian Wielgosik in <a class="reference external" href="https://bugs.python.org/issue?&#64;action=redirect&amp;bpo=24700">bpo-24700</a>.)</p>
  1803. <p>The <a class="reference internal" href="../library/math.html#math.erf" title="math.erf"><code class="xref py py-func docutils literal notranslate"><span class="pre">math.erf()</span></code></a> and <a class="reference internal" href="../library/math.html#math.erfc" title="math.erfc"><code class="xref py py-func docutils literal notranslate"><span class="pre">math.erfc()</span></code></a> functions now use the (faster)
  1804. C library implementation on most platforms.
  1805. (Contributed by Serhiy Storchaka in <a class="reference external" href="https://bugs.python.org/issue?&#64;action=redirect&amp;bpo=26121">bpo-26121</a>.)</p>
  1806. </section>
  1807. <section id="other-cpython-implementation-changes">
  1808. <h2>Other CPython Implementation Changes<a class="headerlink" href="#other-cpython-implementation-changes" title="Link to this heading">¶</a></h2>
  1809. <ul class="simple">
  1810. <li><p>Trace hooks may now opt out of receiving the <code class="docutils literal notranslate"><span class="pre">line</span></code> and opt into receiving
  1811. the <code class="docutils literal notranslate"><span class="pre">opcode</span></code> events from the interpreter by setting the corresponding new
  1812. <a class="reference internal" href="../reference/datamodel.html#frame.f_trace_lines" title="frame.f_trace_lines"><code class="xref py py-attr docutils literal notranslate"><span class="pre">f_trace_lines</span></code></a> and <a class="reference internal" href="../reference/datamodel.html#frame.f_trace_opcodes" title="frame.f_trace_opcodes"><code class="xref py py-attr docutils literal notranslate"><span class="pre">f_trace_opcodes</span></code></a> attributes on the
  1813. frame being traced. (Contributed by Nick Coghlan in <a class="reference external" href="https://bugs.python.org/issue?&#64;action=redirect&amp;bpo=31344">bpo-31344</a>.)</p></li>
  1814. <li><p>Fixed some consistency problems with namespace package module attributes.
  1815. Namespace module objects now have an <code class="docutils literal notranslate"><span class="pre">__file__</span></code> that is set to <code class="docutils literal notranslate"><span class="pre">None</span></code>
  1816. (previously unset), and their <code class="docutils literal notranslate"><span class="pre">__spec__.origin</span></code> is also set to <code class="docutils literal notranslate"><span class="pre">None</span></code>
  1817. (previously the string <code class="docutils literal notranslate"><span class="pre">&quot;namespace&quot;</span></code>). See <a class="reference external" href="https://bugs.python.org/issue?&#64;action=redirect&amp;bpo=32305">bpo-32305</a>. Also, the
  1818. namespace module object’s <code class="docutils literal notranslate"><span class="pre">__spec__.loader</span></code> is set to the same value as
  1819. <code class="docutils literal notranslate"><span class="pre">__loader__</span></code> (previously, the former was set to <code class="docutils literal notranslate"><span class="pre">None</span></code>). See
  1820. <a class="reference external" href="https://bugs.python.org/issue?&#64;action=redirect&amp;bpo=32303">bpo-32303</a>.</p></li>
  1821. <li><p>The <a class="reference internal" href="../library/functions.html#locals" title="locals"><code class="xref py py-func docutils literal notranslate"><span class="pre">locals()</span></code></a> dictionary now displays in the lexical order that
  1822. variables were defined. Previously, the order was undefined.
  1823. (Contributed by Raymond Hettinger in <a class="reference external" href="https://bugs.python.org/issue?&#64;action=redirect&amp;bpo=32690">bpo-32690</a>.)</p></li>
  1824. <li><p>The <code class="docutils literal notranslate"><span class="pre">distutils</span></code> <code class="docutils literal notranslate"><span class="pre">upload</span></code> command no longer tries to change CR
  1825. end-of-line characters to CRLF. This fixes a corruption issue with sdists
  1826. that ended with a byte equivalent to CR.
  1827. (Contributed by Bo Bayles in <a class="reference external" href="https://bugs.python.org/issue?&#64;action=redirect&amp;bpo=32304">bpo-32304</a>.)</p></li>
  1828. </ul>
  1829. </section>
  1830. <section id="deprecated-python-behavior">
  1831. <h2>Deprecated Python Behavior<a class="headerlink" href="#deprecated-python-behavior" title="Link to this heading">¶</a></h2>
  1832. <p>Yield expressions (both <code class="docutils literal notranslate"><span class="pre">yield</span></code> and <code class="docutils literal notranslate"><span class="pre">yield</span> <span class="pre">from</span></code> clauses) are now deprecated
  1833. in comprehensions and generator expressions (aside from the iterable expression
  1834. in the leftmost <code class="xref std std-keyword docutils literal notranslate"><span class="pre">for</span></code> clause). This ensures that comprehensions
  1835. always immediately return a container of the appropriate type (rather than
  1836. potentially returning a <a class="reference internal" href="../glossary.html#term-generator-iterator"><span class="xref std std-term">generator iterator</span></a> object), while generator
  1837. expressions won’t attempt to interleave their implicit output with the output
  1838. from any explicit yield expressions. In Python 3.7, such expressions emit
  1839. <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> when compiled, in Python 3.8 this will be a
  1840. <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>.
  1841. (Contributed by Serhiy Storchaka in <a class="reference external" href="https://bugs.python.org/issue?&#64;action=redirect&amp;bpo=10544">bpo-10544</a>.)</p>
  1842. <p>Returning a subclass of <a class="reference internal" href="../library/functions.html#complex" title="complex"><code class="xref py py-class docutils literal notranslate"><span class="pre">complex</span></code></a> from <a class="reference internal" href="../reference/datamodel.html#object.__complex__" title="object.__complex__"><code class="xref py py-meth docutils literal notranslate"><span class="pre">object.__complex__()</span></code></a> is
  1843. deprecated and will be an error in future Python versions. This makes
  1844. <code class="docutils literal notranslate"><span class="pre">__complex__()</span></code> consistent with <a class="reference internal" href="../reference/datamodel.html#object.__int__" title="object.__int__"><code class="xref py py-meth docutils literal notranslate"><span class="pre">object.__int__()</span></code></a> and
  1845. <a class="reference internal" href="../reference/datamodel.html#object.__float__" title="object.__float__"><code class="xref py py-meth docutils literal notranslate"><span class="pre">object.__float__()</span></code></a>.
  1846. (Contributed by Serhiy Storchaka in <a class="reference external" href="https://bugs.python.org/issue?&#64;action=redirect&amp;bpo=28894">bpo-28894</a>.)</p>
  1847. </section>
  1848. <section id="deprecated-python-modules-functions-and-methods">
  1849. <h2>Deprecated Python modules, functions and methods<a class="headerlink" href="#deprecated-python-modules-functions-and-methods" title="Link to this heading">¶</a></h2>
  1850. <section id="aifc">
  1851. <h3>aifc<a class="headerlink" href="#aifc" title="Link to this heading">¶</a></h3>
  1852. <p><code class="xref py py-func docutils literal notranslate"><span class="pre">aifc.openfp()</span></code> has been deprecated and will be removed in Python 3.9.
  1853. Use <a class="reference internal" href="../library/aifc.html#aifc.open" title="aifc.open"><code class="xref py py-func docutils literal notranslate"><span class="pre">aifc.open()</span></code></a> instead.
  1854. (Contributed by Brian Curtin in <a class="reference external" href="https://bugs.python.org/issue?&#64;action=redirect&amp;bpo=31985">bpo-31985</a>.)</p>
  1855. </section>
  1856. <section id="whatsnew37-asyncio-deprecated">
  1857. <span id="id2"></span><h3>asyncio<a class="headerlink" href="#whatsnew37-asyncio-deprecated" title="Link to this heading">¶</a></h3>
  1858. <p>Support for directly <code class="docutils literal notranslate"><span class="pre">await</span></code>-ing instances of <a class="reference internal" href="../library/asyncio-sync.html#asyncio.Lock" title="asyncio.Lock"><code class="xref py py-class docutils literal notranslate"><span class="pre">asyncio.Lock</span></code></a> and
  1859. other asyncio synchronization primitives has been deprecated. An
  1860. asynchronous context manager must be used in order to acquire and release
  1861. the synchronization resource.
  1862. (Contributed by Andrew Svetlov in <a class="reference external" href="https://bugs.python.org/issue?&#64;action=redirect&amp;bpo=32253">bpo-32253</a>.)</p>
  1863. <p>The <code class="xref py py-meth docutils literal notranslate"><span class="pre">asyncio.Task.current_task()</span></code> and <code class="xref py py-meth docutils literal notranslate"><span class="pre">asyncio.Task.all_tasks()</span></code>
  1864. methods have been deprecated.
  1865. (Contributed by Andrew Svetlov in <a class="reference external" href="https://bugs.python.org/issue?&#64;action=redirect&amp;bpo=32250">bpo-32250</a>.)</p>
  1866. </section>
  1867. <section id="id3">
  1868. <h3>collections<a class="headerlink" href="#id3" title="Link to this heading">¶</a></h3>
  1869. <p>In Python 3.8, the abstract base classes in <a class="reference internal" href="../library/collections.abc.html#module-collections.abc" title="collections.abc: Abstract base classes for containers"><code class="xref py py-mod docutils literal notranslate"><span class="pre">collections.abc</span></code></a> will no
  1870. longer be exposed in the regular <a class="reference internal" href="../library/collections.html#module-collections" title="collections: Container datatypes"><code class="xref py py-mod docutils literal notranslate"><span class="pre">collections</span></code></a> module. This will help
  1871. create a clearer distinction between the concrete classes and the abstract
  1872. base classes.
  1873. (Contributed by Serhiy Storchaka in <a class="reference external" href="https://bugs.python.org/issue?&#64;action=redirect&amp;bpo=25988">bpo-25988</a>.)</p>
  1874. </section>
  1875. <section id="id4">
  1876. <h3>dbm<a class="headerlink" href="#id4" title="Link to this heading">¶</a></h3>
  1877. <p><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> now supports reading read-only files and no longer writes the
  1878. index file when it is not changed. A deprecation warning is now emitted
  1879. if the index file is missing and recreated in the <code class="docutils literal notranslate"><span class="pre">'r'</span></code> and <code class="docutils literal notranslate"><span class="pre">'w'</span></code>
  1880. modes (this will be an error in future Python releases).
  1881. (Contributed by Serhiy Storchaka in <a class="reference external" href="https://bugs.python.org/issue?&#64;action=redirect&amp;bpo=28847">bpo-28847</a>.)</p>
  1882. </section>
  1883. <section id="id5">
  1884. <h3>enum<a class="headerlink" href="#id5" title="Link to this heading">¶</a></h3>
  1885. <p>In Python 3.8, attempting to check for non-Enum objects in <code class="xref py py-class docutils literal notranslate"><span class="pre">Enum</span></code>
  1886. classes will raise a <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> (e.g. <code class="docutils literal notranslate"><span class="pre">1</span> <span class="pre">in</span> <span class="pre">Color</span></code>); similarly,
  1887. attempting to check for non-Flag objects in a <code class="xref py py-class docutils literal notranslate"><span class="pre">Flag</span></code> member will
  1888. 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> (e.g. <code class="docutils literal notranslate"><span class="pre">1</span> <span class="pre">in</span> <span class="pre">Perm.RW</span></code>); currently, both operations
  1889. return <a class="reference internal" href="../library/constants.html#False" title="False"><code class="xref py py-const docutils literal notranslate"><span class="pre">False</span></code></a> instead.
  1890. (Contributed by Ethan Furman in <a class="reference external" href="https://bugs.python.org/issue?&#64;action=redirect&amp;bpo=33217">bpo-33217</a>.)</p>
  1891. </section>
  1892. <section id="gettext">
  1893. <h3>gettext<a class="headerlink" href="#gettext" title="Link to this heading">¶</a></h3>
  1894. <p>Using non-integer value for selecting a plural form in <a class="reference internal" href="../library/gettext.html#module-gettext" title="gettext: Multilingual internationalization services."><code class="xref py py-mod docutils literal notranslate"><span class="pre">gettext</span></code></a> is
  1895. now deprecated. It never correctly worked. (Contributed by Serhiy Storchaka
  1896. in <a class="reference external" href="https://bugs.python.org/issue?&#64;action=redirect&amp;bpo=28692">bpo-28692</a>.)</p>
  1897. </section>
  1898. <section id="id6">
  1899. <h3>importlib<a class="headerlink" href="#id6" title="Link to this heading">¶</a></h3>
  1900. <p>Methods
  1901. <code class="xref py py-meth docutils literal notranslate"><span class="pre">MetaPathFinder.find_module()</span></code>
  1902. (replaced by
  1903. <a class="reference internal" href="../library/importlib.html#importlib.abc.MetaPathFinder.find_spec" title="importlib.abc.MetaPathFinder.find_spec"><code class="xref py py-meth docutils literal notranslate"><span class="pre">MetaPathFinder.find_spec()</span></code></a>)
  1904. and
  1905. <code class="xref py py-meth docutils literal notranslate"><span class="pre">PathEntryFinder.find_loader()</span></code>
  1906. (replaced by
  1907. <a class="reference internal" href="../library/importlib.html#importlib.abc.PathEntryFinder.find_spec" title="importlib.abc.PathEntryFinder.find_spec"><code class="xref py py-meth docutils literal notranslate"><span class="pre">PathEntryFinder.find_spec()</span></code></a>)
  1908. both deprecated in Python 3.4 now emit <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>.
  1909. (Contributed by Matthias Bussonnier in <a class="reference external" href="https://bugs.python.org/issue?&#64;action=redirect&amp;bpo=29576">bpo-29576</a>.)</p>
  1910. <p>The <a class="reference internal" href="../library/importlib.html#importlib.abc.ResourceLoader" title="importlib.abc.ResourceLoader"><code class="xref py py-class docutils literal notranslate"><span class="pre">importlib.abc.ResourceLoader</span></code></a> ABC has been deprecated in
  1911. favour of <a class="reference internal" href="../library/importlib.html#importlib.abc.ResourceReader" title="importlib.abc.ResourceReader"><code class="xref py py-class docutils literal notranslate"><span class="pre">importlib.abc.ResourceReader</span></code></a>.</p>
  1912. </section>
  1913. <section id="id7">
  1914. <h3>locale<a class="headerlink" href="#id7" title="Link to this heading">¶</a></h3>
  1915. <p><code class="xref py py-func docutils literal notranslate"><span class="pre">locale.format()</span></code> has been deprecated, use <a class="reference internal" href="../library/locale.html#locale.format_string" title="locale.format_string"><code class="xref py py-meth docutils literal notranslate"><span class="pre">locale.format_string()</span></code></a>
  1916. instead. (Contributed by Garvit in <a class="reference external" href="https://bugs.python.org/issue?&#64;action=redirect&amp;bpo=10379">bpo-10379</a>.)</p>
  1917. </section>
  1918. <section id="macpath">
  1919. <h3>macpath<a class="headerlink" href="#macpath" title="Link to this heading">¶</a></h3>
  1920. <p>The <code class="xref py py-mod docutils literal notranslate"><span class="pre">macpath</span></code> is now deprecated and will be removed in Python 3.8.
  1921. (Contributed by Chi Hsuan Yen in <a class="reference external" href="https://bugs.python.org/issue?&#64;action=redirect&amp;bpo=9850">bpo-9850</a>.)</p>
  1922. </section>
  1923. <section id="threading">
  1924. <h3>threading<a class="headerlink" href="#threading" title="Link to this heading">¶</a></h3>
  1925. <p><code class="xref py py-mod docutils literal notranslate"><span class="pre">dummy_threading</span></code> and <code class="xref py py-mod docutils literal notranslate"><span class="pre">_dummy_thread</span></code> have been deprecated. It is
  1926. no longer possible to build Python with threading disabled.
  1927. Use <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> instead.
  1928. (Contributed by Antoine Pitrou in <a class="reference external" href="https://bugs.python.org/issue?&#64;action=redirect&amp;bpo=31370">bpo-31370</a>.)</p>
  1929. </section>
  1930. <section id="id8">
  1931. <h3>socket<a class="headerlink" href="#id8" title="Link to this heading">¶</a></h3>
  1932. <p>The silent argument value truncation in <a class="reference internal" href="../library/socket.html#socket.htons" title="socket.htons"><code class="xref py py-func docutils literal notranslate"><span class="pre">socket.htons()</span></code></a> and
  1933. <a class="reference internal" href="../library/socket.html#socket.ntohs" title="socket.ntohs"><code class="xref py py-func docutils literal notranslate"><span class="pre">socket.ntohs()</span></code></a> has been deprecated. In future versions of Python,
  1934. if the passed argument is larger than 16 bits, an exception will be raised.
  1935. (Contributed by Oren Milman in <a class="reference external" href="https://bugs.python.org/issue?&#64;action=redirect&amp;bpo=28332">bpo-28332</a>.)</p>
  1936. </section>
  1937. <section id="id9">
  1938. <h3>ssl<a class="headerlink" href="#id9" title="Link to this heading">¶</a></h3>
  1939. <p><code class="xref py py-func docutils literal notranslate"><span class="pre">ssl.wrap_socket()</span></code> is deprecated. Use
  1940. <a class="reference internal" href="../library/ssl.html#ssl.SSLContext.wrap_socket" title="ssl.SSLContext.wrap_socket"><code class="xref py py-meth docutils literal notranslate"><span class="pre">ssl.SSLContext.wrap_socket()</span></code></a> instead.
  1941. (Contributed by Christian Heimes in <a class="reference external" href="https://bugs.python.org/issue?&#64;action=redirect&amp;bpo=28124">bpo-28124</a>.)</p>
  1942. </section>
  1943. <section id="sunau">
  1944. <h3>sunau<a class="headerlink" href="#sunau" title="Link to this heading">¶</a></h3>
  1945. <p><code class="xref py py-func docutils literal notranslate"><span class="pre">sunau.openfp()</span></code> has been deprecated and will be removed in Python 3.9.
  1946. Use <a class="reference internal" href="../library/sunau.html#sunau.open" title="sunau.open"><code class="xref py py-func docutils literal notranslate"><span class="pre">sunau.open()</span></code></a> instead.
  1947. (Contributed by Brian Curtin in <a class="reference external" href="https://bugs.python.org/issue?&#64;action=redirect&amp;bpo=31985">bpo-31985</a>.)</p>
  1948. </section>
  1949. <section id="id10">
  1950. <h3>sys<a class="headerlink" href="#id10" title="Link to this heading">¶</a></h3>
  1951. <p>Deprecated <code class="xref py py-func docutils literal notranslate"><span class="pre">sys.set_coroutine_wrapper()</span></code> and
  1952. <code class="xref py py-func docutils literal notranslate"><span class="pre">sys.get_coroutine_wrapper()</span></code>.</p>
  1953. <p>The undocumented <code class="docutils literal notranslate"><span class="pre">sys.callstats()</span></code> function has been deprecated and
  1954. will be removed in a future Python version.
  1955. (Contributed by Victor Stinner in <a class="reference external" href="https://bugs.python.org/issue?&#64;action=redirect&amp;bpo=28799">bpo-28799</a>.)</p>
  1956. </section>
  1957. <section id="wave">
  1958. <h3>wave<a class="headerlink" href="#wave" title="Link to this heading">¶</a></h3>
  1959. <p><code class="xref py py-func docutils literal notranslate"><span class="pre">wave.openfp()</span></code> has been deprecated and will be removed in Python 3.9.
  1960. Use <a class="reference internal" href="../library/wave.html#wave.open" title="wave.open"><code class="xref py py-func docutils literal notranslate"><span class="pre">wave.open()</span></code></a> instead.
  1961. (Contributed by Brian Curtin in <a class="reference external" href="https://bugs.python.org/issue?&#64;action=redirect&amp;bpo=31985">bpo-31985</a>.)</p>
  1962. </section>
  1963. </section>
  1964. <section id="deprecated-functions-and-types-of-the-c-api">
  1965. <h2>Deprecated functions and types of the C API<a class="headerlink" href="#deprecated-functions-and-types-of-the-c-api" title="Link to this heading">¶</a></h2>
  1966. <p>Function <a class="reference internal" href="../c-api/slice.html#c.PySlice_GetIndicesEx" title="PySlice_GetIndicesEx"><code class="xref c c-func docutils literal notranslate"><span class="pre">PySlice_GetIndicesEx()</span></code></a> is deprecated and replaced with
  1967. a macro if <code class="docutils literal notranslate"><span class="pre">Py_LIMITED_API</span></code> is not set or set to a value in the range
  1968. between <code class="docutils literal notranslate"><span class="pre">0x03050400</span></code> and <code class="docutils literal notranslate"><span class="pre">0x03060000</span></code> (not inclusive), or is <code class="docutils literal notranslate"><span class="pre">0x03060100</span></code>
  1969. or higher. (Contributed by Serhiy Storchaka in <a class="reference external" href="https://bugs.python.org/issue?&#64;action=redirect&amp;bpo=27867">bpo-27867</a>.)</p>
  1970. <p><a class="reference internal" href="../c-api/sys.html#c.PyOS_AfterFork" title="PyOS_AfterFork"><code class="xref c c-func docutils literal notranslate"><span class="pre">PyOS_AfterFork()</span></code></a> has been deprecated. Use <a class="reference internal" href="../c-api/sys.html#c.PyOS_BeforeFork" title="PyOS_BeforeFork"><code class="xref c c-func docutils literal notranslate"><span class="pre">PyOS_BeforeFork()</span></code></a>,
  1971. <a class="reference internal" href="../c-api/sys.html#c.PyOS_AfterFork_Parent" title="PyOS_AfterFork_Parent"><code class="xref c c-func docutils literal notranslate"><span class="pre">PyOS_AfterFork_Parent()</span></code></a> or <a class="reference internal" href="../c-api/sys.html#c.PyOS_AfterFork_Child" title="PyOS_AfterFork_Child"><code class="xref c c-func docutils literal notranslate"><span class="pre">PyOS_AfterFork_Child()</span></code></a> instead.
  1972. (Contributed by Antoine Pitrou in <a class="reference external" href="https://bugs.python.org/issue?&#64;action=redirect&amp;bpo=16500">bpo-16500</a>.)</p>
  1973. </section>
  1974. <section id="platform-support-removals">
  1975. <span id="id11"></span><h2>Platform Support Removals<a class="headerlink" href="#platform-support-removals" title="Link to this heading">¶</a></h2>
  1976. <ul>
  1977. <li><p>FreeBSD 9 and older are no longer officially supported.</p></li>
  1978. <li><p>For full Unicode support, including within extension modules, *nix platforms
  1979. are now expected to provide at least one of <code class="docutils literal notranslate"><span class="pre">C.UTF-8</span></code> (full locale),
  1980. <code class="docutils literal notranslate"><span class="pre">C.utf8</span></code> (full locale) or <code class="docutils literal notranslate"><span class="pre">UTF-8</span></code> (<code class="docutils literal notranslate"><span class="pre">LC_CTYPE</span></code>-only locale) as an
  1981. alternative to the legacy <code class="docutils literal notranslate"><span class="pre">ASCII</span></code>-based <code class="docutils literal notranslate"><span class="pre">C</span></code> locale.</p></li>
  1982. <li><p>OpenSSL 0.9.8 and 1.0.1 are no longer supported, which means building CPython
  1983. 3.7 with SSL/TLS support on older platforms still using these versions
  1984. requires custom build options that link to a more recent version of OpenSSL.</p>
  1985. <p>Notably, this issue affects the Debian 8 (aka “jessie”) and Ubuntu 14.04
  1986. (aka “Trusty”) LTS Linux distributions, as they still use OpenSSL 1.0.1 by
  1987. default.</p>
  1988. <p>Debian 9 (“stretch”) and Ubuntu 16.04 (“xenial”), as well as recent releases
  1989. of other LTS Linux releases (e.g. RHEL/CentOS 7.5, SLES 12-SP3), use OpenSSL
  1990. 1.0.2 or later, and remain supported in the default build configuration.</p>
  1991. <p>CPython’s own <a class="reference external" href="https://github.com/python/cpython/blob/v3.7.13/.travis.yml">CI configuration file</a> provides an
  1992. example of using the SSL
  1993. <a class="reference external" href="https://github.com/python/cpython/tree/3.12/Tools/ssl/multissltests.py">compatibility testing infrastructure</a> in
  1994. CPython’s test suite to build and link against OpenSSL 1.1.0 rather than an
  1995. outdated system provided OpenSSL.</p>
  1996. </li>
  1997. </ul>
  1998. </section>
  1999. <section id="api-and-feature-removals">
  2000. <h2>API and Feature Removals<a class="headerlink" href="#api-and-feature-removals" title="Link to this heading">¶</a></h2>
  2001. <p>The following features and APIs have been removed from Python 3.7:</p>
  2002. <ul class="simple">
  2003. <li><p>The <code class="docutils literal notranslate"><span class="pre">os.stat_float_times()</span></code> function has been removed. It was introduced in
  2004. Python 2.3 for backward compatibility with Python 2.2, and was deprecated
  2005. since Python 3.1.</p></li>
  2006. <li><p>Unknown escapes consisting of <code class="docutils literal notranslate"><span class="pre">'\'</span></code> and an ASCII letter in replacement
  2007. 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> were deprecated in Python 3.5, and will now
  2008. cause an error.</p></li>
  2009. <li><p>Removed support of the <em>exclude</em> argument in <a class="reference internal" href="../library/tarfile.html#tarfile.TarFile.add" title="tarfile.TarFile.add"><code class="xref py py-meth docutils literal notranslate"><span class="pre">tarfile.TarFile.add()</span></code></a>.
  2010. It was deprecated in Python 2.7 and 3.2. Use the <em>filter</em> argument instead.</p></li>
  2011. <li><p>The <code class="xref py py-func docutils literal notranslate"><span class="pre">ntpath.splitunc()</span></code> function was deprecated in
  2012. Python 3.1, and has now been removed. Use <a class="reference internal" href="../library/os.path.html#os.path.splitdrive" title="os.path.splitdrive"><code class="xref py py-func docutils literal notranslate"><span class="pre">splitdrive()</span></code></a>
  2013. instead.</p></li>
  2014. <li><p><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">collections.namedtuple()</span></code></a> no longer supports the <em>verbose</em> parameter
  2015. or <code class="docutils literal notranslate"><span class="pre">_source</span></code> attribute which showed the generated source code for the
  2016. named tuple class. This was part of an optimization designed to speed-up
  2017. class creation. (Contributed by Jelle Zijlstra with further improvements
  2018. by INADA Naoki, Serhiy Storchaka, and Raymond Hettinger in <a class="reference external" href="https://bugs.python.org/issue?&#64;action=redirect&amp;bpo=28638">bpo-28638</a>.)</p></li>
  2019. <li><p>Functions <a class="reference internal" href="../library/functions.html#bool" title="bool"><code class="xref py py-func docutils literal notranslate"><span class="pre">bool()</span></code></a>, <a class="reference internal" href="../library/functions.html#float" title="float"><code class="xref py py-func docutils literal notranslate"><span class="pre">float()</span></code></a>, <a class="reference internal" href="../library/stdtypes.html#list" title="list"><code class="xref py py-func docutils literal notranslate"><span class="pre">list()</span></code></a> and <a class="reference internal" href="../library/stdtypes.html#tuple" title="tuple"><code class="xref py py-func docutils literal notranslate"><span class="pre">tuple()</span></code></a> no
  2020. longer take keyword arguments. The first argument of <a class="reference internal" href="../library/functions.html#int" title="int"><code class="xref py py-func docutils literal notranslate"><span class="pre">int()</span></code></a> can now
  2021. be passed only as positional argument.</p></li>
  2022. <li><p>Removed previously deprecated in Python 2.4 classes <code class="docutils literal notranslate"><span class="pre">Plist</span></code>, <code class="docutils literal notranslate"><span class="pre">Dict</span></code> and
  2023. <code class="docutils literal notranslate"><span class="pre">_InternalDict</span></code> in the <a class="reference internal" href="../library/plistlib.html#module-plistlib" title="plistlib: Generate and parse Apple plist files."><code class="xref py py-mod docutils literal notranslate"><span class="pre">plistlib</span></code></a> module. Dict values in the result
  2024. of functions <code class="xref py py-func docutils literal notranslate"><span class="pre">readPlist()</span></code> and
  2025. <code class="xref py py-func docutils literal notranslate"><span class="pre">readPlistFromBytes()</span></code> are now normal dicts. You no longer
  2026. can use attribute access to access items of these dictionaries.</p></li>
  2027. <li><p>The <code class="docutils literal notranslate"><span class="pre">asyncio.windows_utils.socketpair()</span></code> function has been
  2028. removed. Use the <a class="reference internal" href="../library/socket.html#socket.socketpair" title="socket.socketpair"><code class="xref py py-func docutils literal notranslate"><span class="pre">socket.socketpair()</span></code></a> function instead,
  2029. it is available on all platforms since Python 3.5.
  2030. <code class="docutils literal notranslate"><span class="pre">asyncio.windows_utils.socketpair</span></code> was just an alias to
  2031. <code class="docutils literal notranslate"><span class="pre">socket.socketpair</span></code> on Python 3.5 and newer.</p></li>
  2032. <li><p><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> no longer exports the <a class="reference internal" href="../library/selectors.html#module-selectors" title="selectors: High-level I/O multiplexing."><code class="xref py py-mod docutils literal notranslate"><span class="pre">selectors</span></code></a> and
  2033. <code class="xref py py-mod docutils literal notranslate"><span class="pre">_overlapped</span></code> modules as <code class="docutils literal notranslate"><span class="pre">asyncio.selectors</span></code> and
  2034. <code class="docutils literal notranslate"><span class="pre">asyncio._overlapped</span></code>. Replace <code class="docutils literal notranslate"><span class="pre">from</span> <span class="pre">asyncio</span> <span class="pre">import</span> <span class="pre">selectors</span></code> with
  2035. <code class="docutils literal notranslate"><span class="pre">import</span> <span class="pre">selectors</span></code>.</p></li>
  2036. <li><p>Direct instantiation of <a class="reference internal" href="../library/ssl.html#ssl.SSLSocket" title="ssl.SSLSocket"><code class="xref py py-class docutils literal notranslate"><span class="pre">ssl.SSLSocket</span></code></a> and <a class="reference internal" href="../library/ssl.html#ssl.SSLObject" title="ssl.SSLObject"><code class="xref py py-class docutils literal notranslate"><span class="pre">ssl.SSLObject</span></code></a>
  2037. objects is now prohibited. The constructors were never documented, tested,
  2038. or designed as public constructors. Users were supposed to use
  2039. <code class="xref py py-func docutils literal notranslate"><span class="pre">ssl.wrap_socket()</span></code> or <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">ssl.SSLContext</span></code></a>.
  2040. (Contributed by Christian Heimes in <a class="reference external" href="https://bugs.python.org/issue?&#64;action=redirect&amp;bpo=32951">bpo-32951</a>.)</p></li>
  2041. <li><p>The unused <code class="docutils literal notranslate"><span class="pre">distutils</span></code> <code class="docutils literal notranslate"><span class="pre">install_misc</span></code> command has been removed.
  2042. (Contributed by Eric N. Vander Weele in <a class="reference external" href="https://bugs.python.org/issue?&#64;action=redirect&amp;bpo=29218">bpo-29218</a>.)</p></li>
  2043. </ul>
  2044. </section>
  2045. <section id="module-removals">
  2046. <h2>Module Removals<a class="headerlink" href="#module-removals" title="Link to this heading">¶</a></h2>
  2047. <p>The <code class="docutils literal notranslate"><span class="pre">fpectl</span></code> module has been removed. It was never enabled by
  2048. default, never worked correctly on x86-64, and it changed the Python
  2049. ABI in ways that caused unexpected breakage of C extensions.
  2050. (Contributed by Nathaniel J. Smith in <a class="reference external" href="https://bugs.python.org/issue?&#64;action=redirect&amp;bpo=29137">bpo-29137</a>.)</p>
  2051. </section>
  2052. <section id="windows-only-changes">
  2053. <h2>Windows-only Changes<a class="headerlink" href="#windows-only-changes" title="Link to this heading">¶</a></h2>
  2054. <p>The python launcher, (py.exe), can accept 32 &amp; 64 bit specifiers <strong>without</strong>
  2055. having to specify a minor version as well. So <code class="docutils literal notranslate"><span class="pre">py</span> <span class="pre">-3-32</span></code> and <code class="docutils literal notranslate"><span class="pre">py</span> <span class="pre">-3-64</span></code>
  2056. become valid as well as <code class="docutils literal notranslate"><span class="pre">py</span> <span class="pre">-3.7-32</span></code>, also the -<em>m</em>-64 and -<em>m.n</em>-64 forms
  2057. are now accepted to force 64 bit python even if 32 bit would have otherwise
  2058. been used. If the specified version is not available py.exe will error exit.
  2059. (Contributed by Steve Barnes in <a class="reference external" href="https://bugs.python.org/issue?&#64;action=redirect&amp;bpo=30291">bpo-30291</a>.)</p>
  2060. <p>The launcher can be run as <code class="docutils literal notranslate"><span class="pre">py</span> <span class="pre">-0</span></code> to produce a list of the installed pythons,
  2061. <em>with default marked with an asterisk</em>. Running <code class="docutils literal notranslate"><span class="pre">py</span> <span class="pre">-0p</span></code> will include the paths.
  2062. If py is run with a version specifier that cannot be matched it will also print
  2063. the <em>short form</em> list of available specifiers.
  2064. (Contributed by Steve Barnes in <a class="reference external" href="https://bugs.python.org/issue?&#64;action=redirect&amp;bpo=30362">bpo-30362</a>.)</p>
  2065. </section>
  2066. <section id="porting-to-python-3-7">
  2067. <span id="porting-to-python-37"></span><h2>Porting to Python 3.7<a class="headerlink" href="#porting-to-python-3-7" title="Link to this heading">¶</a></h2>
  2068. <p>This section lists previously described changes and other bugfixes
  2069. that may require changes to your code.</p>
  2070. <section id="changes-in-python-behavior">
  2071. <h3>Changes in Python Behavior<a class="headerlink" href="#changes-in-python-behavior" title="Link to this heading">¶</a></h3>
  2072. <ul>
  2073. <li><p><a class="reference internal" href="../reference/compound_stmts.html#async"><code class="xref std std-keyword docutils literal notranslate"><span class="pre">async</span></code></a> and <a class="reference internal" href="../reference/expressions.html#await"><code class="xref std std-keyword docutils literal notranslate"><span class="pre">await</span></code></a> names are now reserved keywords.
  2074. Code using these names as identifiers will now raise 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>.
  2075. (Contributed by Jelle Zijlstra in <a class="reference external" href="https://bugs.python.org/issue?&#64;action=redirect&amp;bpo=30406">bpo-30406</a>.)</p></li>
  2076. <li><p><span class="target" id="index-37"></span><a class="pep reference external" href="https://peps.python.org/pep-0479/"><strong>PEP 479</strong></a> is enabled for all code in Python 3.7, meaning that
  2077. <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> exceptions raised directly or indirectly in
  2078. coroutines and generators are transformed into <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>
  2079. exceptions.
  2080. (Contributed by Yury Selivanov in <a class="reference external" href="https://bugs.python.org/issue?&#64;action=redirect&amp;bpo=32670">bpo-32670</a>.)</p></li>
  2081. <li><p><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">object.__aiter__()</span></code></a> methods can no longer be declared as
  2082. asynchronous. (Contributed by Yury Selivanov in <a class="reference external" href="https://bugs.python.org/issue?&#64;action=redirect&amp;bpo=31709">bpo-31709</a>.)</p></li>
  2083. <li><p>Due to an oversight, earlier Python versions erroneously accepted the
  2084. following syntax:</p>
  2085. <div class="highlight-python3 notranslate"><div class="highlight"><pre><span></span><span class="n">f</span><span class="p">(</span><span class="mi">1</span> <span class="k">for</span> <span class="n">x</span> <span class="ow">in</span> <span class="p">[</span><span class="mi">1</span><span class="p">],)</span>
  2086. <span class="k">class</span> <span class="nc">C</span><span class="p">(</span><span class="mi">1</span> <span class="k">for</span> <span class="n">x</span> <span class="ow">in</span> <span class="p">[</span><span class="mi">1</span><span class="p">]):</span>
  2087. <span class="k">pass</span>
  2088. </pre></div>
  2089. </div>
  2090. <p>Python 3.7 now correctly raises 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>, as a generator
  2091. expression always needs to be directly inside a set of parentheses
  2092. and cannot have a comma on either side, and the duplication of the
  2093. parentheses can be omitted only on calls.
  2094. (Contributed by Serhiy Storchaka in <a class="reference external" href="https://bugs.python.org/issue?&#64;action=redirect&amp;bpo=32012">bpo-32012</a> and <a class="reference external" href="https://bugs.python.org/issue?&#64;action=redirect&amp;bpo=32023">bpo-32023</a>.)</p>
  2095. </li>
  2096. <li><p>When using the <a class="reference internal" href="../using/cmdline.html#cmdoption-m"><code class="xref std std-option docutils literal notranslate"><span class="pre">-m</span></code></a> switch, the initial working directory is now added
  2097. to <a class="reference internal" href="../library/sys.html#sys.path" title="sys.path"><code class="xref py py-data docutils literal notranslate"><span class="pre">sys.path</span></code></a>, rather than an empty string (which dynamically denoted
  2098. the current working directory at the time of each import). Any programs that
  2099. are checking for the empty string, or otherwise relying on the previous
  2100. behaviour, will need to be updated accordingly (e.g. by also checking for
  2101. <code class="docutils literal notranslate"><span class="pre">os.getcwd()</span></code> or <code class="docutils literal notranslate"><span class="pre">os.path.dirname(__main__.__file__)</span></code>, depending on why
  2102. the code was checking for the empty string in the first place).</p></li>
  2103. </ul>
  2104. </section>
  2105. <section id="changes-in-the-python-api">
  2106. <h3>Changes in the Python API<a class="headerlink" href="#changes-in-the-python-api" title="Link to this heading">¶</a></h3>
  2107. <ul>
  2108. <li><p><code class="xref py py-meth docutils literal notranslate"><span class="pre">socketserver.ThreadingMixIn.server_close()</span></code> now waits until all
  2109. non-daemon threads complete. Set the new
  2110. <a class="reference internal" href="../library/socketserver.html#socketserver.ThreadingMixIn.block_on_close" title="socketserver.ThreadingMixIn.block_on_close"><code class="xref py py-attr docutils literal notranslate"><span class="pre">socketserver.ThreadingMixIn.block_on_close</span></code></a> class attribute to
  2111. <code class="docutils literal notranslate"><span class="pre">False</span></code> to get the pre-3.7 behaviour.
  2112. (Contributed by Victor Stinner in <a class="reference external" href="https://bugs.python.org/issue?&#64;action=redirect&amp;bpo=31233">bpo-31233</a> and <a class="reference external" href="https://bugs.python.org/issue?&#64;action=redirect&amp;bpo=33540">bpo-33540</a>.)</p></li>
  2113. <li><p><code class="xref py py-meth docutils literal notranslate"><span class="pre">socketserver.ForkingMixIn.server_close()</span></code> now waits until all
  2114. child processes complete. Set the new
  2115. <code class="xref py py-attr docutils literal notranslate"><span class="pre">socketserver.ForkingMixIn.block_on_close</span></code> class attribute to <code class="docutils literal notranslate"><span class="pre">False</span></code>
  2116. to get the pre-3.7 behaviour.
  2117. (Contributed by Victor Stinner in <a class="reference external" href="https://bugs.python.org/issue?&#64;action=redirect&amp;bpo=31151">bpo-31151</a> and <a class="reference external" href="https://bugs.python.org/issue?&#64;action=redirect&amp;bpo=33540">bpo-33540</a>.)</p></li>
  2118. <li><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 temporarily sets the <code class="docutils literal notranslate"><span class="pre">LC_CTYPE</span></code>
  2119. locale to the value of <code class="docutils literal notranslate"><span class="pre">LC_NUMERIC</span></code> in some cases.
  2120. (Contributed by Victor Stinner in <a class="reference external" href="https://bugs.python.org/issue?&#64;action=redirect&amp;bpo=31900">bpo-31900</a>.)</p></li>
  2121. <li><p><a class="reference internal" href="../library/pkgutil.html#pkgutil.walk_packages" title="pkgutil.walk_packages"><code class="xref py py-meth docutils literal notranslate"><span class="pre">pkgutil.walk_packages()</span></code></a> now raises 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> if <em>path</em> is
  2122. a string. Previously an empty list was returned.
  2123. (Contributed by Sanyam Khurana in <a class="reference external" href="https://bugs.python.org/issue?&#64;action=redirect&amp;bpo=24744">bpo-24744</a>.)</p></li>
  2124. <li><p>A format string argument for <a class="reference internal" href="../library/string.html#string.Formatter.format" title="string.Formatter.format"><code class="xref py py-meth docutils literal notranslate"><span class="pre">string.Formatter.format()</span></code></a>
  2125. is now <a class="reference internal" href="../glossary.html#positional-only-parameter"><span class="std std-ref">positional-only</span></a>.
  2126. Passing it as a keyword argument was deprecated in Python 3.5. (Contributed
  2127. by Serhiy Storchaka in <a class="reference external" href="https://bugs.python.org/issue?&#64;action=redirect&amp;bpo=29193">bpo-29193</a>.)</p></li>
  2128. <li><p>Attributes <a class="reference internal" href="../library/http.cookies.html#http.cookies.Morsel.key" title="http.cookies.Morsel.key"><code class="xref py py-attr docutils literal notranslate"><span class="pre">key</span></code></a>,
  2129. <a class="reference internal" href="../library/http.cookies.html#http.cookies.Morsel.value" title="http.cookies.Morsel.value"><code class="xref py py-attr docutils literal notranslate"><span class="pre">value</span></code></a> and
  2130. <a class="reference internal" href="../library/http.cookies.html#http.cookies.Morsel.coded_value" title="http.cookies.Morsel.coded_value"><code class="xref py py-attr docutils literal notranslate"><span class="pre">coded_value</span></code></a> of class
  2131. <a class="reference internal" href="../library/http.cookies.html#http.cookies.Morsel" title="http.cookies.Morsel"><code class="xref py py-class docutils literal notranslate"><span class="pre">http.cookies.Morsel</span></code></a> are now read-only.
  2132. Assigning to them was deprecated in Python 3.5.
  2133. Use the <a class="reference internal" href="../library/http.cookies.html#http.cookies.Morsel.set" title="http.cookies.Morsel.set"><code class="xref py py-meth docutils literal notranslate"><span class="pre">set()</span></code></a> method for setting them.
  2134. (Contributed by Serhiy Storchaka in <a class="reference external" href="https://bugs.python.org/issue?&#64;action=redirect&amp;bpo=29192">bpo-29192</a>.)</p></li>
  2135. <li><p>The <em>mode</em> argument of <a class="reference internal" href="../library/os.html#os.makedirs" title="os.makedirs"><code class="xref py py-func docutils literal notranslate"><span class="pre">os.makedirs()</span></code></a> no longer affects the file
  2136. permission bits of newly created intermediate-level directories.
  2137. To set their file permission bits you can set the umask before invoking
  2138. <code class="docutils literal notranslate"><span class="pre">makedirs()</span></code>.
  2139. (Contributed by Serhiy Storchaka in <a class="reference external" href="https://bugs.python.org/issue?&#64;action=redirect&amp;bpo=19930">bpo-19930</a>.)</p></li>
  2140. <li><p>The <a class="reference internal" href="../library/struct.html#struct.Struct.format" title="struct.Struct.format"><code class="xref py py-attr docutils literal notranslate"><span class="pre">struct.Struct.format</span></code></a> type is now <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> instead of
  2141. <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>. (Contributed by Victor Stinner in <a class="reference external" href="https://bugs.python.org/issue?&#64;action=redirect&amp;bpo=21071">bpo-21071</a>.)</p></li>
  2142. <li><p><a class="reference internal" href="../library/cgi.html#cgi.parse_multipart" title="cgi.parse_multipart"><code class="xref py py-func docutils literal notranslate"><span class="pre">parse_multipart()</span></code></a> now accepts the <em>encoding</em> and <em>errors</em>
  2143. arguments and returns the same results as
  2144. <code class="xref py py-class docutils literal notranslate"><span class="pre">FieldStorage</span></code>: for non-file fields, the value associated to a key
  2145. is a list of strings, not bytes.
  2146. (Contributed by Pierre Quentel in <a class="reference external" href="https://bugs.python.org/issue?&#64;action=redirect&amp;bpo=29979">bpo-29979</a>.)</p></li>
  2147. <li><p>Due to internal changes in <a class="reference internal" href="../library/socket.html#module-socket" title="socket: Low-level networking interface."><code class="xref py py-mod docutils literal notranslate"><span class="pre">socket</span></code></a>, calling <a class="reference internal" href="../library/socket.html#socket.fromshare" title="socket.fromshare"><code class="xref py py-func docutils literal notranslate"><span class="pre">socket.fromshare()</span></code></a>
  2148. on a socket created by <a class="reference internal" href="../library/socket.html#socket.socket.share" title="socket.socket.share"><code class="xref py py-func docutils literal notranslate"><span class="pre">socket.share</span></code></a> in older
  2149. Python versions is not supported.</p></li>
  2150. <li><p><code class="docutils literal notranslate"><span class="pre">repr</span></code> for <a class="reference internal" href="../library/exceptions.html#BaseException" title="BaseException"><code class="xref py py-exc docutils literal notranslate"><span class="pre">BaseException</span></code></a> has changed to not include the trailing
  2151. comma. Most exceptions are affected by this change.
  2152. (Contributed by Serhiy Storchaka in <a class="reference external" href="https://bugs.python.org/issue?&#64;action=redirect&amp;bpo=30399">bpo-30399</a>.)</p></li>
  2153. <li><p><code class="docutils literal notranslate"><span class="pre">repr</span></code> for <a class="reference internal" href="../library/datetime.html#datetime.timedelta" title="datetime.timedelta"><code class="xref py py-class docutils literal notranslate"><span class="pre">datetime.timedelta</span></code></a> has changed to include the keyword
  2154. arguments in the output. (Contributed by Utkarsh Upadhyay in <a class="reference external" href="https://bugs.python.org/issue?&#64;action=redirect&amp;bpo=30302">bpo-30302</a>.)</p></li>
  2155. <li><p>Because <a class="reference internal" href="../library/shutil.html#shutil.rmtree" title="shutil.rmtree"><code class="xref py py-func docutils literal notranslate"><span class="pre">shutil.rmtree()</span></code></a> is now implemented using 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">os.scandir()</span></code></a>
  2156. function, the user specified handler <em>onerror</em> is now called with the first
  2157. argument <code class="docutils literal notranslate"><span class="pre">os.scandir</span></code> instead of <code class="docutils literal notranslate"><span class="pre">os.listdir</span></code> when listing the directory
  2158. is failed.</p></li>
  2159. <li><p>Support for nested sets and set operations in regular expressions as in
  2160. <a class="reference external" href="https://unicode.org/reports/tr18/">Unicode Technical Standard #18</a> might be added in the future. This would
  2161. change the syntax. To facilitate this future change a <a class="reference internal" href="../library/exceptions.html#FutureWarning" title="FutureWarning"><code class="xref py py-exc docutils literal notranslate"><span class="pre">FutureWarning</span></code></a>
  2162. will be raised in ambiguous cases for the time being.
  2163. That include sets starting with a literal <code class="docutils literal notranslate"><span class="pre">'['</span></code> or containing literal
  2164. character sequences <code class="docutils literal notranslate"><span class="pre">'--'</span></code>, <code class="docutils literal notranslate"><span class="pre">'&amp;&amp;'</span></code>, <code class="docutils literal notranslate"><span class="pre">'~~'</span></code>, and <code class="docutils literal notranslate"><span class="pre">'||'</span></code>. To
  2165. avoid a warning, escape them with a backslash.
  2166. (Contributed by Serhiy Storchaka in <a class="reference external" href="https://bugs.python.org/issue?&#64;action=redirect&amp;bpo=30349">bpo-30349</a>.)</p>
  2167. </li>
  2168. <li><p>The result of splitting a string on a <a class="reference internal" href="../library/re.html#module-re" title="re: Regular expression operations."><code class="xref py py-mod docutils literal notranslate"><span class="pre">regular</span> <span class="pre">expression</span></code></a>
  2169. that could match an empty string has been changed. For example
  2170. splitting on <code class="docutils literal notranslate"><span class="pre">r'\s*'</span></code> will now split not only on whitespaces as it
  2171. did previously, but also on empty strings before all non-whitespace
  2172. characters and just before the end of the string.
  2173. The previous behavior can be restored by changing the pattern
  2174. to <code class="docutils literal notranslate"><span class="pre">r'\s+'</span></code>. A <a class="reference internal" href="../library/exceptions.html#FutureWarning" title="FutureWarning"><code class="xref py py-exc docutils literal notranslate"><span class="pre">FutureWarning</span></code></a> was emitted for such patterns since
  2175. Python 3.5.</p>
  2176. <p>For patterns that match both empty and non-empty strings, the result of
  2177. searching for all matches may also be changed in other cases. For example
  2178. in the string <code class="docutils literal notranslate"><span class="pre">'a\n\n'</span></code>, the pattern <code class="docutils literal notranslate"><span class="pre">r'(?m)^\s*?$'</span></code> will not only
  2179. match empty strings at positions 2 and 3, but also the string <code class="docutils literal notranslate"><span class="pre">'\n'</span></code> at
  2180. positions 2–3. To match only blank lines, the pattern should be rewritten
  2181. as <code class="docutils literal notranslate"><span class="pre">r'(?m)^[^\S\n]*$'</span></code>.</p>
  2182. <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 replaces empty matches adjacent to a previous
  2183. non-empty match. For example <code class="docutils literal notranslate"><span class="pre">re.sub('x*',</span> <span class="pre">'-',</span> <span class="pre">'abxd')</span></code> returns now
  2184. <code class="docutils literal notranslate"><span class="pre">'-a-b--d-'</span></code> instead of <code class="docutils literal notranslate"><span class="pre">'-a-b-d-'</span></code> (the first minus between ‘b’ and
  2185. ‘d’ replaces ‘x’, and the second minus replaces an empty string between
  2186. ‘x’ and ‘d’).</p>
  2187. <p>(Contributed by Serhiy Storchaka in <a class="reference external" href="https://bugs.python.org/issue?&#64;action=redirect&amp;bpo=25054">bpo-25054</a> and <a class="reference external" href="https://bugs.python.org/issue?&#64;action=redirect&amp;bpo=32308">bpo-32308</a>.)</p>
  2188. </li>
  2189. <li><p>Change <a class="reference internal" href="../library/re.html#re.escape" title="re.escape"><code class="xref py py-func docutils literal notranslate"><span class="pre">re.escape()</span></code></a> to only escape regex special characters instead
  2190. of escaping all characters other than ASCII letters, numbers, and <code class="docutils literal notranslate"><span class="pre">'_'</span></code>.
  2191. (Contributed by Serhiy Storchaka in <a class="reference external" href="https://bugs.python.org/issue?&#64;action=redirect&amp;bpo=29995">bpo-29995</a>.)</p></li>
  2192. <li><p><a class="reference internal" href="../library/tracemalloc.html#tracemalloc.Traceback" title="tracemalloc.Traceback"><code class="xref py py-class docutils literal notranslate"><span class="pre">tracemalloc.Traceback</span></code></a> frames are now sorted from oldest to most
  2193. recent to be more consistent with <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>.
  2194. (Contributed by Jesse Bakker in <a class="reference external" href="https://bugs.python.org/issue?&#64;action=redirect&amp;bpo=32121">bpo-32121</a>.)</p></li>
  2195. <li><p>On OSes that support <a class="reference internal" href="../library/socket.html#socket.SOCK_NONBLOCK" title="socket.SOCK_NONBLOCK"><code class="xref py py-const docutils literal notranslate"><span class="pre">socket.SOCK_NONBLOCK</span></code></a> or
  2196. <a class="reference internal" href="../library/socket.html#socket.SOCK_CLOEXEC" title="socket.SOCK_CLOEXEC"><code class="xref py py-const docutils literal notranslate"><span class="pre">socket.SOCK_CLOEXEC</span></code></a> bit flags, the
  2197. <a class="reference internal" href="../library/socket.html#socket.socket.type" title="socket.socket.type"><code class="xref py py-attr docutils literal notranslate"><span class="pre">socket.type</span></code></a> no longer has them applied.
  2198. Therefore, checks like <code class="docutils literal notranslate"><span class="pre">if</span> <span class="pre">sock.type</span> <span class="pre">==</span> <span class="pre">socket.SOCK_STREAM</span></code>
  2199. work as expected on all platforms.
  2200. (Contributed by Yury Selivanov in <a class="reference external" href="https://bugs.python.org/issue?&#64;action=redirect&amp;bpo=32331">bpo-32331</a>.)</p></li>
  2201. <li><p>On Windows the default for the <em>close_fds</em> argument of
  2202. <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> was changed from <a class="reference internal" href="../library/constants.html#False" title="False"><code class="xref py py-const docutils literal notranslate"><span class="pre">False</span></code></a> to <a class="reference internal" href="../library/constants.html#True" title="True"><code class="xref py py-const docutils literal notranslate"><span class="pre">True</span></code></a>
  2203. when redirecting the standard handles. If you previously depended on handles
  2204. being inherited when using <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> with standard io
  2205. redirection, you will have to pass <code class="docutils literal notranslate"><span class="pre">close_fds=False</span></code> to preserve the
  2206. previous behaviour, or use
  2207. <a class="reference internal" href="../library/subprocess.html#subprocess.STARTUPINFO.lpAttributeList" title="subprocess.STARTUPINFO.lpAttributeList"><code class="xref py py-attr docutils literal notranslate"><span class="pre">STARTUPINFO.lpAttributeList</span></code></a>.</p></li>
  2208. <li><p><a class="reference internal" href="../library/importlib.html#importlib.machinery.PathFinder.invalidate_caches" title="importlib.machinery.PathFinder.invalidate_caches"><code class="xref py py-meth docutils literal notranslate"><span class="pre">importlib.machinery.PathFinder.invalidate_caches()</span></code></a> – which implicitly
  2209. affects <a class="reference internal" href="../library/importlib.html#importlib.invalidate_caches" title="importlib.invalidate_caches"><code class="xref py py-func docutils literal notranslate"><span class="pre">importlib.invalidate_caches()</span></code></a> – now deletes entries
  2210. in <a class="reference internal" href="../library/sys.html#sys.path_importer_cache" title="sys.path_importer_cache"><code class="xref py py-data docutils literal notranslate"><span class="pre">sys.path_importer_cache</span></code></a> which are set to <code class="docutils literal notranslate"><span class="pre">None</span></code>.
  2211. (Contributed by Brett Cannon in <a class="reference external" href="https://bugs.python.org/issue?&#64;action=redirect&amp;bpo=33169">bpo-33169</a>.)</p></li>
  2212. <li><p>In <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>,
  2213. <a class="reference internal" href="../library/asyncio-eventloop.html#asyncio.loop.sock_recv" title="asyncio.loop.sock_recv"><code class="xref py py-meth docutils literal notranslate"><span class="pre">loop.sock_recv()</span></code></a>,
  2214. <a class="reference internal" href="../library/asyncio-eventloop.html#asyncio.loop.sock_sendall" title="asyncio.loop.sock_sendall"><code class="xref py py-meth docutils literal notranslate"><span class="pre">loop.sock_sendall()</span></code></a>,
  2215. <a class="reference internal" href="../library/asyncio-eventloop.html#asyncio.loop.sock_accept" title="asyncio.loop.sock_accept"><code class="xref py py-meth docutils literal notranslate"><span class="pre">loop.sock_accept()</span></code></a>,
  2216. <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>,
  2217. <a class="reference internal" href="../library/asyncio-eventloop.html#asyncio.loop.getnameinfo" title="asyncio.loop.getnameinfo"><code class="xref py py-meth docutils literal notranslate"><span class="pre">loop.getnameinfo()</span></code></a>
  2218. have been changed to be proper coroutine methods to match their
  2219. documentation. Previously, these methods returned <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>
  2220. instances.
  2221. (Contributed by Yury Selivanov in <a class="reference external" href="https://bugs.python.org/issue?&#64;action=redirect&amp;bpo=32327">bpo-32327</a>.)</p></li>
  2222. <li><p><a class="reference internal" href="../library/asyncio-eventloop.html#asyncio.Server.sockets" title="asyncio.Server.sockets"><code class="xref py py-attr docutils literal notranslate"><span class="pre">asyncio.Server.sockets</span></code></a> now returns a copy of the internal list
  2223. of server sockets, instead of returning it directly.
  2224. (Contributed by Yury Selivanov in <a class="reference external" href="https://bugs.python.org/issue?&#64;action=redirect&amp;bpo=32662">bpo-32662</a>.)</p></li>
  2225. <li><p><a class="reference internal" href="../library/struct.html#struct.Struct.format" title="struct.Struct.format"><code class="xref py py-attr docutils literal notranslate"><span class="pre">Struct.format</span></code></a> is now 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> instance
  2226. instead of a <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> instance.
  2227. (Contributed by Victor Stinner in <a class="reference external" href="https://bugs.python.org/issue?&#64;action=redirect&amp;bpo=21071">bpo-21071</a>.)</p></li>
  2228. <li><p><a class="reference internal" href="../library/argparse.html#module-argparse" title="argparse: Command-line option and argument parsing library."><code class="xref py py-mod docutils literal notranslate"><span class="pre">argparse</span></code></a> subparsers can now be made mandatory by passing <code class="docutils literal notranslate"><span class="pre">required=True</span></code>
  2229. to <a class="reference internal" href="../library/argparse.html#argparse.ArgumentParser.add_subparsers" title="argparse.ArgumentParser.add_subparsers"><code class="xref py py-meth docutils literal notranslate"><span class="pre">ArgumentParser.add_subparsers()</span></code></a>.
  2230. (Contributed by Anthony Sottile in <a class="reference external" href="https://bugs.python.org/issue?&#64;action=redirect&amp;bpo=26510">bpo-26510</a>.)</p></li>
  2231. <li><p><a class="reference internal" href="../library/ast.html#ast.literal_eval" title="ast.literal_eval"><code class="xref py py-meth docutils literal notranslate"><span class="pre">ast.literal_eval()</span></code></a> is now stricter. Addition and subtraction of
  2232. arbitrary numbers are no longer allowed.
  2233. (Contributed by Serhiy Storchaka in <a class="reference external" href="https://bugs.python.org/issue?&#64;action=redirect&amp;bpo=31778">bpo-31778</a>.)</p></li>
  2234. <li><p><a class="reference internal" href="../library/calendar.html#calendar.Calendar.itermonthdates" title="calendar.Calendar.itermonthdates"><code class="xref py py-meth docutils literal notranslate"><span class="pre">Calendar.itermonthdates</span></code></a>
  2235. will now consistently raise an exception when a date falls outside of the
  2236. <code class="docutils literal notranslate"><span class="pre">0001-01-01</span></code> through <code class="docutils literal notranslate"><span class="pre">9999-12-31</span></code> range. To support applications that
  2237. cannot tolerate such exceptions, the new
  2238. <a class="reference internal" href="../library/calendar.html#calendar.Calendar.itermonthdays3" title="calendar.Calendar.itermonthdays3"><code class="xref py py-meth docutils literal notranslate"><span class="pre">Calendar.itermonthdays3</span></code></a> and
  2239. <a class="reference internal" href="../library/calendar.html#calendar.Calendar.itermonthdays4" title="calendar.Calendar.itermonthdays4"><code class="xref py py-meth docutils literal notranslate"><span class="pre">Calendar.itermonthdays4</span></code></a> can be used.
  2240. The new methods return tuples and are not restricted by the range supported by
  2241. <a class="reference internal" href="../library/datetime.html#datetime.date" title="datetime.date"><code class="xref py py-class docutils literal notranslate"><span class="pre">datetime.date</span></code></a>.
  2242. (Contributed by Alexander Belopolsky in <a class="reference external" href="https://bugs.python.org/issue?&#64;action=redirect&amp;bpo=28292">bpo-28292</a>.)</p></li>
  2243. <li><p><a class="reference internal" href="../library/collections.html#collections.ChainMap" title="collections.ChainMap"><code class="xref py py-class docutils literal notranslate"><span class="pre">collections.ChainMap</span></code></a> now preserves the order of the underlying
  2244. mappings. (Contributed by Raymond Hettinger in <a class="reference external" href="https://bugs.python.org/issue?&#64;action=redirect&amp;bpo=32792">bpo-32792</a>.)</p></li>
  2245. <li><p>The <code class="docutils literal notranslate"><span class="pre">submit()</span></code> method of <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">concurrent.futures.ThreadPoolExecutor</span></code></a>
  2246. and <a class="reference internal" href="../library/concurrent.futures.html#concurrent.futures.ProcessPoolExecutor" title="concurrent.futures.ProcessPoolExecutor"><code class="xref py py-class docutils literal notranslate"><span class="pre">concurrent.futures.ProcessPoolExecutor</span></code></a> now raises
  2247. 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> if called during interpreter shutdown.
  2248. (Contributed by Mark Nemec in <a class="reference external" href="https://bugs.python.org/issue?&#64;action=redirect&amp;bpo=33097">bpo-33097</a>.)</p></li>
  2249. <li><p>The <a class="reference internal" href="../library/configparser.html#configparser.ConfigParser" title="configparser.ConfigParser"><code class="xref py py-class docutils literal notranslate"><span class="pre">configparser.ConfigParser</span></code></a> constructor now uses <code class="docutils literal notranslate"><span class="pre">read_dict()</span></code>
  2250. to process the default values, making its behavior consistent with the
  2251. rest of the parser. Non-string keys and values in the defaults
  2252. dictionary are now being implicitly converted to strings.
  2253. (Contributed by James Tocknell in <a class="reference external" href="https://bugs.python.org/issue?&#64;action=redirect&amp;bpo=23835">bpo-23835</a>.)</p></li>
  2254. <li><p>Several undocumented internal imports were removed.
  2255. One example is that <code class="docutils literal notranslate"><span class="pre">os.errno</span></code> is no longer available; use <code class="docutils literal notranslate"><span class="pre">import</span> <span class="pre">errno</span></code>
  2256. directly instead.
  2257. Note that such undocumented internal imports may be removed any time without
  2258. notice, even in micro version releases.</p></li>
  2259. </ul>
  2260. </section>
  2261. <section id="changes-in-the-c-api">
  2262. <h3>Changes in the C API<a class="headerlink" href="#changes-in-the-c-api" title="Link to this heading">¶</a></h3>
  2263. <p>The function <a class="reference internal" href="../c-api/slice.html#c.PySlice_GetIndicesEx" title="PySlice_GetIndicesEx"><code class="xref c c-func docutils literal notranslate"><span class="pre">PySlice_GetIndicesEx()</span></code></a> is considered unsafe for
  2264. resizable sequences. If the slice indices are not instances of <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>,
  2265. but objects that implement the <code class="xref py py-meth docutils literal notranslate"><span class="pre">__index__()</span></code> method, the sequence can be
  2266. resized after passing its length to <code class="xref c c-func docutils literal notranslate"><span class="pre">PySlice_GetIndicesEx()</span></code>. This
  2267. can lead to returning indices out of the length of the sequence. For
  2268. avoiding possible problems use new functions <a class="reference internal" href="../c-api/slice.html#c.PySlice_Unpack" title="PySlice_Unpack"><code class="xref c c-func docutils literal notranslate"><span class="pre">PySlice_Unpack()</span></code></a> and
  2269. <a class="reference internal" href="../c-api/slice.html#c.PySlice_AdjustIndices" title="PySlice_AdjustIndices"><code class="xref c c-func docutils literal notranslate"><span class="pre">PySlice_AdjustIndices()</span></code></a>.
  2270. (Contributed by Serhiy Storchaka in <a class="reference external" href="https://bugs.python.org/issue?&#64;action=redirect&amp;bpo=27867">bpo-27867</a>.)</p>
  2271. </section>
  2272. <section id="cpython-bytecode-changes">
  2273. <h3>CPython bytecode changes<a class="headerlink" href="#cpython-bytecode-changes" title="Link to this heading">¶</a></h3>
  2274. <p>There are two new opcodes: <a class="reference internal" href="../library/dis.html#opcode-LOAD_METHOD"><code class="xref std std-opcode docutils literal notranslate"><span class="pre">LOAD_METHOD</span></code></a> and <code class="xref std std-opcode docutils literal notranslate"><span class="pre">CALL_METHOD</span></code>.
  2275. (Contributed by Yury Selivanov and INADA Naoki in <a class="reference external" href="https://bugs.python.org/issue?&#64;action=redirect&amp;bpo=26110">bpo-26110</a>.)</p>
  2276. <p>The <code class="xref std std-opcode docutils literal notranslate"><span class="pre">STORE_ANNOTATION</span></code> opcode has been removed.
  2277. (Contributed by Mark Shannon in <a class="reference external" href="https://bugs.python.org/issue?&#64;action=redirect&amp;bpo=32550">bpo-32550</a>.)</p>
  2278. </section>
  2279. <section id="id12">
  2280. <h3>Windows-only Changes<a class="headerlink" href="#id12" title="Link to this heading">¶</a></h3>
  2281. <p>The file used to override <a class="reference internal" href="../library/sys.html#sys.path" title="sys.path"><code class="xref py py-data docutils literal notranslate"><span class="pre">sys.path</span></code></a> is now called
  2282. <code class="docutils literal notranslate"><span class="pre">&lt;python-executable&gt;._pth</span></code> instead of <code class="docutils literal notranslate"><span class="pre">'sys.path'</span></code>.
  2283. See <a class="reference internal" href="../using/windows.html#windows-finding-modules"><span class="std std-ref">Finding modules</span></a> for more information.
  2284. (Contributed by Steve Dower in <a class="reference external" href="https://bugs.python.org/issue?&#64;action=redirect&amp;bpo=28137">bpo-28137</a>.)</p>
  2285. </section>
  2286. <section id="id13">
  2287. <h3>Other CPython implementation changes<a class="headerlink" href="#id13" title="Link to this heading">¶</a></h3>
  2288. <p>In preparation for potential future changes to the public CPython runtime
  2289. initialization API (see <span class="target" id="index-38"></span><a class="pep reference external" href="https://peps.python.org/pep-0432/"><strong>PEP 432</strong></a> for an initial, but somewhat outdated,
  2290. draft), CPython’s internal startup
  2291. and configuration management logic has been significantly refactored. While
  2292. these updates are intended to be entirely transparent to both embedding
  2293. applications and users of the regular CPython CLI, they’re being mentioned
  2294. here as the refactoring changes the internal order of various operations
  2295. during interpreter startup, and hence may uncover previously latent defects,
  2296. either in embedding applications, or in CPython itself.
  2297. (Initially contributed by Nick Coghlan and Eric Snow as part of
  2298. <a class="reference external" href="https://bugs.python.org/issue?&#64;action=redirect&amp;bpo=22257">bpo-22257</a>, and further updated by Nick, Eric, and Victor Stinner in a
  2299. number of other issues). Some known details affected:</p>
  2300. <ul class="simple">
  2301. <li><p><a class="reference internal" href="../c-api/sys.html#c.PySys_AddWarnOptionUnicode" title="PySys_AddWarnOptionUnicode"><code class="xref c c-func docutils literal notranslate"><span class="pre">PySys_AddWarnOptionUnicode()</span></code></a> is not currently usable by embedding
  2302. applications due to the requirement to create a Unicode object prior to
  2303. calling <code class="docutils literal notranslate"><span class="pre">Py_Initialize</span></code>. Use <a class="reference internal" href="../c-api/sys.html#c.PySys_AddWarnOption" title="PySys_AddWarnOption"><code class="xref c c-func docutils literal notranslate"><span class="pre">PySys_AddWarnOption()</span></code></a> instead.</p></li>
  2304. <li><p>warnings filters added by an embedding application with
  2305. <a class="reference internal" href="../c-api/sys.html#c.PySys_AddWarnOption" title="PySys_AddWarnOption"><code class="xref c c-func docutils literal notranslate"><span class="pre">PySys_AddWarnOption()</span></code></a> should now more consistently take precedence
  2306. over the default filters set by the interpreter</p></li>
  2307. </ul>
  2308. <p>Due to changes in the way the default warnings filters are configured,
  2309. setting <a class="reference internal" href="../c-api/init.html#c.Py_BytesWarningFlag" title="Py_BytesWarningFlag"><code class="xref c c-data docutils literal notranslate"><span class="pre">Py_BytesWarningFlag</span></code></a> to a value greater than one is no longer
  2310. sufficient to both emit <a class="reference internal" href="../library/exceptions.html#BytesWarning" title="BytesWarning"><code class="xref py py-exc docutils literal notranslate"><span class="pre">BytesWarning</span></code></a> messages and have them converted
  2311. to exceptions. Instead, the flag must be set (to cause the warnings to be
  2312. emitted in the first place), and an explicit <code class="docutils literal notranslate"><span class="pre">error::BytesWarning</span></code>
  2313. warnings filter added to convert them to exceptions.</p>
  2314. <p>Due to a change in the way docstrings are handled by the compiler, the
  2315. implicit <code class="docutils literal notranslate"><span class="pre">return</span> <span class="pre">None</span></code> in a function body consisting solely of a docstring
  2316. is now marked as occurring on the same line as the docstring, not on the
  2317. function’s header line.</p>
  2318. <p>The current exception state has been moved from the frame object to the co-routine.
  2319. This simplified the interpreter and fixed a couple of obscure bugs caused by
  2320. having swap exception state when entering or exiting a generator.
  2321. (Contributed by Mark Shannon in <a class="reference external" href="https://bugs.python.org/issue?&#64;action=redirect&amp;bpo=25612">bpo-25612</a>.)</p>
  2322. </section>
  2323. </section>
  2324. <section id="notable-changes-in-python-3-7-1">
  2325. <h2>Notable changes in Python 3.7.1<a class="headerlink" href="#notable-changes-in-python-3-7-1" title="Link to this heading">¶</a></h2>
  2326. <p>Starting in 3.7.1, <a class="reference internal" href="../c-api/init.html#c.Py_Initialize" title="Py_Initialize"><code class="xref c c-func docutils literal notranslate"><span class="pre">Py_Initialize()</span></code></a> now consistently reads and respects
  2327. all of the same environment settings as <a class="reference internal" href="../c-api/veryhigh.html#c.Py_Main" title="Py_Main"><code class="xref c c-func docutils literal notranslate"><span class="pre">Py_Main()</span></code></a> (in earlier Python
  2328. versions, it respected an ill-defined subset of those environment variables,
  2329. while in Python 3.7.0 it didn’t read any of them due to <a class="reference external" href="https://bugs.python.org/issue?&#64;action=redirect&amp;bpo=34247">bpo-34247</a>). If
  2330. this behavior is unwanted, set <a class="reference internal" href="../c-api/init.html#c.Py_IgnoreEnvironmentFlag" title="Py_IgnoreEnvironmentFlag"><code class="xref c c-data docutils literal notranslate"><span class="pre">Py_IgnoreEnvironmentFlag</span></code></a> to 1 before
  2331. calling <a class="reference internal" href="../c-api/init.html#c.Py_Initialize" title="Py_Initialize"><code class="xref c c-func docutils literal notranslate"><span class="pre">Py_Initialize()</span></code></a>.</p>
  2332. <p>In 3.7.1 the C API for Context Variables
  2333. <a class="reference internal" href="../c-api/contextvars.html#contextvarsobjects-pointertype-change"><span class="std std-ref">was updated</span></a> to use
  2334. <a class="reference internal" href="../c-api/structures.html#c.PyObject" title="PyObject"><code class="xref c c-type docutils literal notranslate"><span class="pre">PyObject</span></code></a> pointers. See also <a class="reference external" href="https://bugs.python.org/issue?&#64;action=redirect&amp;bpo=34762">bpo-34762</a>.</p>
  2335. <p>In 3.7.1 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
  2336. when provided with input that does not have a trailing new line. This behavior
  2337. now matches what the C tokenizer does internally.
  2338. (Contributed by Ammar Askar in <a class="reference external" href="https://bugs.python.org/issue?&#64;action=redirect&amp;bpo=33899">bpo-33899</a>.)</p>
  2339. </section>
  2340. <section id="notable-changes-in-python-3-7-2">
  2341. <h2>Notable changes in Python 3.7.2<a class="headerlink" href="#notable-changes-in-python-3-7-2" title="Link to this heading">¶</a></h2>
  2342. <p>In 3.7.2, <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> on Windows no longer copies the original binaries, but
  2343. creates redirector scripts named <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> instead.
  2344. This resolves a long standing issue where all virtual environments would have
  2345. to be upgraded or recreated with each Python update. However, note that this
  2346. release will still require recreation of virtual environments in order to get
  2347. the new scripts.</p>
  2348. </section>
  2349. <section id="notable-changes-in-python-3-7-6">
  2350. <h2>Notable changes in Python 3.7.6<a class="headerlink" href="#notable-changes-in-python-3-7-6" title="Link to this heading">¶</a></h2>
  2351. <p>Due to significant security concerns, the <em>reuse_address</em> parameter of
  2352. <a class="reference internal" href="../library/asyncio-eventloop.html#asyncio.loop.create_datagram_endpoint" title="asyncio.loop.create_datagram_endpoint"><code class="xref py py-meth docutils literal notranslate"><span class="pre">asyncio.loop.create_datagram_endpoint()</span></code></a> is no longer supported. This is
  2353. because of the behavior of the socket option <code class="docutils literal notranslate"><span class="pre">SO_REUSEADDR</span></code> in UDP. For more
  2354. details, see the documentation for <code class="docutils literal notranslate"><span class="pre">loop.create_datagram_endpoint()</span></code>.
  2355. (Contributed by Kyle Stanley, Antoine Pitrou, and Yury Selivanov in
  2356. <a class="reference external" href="https://bugs.python.org/issue?&#64;action=redirect&amp;bpo=37228">bpo-37228</a>.)</p>
  2357. </section>
  2358. <section id="notable-changes-in-python-3-7-10">
  2359. <h2>Notable changes in Python 3.7.10<a class="headerlink" href="#notable-changes-in-python-3-7-10" title="Link to this heading">¶</a></h2>
  2360. <p>Earlier Python versions allowed using both <code class="docutils literal notranslate"><span class="pre">;</span></code> and <code class="docutils literal notranslate"><span class="pre">&amp;</span></code> as
  2361. query parameter separators in <a class="reference internal" href="../library/urllib.parse.html#urllib.parse.parse_qs" title="urllib.parse.parse_qs"><code class="xref py py-func docutils literal notranslate"><span class="pre">urllib.parse.parse_qs()</span></code></a> and
  2362. <a class="reference internal" href="../library/urllib.parse.html#urllib.parse.parse_qsl" title="urllib.parse.parse_qsl"><code class="xref py py-func docutils literal notranslate"><span class="pre">urllib.parse.parse_qsl()</span></code></a>. Due to security concerns, and to conform with
  2363. newer W3C recommendations, this has been changed to allow only a single
  2364. separator key, with <code class="docutils literal notranslate"><span class="pre">&amp;</span></code> as the default. This change also affects
  2365. <a class="reference internal" href="../library/cgi.html#cgi.parse" title="cgi.parse"><code class="xref py py-func docutils literal notranslate"><span class="pre">cgi.parse()</span></code></a> and <a class="reference internal" href="../library/cgi.html#cgi.parse_multipart" title="cgi.parse_multipart"><code class="xref py py-func docutils literal notranslate"><span class="pre">cgi.parse_multipart()</span></code></a> as they use the affected
  2366. functions internally. For more details, please see their respective
  2367. documentation.
  2368. (Contributed by Adam Goldschmidt, Senthil Kumaran and Ken Jin in <a class="reference external" href="https://bugs.python.org/issue?&#64;action=redirect&amp;bpo=42967">bpo-42967</a>.)</p>
  2369. </section>
  2370. <section id="notable-changes-in-python-3-7-11">
  2371. <h2>Notable changes in Python 3.7.11<a class="headerlink" href="#notable-changes-in-python-3-7-11" title="Link to this heading">¶</a></h2>
  2372. <p>A security fix alters the <a class="reference internal" href="../library/ftplib.html#ftplib.FTP" title="ftplib.FTP"><code class="xref py py-class docutils literal notranslate"><span class="pre">ftplib.FTP</span></code></a> behavior to not trust the
  2373. IPv4 address sent from the remote server when setting up a passive data
  2374. channel. We reuse the ftp server IP address instead. For unusual code
  2375. requiring the old behavior, set a <code class="docutils literal notranslate"><span class="pre">trust_server_pasv_ipv4_address</span></code>
  2376. attribute on your FTP instance to <code class="docutils literal notranslate"><span class="pre">True</span></code>. (See <a class="reference external" href="https://github.com/python/cpython/issues/87451">gh-87451</a>)</p>
  2377. <p>The presence of newline or tab characters in parts of a URL allows for some
  2378. forms of attacks. Following the WHATWG specification that updates RFC 3986,
  2379. ASCII newline <code class="docutils literal notranslate"><span class="pre">\n</span></code>, <code class="docutils literal notranslate"><span class="pre">\r</span></code> and tab <code class="docutils literal notranslate"><span class="pre">\t</span></code> characters are stripped from the
  2380. URL by the parser <a class="reference internal" href="../library/urllib.parse.html#module-urllib.parse" title="urllib.parse: Parse URLs into or assemble them from components."><code class="xref py py-func docutils literal notranslate"><span class="pre">urllib.parse()</span></code></a> preventing such attacks. The removal
  2381. characters are controlled by a new module level variable
  2382. <code class="docutils literal notranslate"><span class="pre">urllib.parse._UNSAFE_URL_BYTES_TO_REMOVE</span></code>. (See <a class="reference external" href="https://github.com/python/cpython/issues/88048">gh-88048</a>)</p>
  2383. </section>
  2384. <section id="notable-security-feature-in-3-7-14">
  2385. <h2>Notable security feature in 3.7.14<a class="headerlink" href="#notable-security-feature-in-3-7-14" title="Link to this heading">¶</a></h2>
  2386. <p>Converting between <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> and <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> in bases other than 2
  2387. (binary), 4, 8 (octal), 16 (hexadecimal), or 32 such as base 10 (decimal)
  2388. now raises 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> if the number of digits in string form is
  2389. above a limit to avoid potential denial of service attacks due to the
  2390. algorithmic complexity. This is a mitigation for <a class="reference external" href="https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2020-10735">CVE-2020-10735</a>.
  2391. This limit can be configured or disabled by environment variable, command
  2392. line flag, or <a class="reference internal" href="../library/sys.html#module-sys" title="sys: Access system-specific parameters and functions."><code class="xref py py-mod docutils literal notranslate"><span class="pre">sys</span></code></a> APIs. See the <a class="reference internal" href="../library/stdtypes.html#int-max-str-digits"><span class="std std-ref">integer string conversion
  2393. length limitation</span></a> documentation. The default limit
  2394. is 4300 digits in string form.</p>
  2395. </section>
  2396. </section>
  2397. <div class="clearer"></div>
  2398. </div>
  2399. </div>
  2400. </div>
  2401. <div class="sphinxsidebar" role="navigation" aria-label="main navigation">
  2402. <div class="sphinxsidebarwrapper">
  2403. <div>
  2404. <h3><a href="../contents.html">Table of Contents</a></h3>
  2405. <ul>
  2406. <li><a class="reference internal" href="#">What’s New In Python 3.7</a><ul>
  2407. <li><a class="reference internal" href="#summary-release-highlights">Summary – Release Highlights</a></li>
  2408. <li><a class="reference internal" href="#new-features">New Features</a><ul>
  2409. <li><a class="reference internal" href="#pep-563-postponed-evaluation-of-annotations">PEP 563: Postponed Evaluation of Annotations</a></li>
  2410. <li><a class="reference internal" href="#pep-538-legacy-c-locale-coercion">PEP 538: Legacy C Locale Coercion</a></li>
  2411. <li><a class="reference internal" href="#pep-540-forced-utf-8-runtime-mode">PEP 540: Forced UTF-8 Runtime Mode</a></li>
  2412. <li><a class="reference internal" href="#pep-553-built-in-breakpoint">PEP 553: Built-in <code class="docutils literal notranslate"><span class="pre">breakpoint()</span></code></a></li>
  2413. <li><a class="reference internal" href="#pep-539-new-c-api-for-thread-local-storage">PEP 539: New C API for Thread-Local Storage</a></li>
  2414. <li><a class="reference internal" href="#pep-562-customization-of-access-to-module-attributes">PEP 562: Customization of Access to Module Attributes</a></li>
  2415. <li><a class="reference internal" href="#pep-564-new-time-functions-with-nanosecond-resolution">PEP 564: New Time Functions With Nanosecond Resolution</a></li>
  2416. <li><a class="reference internal" href="#pep-565-show-deprecationwarning-in-main">PEP 565: Show DeprecationWarning in <code class="docutils literal notranslate"><span class="pre">__main__</span></code></a></li>
  2417. <li><a class="reference internal" href="#pep-560-core-support-for-typing-module-and-generic-types">PEP 560: Core Support for <code class="docutils literal notranslate"><span class="pre">typing</span></code> module and Generic Types</a></li>
  2418. <li><a class="reference internal" href="#pep-552-hash-based-pyc-files">PEP 552: Hash-based .pyc Files</a></li>
  2419. <li><a class="reference internal" href="#pep-545-python-documentation-translations">PEP 545: Python Documentation Translations</a></li>
  2420. <li><a class="reference internal" href="#python-development-mode-x-dev">Python Development Mode (-X dev)</a></li>
  2421. </ul>
  2422. </li>
  2423. <li><a class="reference internal" href="#other-language-changes">Other Language Changes</a></li>
  2424. <li><a class="reference internal" href="#new-modules">New Modules</a><ul>
  2425. <li><a class="reference internal" href="#contextvars">contextvars</a></li>
  2426. <li><a class="reference internal" href="#dataclasses">dataclasses</a></li>
  2427. <li><a class="reference internal" href="#importlib-resources">importlib.resources</a></li>
  2428. </ul>
  2429. </li>
  2430. <li><a class="reference internal" href="#improved-modules">Improved Modules</a><ul>
  2431. <li><a class="reference internal" href="#argparse">argparse</a></li>
  2432. <li><a class="reference internal" href="#asyncio">asyncio</a></li>
  2433. <li><a class="reference internal" href="#binascii">binascii</a></li>
  2434. <li><a class="reference internal" href="#calendar">calendar</a></li>
  2435. <li><a class="reference internal" href="#collections">collections</a></li>
  2436. <li><a class="reference internal" href="#compileall">compileall</a></li>
  2437. <li><a class="reference internal" href="#concurrent-futures">concurrent.futures</a></li>
  2438. <li><a class="reference internal" href="#contextlib">contextlib</a></li>
  2439. <li><a class="reference internal" href="#cprofile">cProfile</a></li>
  2440. <li><a class="reference internal" href="#crypt">crypt</a></li>
  2441. <li><a class="reference internal" href="#datetime">datetime</a></li>
  2442. <li><a class="reference internal" href="#dbm">dbm</a></li>
  2443. <li><a class="reference internal" href="#decimal">decimal</a></li>
  2444. <li><a class="reference internal" href="#dis">dis</a></li>
  2445. <li><a class="reference internal" href="#distutils">distutils</a></li>
  2446. <li><a class="reference internal" href="#enum">enum</a></li>
  2447. <li><a class="reference internal" href="#functools">functools</a></li>
  2448. <li><a class="reference internal" href="#gc">gc</a></li>
  2449. <li><a class="reference internal" href="#hmac">hmac</a></li>
  2450. <li><a class="reference internal" href="#http-client">http.client</a></li>
  2451. <li><a class="reference internal" href="#http-server">http.server</a></li>
  2452. <li><a class="reference internal" href="#idlelib-and-idle">idlelib and IDLE</a></li>
  2453. <li><a class="reference internal" href="#importlib">importlib</a></li>
  2454. <li><a class="reference internal" href="#io">io</a></li>
  2455. <li><a class="reference internal" href="#ipaddress">ipaddress</a></li>
  2456. <li><a class="reference internal" href="#itertools">itertools</a></li>
  2457. <li><a class="reference internal" href="#locale">locale</a></li>
  2458. <li><a class="reference internal" href="#logging">logging</a></li>
  2459. <li><a class="reference internal" href="#math">math</a></li>
  2460. <li><a class="reference internal" href="#mimetypes">mimetypes</a></li>
  2461. <li><a class="reference internal" href="#msilib">msilib</a></li>
  2462. <li><a class="reference internal" href="#multiprocessing">multiprocessing</a></li>
  2463. <li><a class="reference internal" href="#os">os</a></li>
  2464. <li><a class="reference internal" href="#pathlib">pathlib</a></li>
  2465. <li><a class="reference internal" href="#pdb">pdb</a></li>
  2466. <li><a class="reference internal" href="#py-compile">py_compile</a></li>
  2467. <li><a class="reference internal" href="#pydoc">pydoc</a></li>
  2468. <li><a class="reference internal" href="#queue">queue</a></li>
  2469. <li><a class="reference internal" href="#re">re</a></li>
  2470. <li><a class="reference internal" href="#signal">signal</a></li>
  2471. <li><a class="reference internal" href="#socket">socket</a></li>
  2472. <li><a class="reference internal" href="#socketserver">socketserver</a></li>
  2473. <li><a class="reference internal" href="#sqlite3">sqlite3</a></li>
  2474. <li><a class="reference internal" href="#ssl">ssl</a></li>
  2475. <li><a class="reference internal" href="#string">string</a></li>
  2476. <li><a class="reference internal" href="#subprocess">subprocess</a></li>
  2477. <li><a class="reference internal" href="#sys">sys</a></li>
  2478. <li><a class="reference internal" href="#time">time</a></li>
  2479. <li><a class="reference internal" href="#tkinter">tkinter</a></li>
  2480. <li><a class="reference internal" href="#tracemalloc">tracemalloc</a></li>
  2481. <li><a class="reference internal" href="#types">types</a></li>
  2482. <li><a class="reference internal" href="#unicodedata">unicodedata</a></li>
  2483. <li><a class="reference internal" href="#unittest">unittest</a></li>
  2484. <li><a class="reference internal" href="#unittest-mock">unittest.mock</a></li>
  2485. <li><a class="reference internal" href="#urllib-parse">urllib.parse</a></li>
  2486. <li><a class="reference internal" href="#uu">uu</a></li>
  2487. <li><a class="reference internal" href="#uuid">uuid</a></li>
  2488. <li><a class="reference internal" href="#warnings">warnings</a></li>
  2489. <li><a class="reference internal" href="#xml">xml</a></li>
  2490. <li><a class="reference internal" href="#xml-etree">xml.etree</a></li>
  2491. <li><a class="reference internal" href="#xmlrpc-server">xmlrpc.server</a></li>
  2492. <li><a class="reference internal" href="#zipapp">zipapp</a></li>
  2493. <li><a class="reference internal" href="#zipfile">zipfile</a></li>
  2494. </ul>
  2495. </li>
  2496. <li><a class="reference internal" href="#c-api-changes">C API Changes</a></li>
  2497. <li><a class="reference internal" href="#build-changes">Build Changes</a></li>
  2498. <li><a class="reference internal" href="#optimizations">Optimizations</a></li>
  2499. <li><a class="reference internal" href="#other-cpython-implementation-changes">Other CPython Implementation Changes</a></li>
  2500. <li><a class="reference internal" href="#deprecated-python-behavior">Deprecated Python Behavior</a></li>
  2501. <li><a class="reference internal" href="#deprecated-python-modules-functions-and-methods">Deprecated Python modules, functions and methods</a><ul>
  2502. <li><a class="reference internal" href="#aifc">aifc</a></li>
  2503. <li><a class="reference internal" href="#whatsnew37-asyncio-deprecated">asyncio</a></li>
  2504. <li><a class="reference internal" href="#id3">collections</a></li>
  2505. <li><a class="reference internal" href="#id4">dbm</a></li>
  2506. <li><a class="reference internal" href="#id5">enum</a></li>
  2507. <li><a class="reference internal" href="#gettext">gettext</a></li>
  2508. <li><a class="reference internal" href="#id6">importlib</a></li>
  2509. <li><a class="reference internal" href="#id7">locale</a></li>
  2510. <li><a class="reference internal" href="#macpath">macpath</a></li>
  2511. <li><a class="reference internal" href="#threading">threading</a></li>
  2512. <li><a class="reference internal" href="#id8">socket</a></li>
  2513. <li><a class="reference internal" href="#id9">ssl</a></li>
  2514. <li><a class="reference internal" href="#sunau">sunau</a></li>
  2515. <li><a class="reference internal" href="#id10">sys</a></li>
  2516. <li><a class="reference internal" href="#wave">wave</a></li>
  2517. </ul>
  2518. </li>
  2519. <li><a class="reference internal" href="#deprecated-functions-and-types-of-the-c-api">Deprecated functions and types of the C API</a></li>
  2520. <li><a class="reference internal" href="#platform-support-removals">Platform Support Removals</a></li>
  2521. <li><a class="reference internal" href="#api-and-feature-removals">API and Feature Removals</a></li>
  2522. <li><a class="reference internal" href="#module-removals">Module Removals</a></li>
  2523. <li><a class="reference internal" href="#windows-only-changes">Windows-only Changes</a></li>
  2524. <li><a class="reference internal" href="#porting-to-python-3-7">Porting to Python 3.7</a><ul>
  2525. <li><a class="reference internal" href="#changes-in-python-behavior">Changes in Python Behavior</a></li>
  2526. <li><a class="reference internal" href="#changes-in-the-python-api">Changes in the Python API</a></li>
  2527. <li><a class="reference internal" href="#changes-in-the-c-api">Changes in the C API</a></li>
  2528. <li><a class="reference internal" href="#cpython-bytecode-changes">CPython bytecode changes</a></li>
  2529. <li><a class="reference internal" href="#id12">Windows-only Changes</a></li>
  2530. <li><a class="reference internal" href="#id13">Other CPython implementation changes</a></li>
  2531. </ul>
  2532. </li>
  2533. <li><a class="reference internal" href="#notable-changes-in-python-3-7-1">Notable changes in Python 3.7.1</a></li>
  2534. <li><a class="reference internal" href="#notable-changes-in-python-3-7-2">Notable changes in Python 3.7.2</a></li>
  2535. <li><a class="reference internal" href="#notable-changes-in-python-3-7-6">Notable changes in Python 3.7.6</a></li>
  2536. <li><a class="reference internal" href="#notable-changes-in-python-3-7-10">Notable changes in Python 3.7.10</a></li>
  2537. <li><a class="reference internal" href="#notable-changes-in-python-3-7-11">Notable changes in Python 3.7.11</a></li>
  2538. <li><a class="reference internal" href="#notable-security-feature-in-3-7-14">Notable security feature in 3.7.14</a></li>
  2539. </ul>
  2540. </li>
  2541. </ul>
  2542. </div>
  2543. <div>
  2544. <h4>Previous topic</h4>
  2545. <p class="topless"><a href="3.8.html"
  2546. title="previous chapter">What’s New In Python 3.8</a></p>
  2547. </div>
  2548. <div>
  2549. <h4>Next topic</h4>
  2550. <p class="topless"><a href="3.6.html"
  2551. title="next chapter">What’s New In Python 3.6</a></p>
  2552. </div>
  2553. <div role="note" aria-label="source link">
  2554. <h3>This Page</h3>
  2555. <ul class="this-page-menu">
  2556. <li><a href="../bugs.html">Report a Bug</a></li>
  2557. <li>
  2558. <a href="https://github.com/python/cpython/blob/main/Doc/whatsnew/3.7.rst"
  2559. rel="nofollow">Show Source
  2560. </a>
  2561. </li>
  2562. </ul>
  2563. </div>
  2564. </div>
  2565. <div id="sidebarbutton" title="Collapse sidebar">
  2566. <span>«</span>
  2567. </div>
  2568. </div>
  2569. <div class="clearer"></div>
  2570. </div>
  2571. <div class="related" role="navigation" aria-label="related navigation">
  2572. <h3>Navigation</h3>
  2573. <ul>
  2574. <li class="right" style="margin-right: 10px">
  2575. <a href="../genindex.html" title="General Index"
  2576. >index</a></li>
  2577. <li class="right" >
  2578. <a href="../py-modindex.html" title="Python Module Index"
  2579. >modules</a> |</li>
  2580. <li class="right" >
  2581. <a href="3.6.html" title="What’s New In Python 3.6"
  2582. >next</a> |</li>
  2583. <li class="right" >
  2584. <a href="3.8.html" title="What’s New In Python 3.8"
  2585. >previous</a> |</li>
  2586. <li><img src="../_static/py.svg" alt="Python logo" style="vertical-align: middle; margin-top: -1px"/></li>
  2587. <li><a href="https://www.python.org/">Python</a> &#187;</li>
  2588. <li class="switchers">
  2589. <div class="language_switcher_placeholder"></div>
  2590. <div class="version_switcher_placeholder"></div>
  2591. </li>
  2592. <li>
  2593. </li>
  2594. <li id="cpython-language-and-version">
  2595. <a href="../index.html">3.12.3 Documentation</a> &#187;
  2596. </li>
  2597. <li class="nav-item nav-item-1"><a href="index.html" >What’s New in Python</a> &#187;</li>
  2598. <li class="nav-item nav-item-this"><a href="">What’s New In Python 3.7</a></li>
  2599. <li class="right">
  2600. <div class="inline-search" role="search">
  2601. <form class="inline-search" action="../search.html" method="get">
  2602. <input placeholder="Quick search" aria-label="Quick search" type="search" name="q" id="search-box" />
  2603. <input type="submit" value="Go" />
  2604. </form>
  2605. </div>
  2606. |
  2607. </li>
  2608. <li class="right">
  2609. <label class="theme-selector-label">
  2610. Theme
  2611. <select class="theme-selector" oninput="activateTheme(this.value)">
  2612. <option value="auto" selected>Auto</option>
  2613. <option value="light">Light</option>
  2614. <option value="dark">Dark</option>
  2615. </select>
  2616. </label> |</li>
  2617. </ul>
  2618. </div>
  2619. <div class="footer">
  2620. &copy;
  2621. <a href="../copyright.html">
  2622. Copyright
  2623. </a>
  2624. 2001-2024, Python Software Foundation.
  2625. <br />
  2626. This page is licensed under the Python Software Foundation License Version 2.
  2627. <br />
  2628. Examples, recipes, and other code in the documentation are additionally licensed under the Zero Clause BSD License.
  2629. <br />
  2630. See <a href="/license.html">History and License</a> for more information.<br />
  2631. <br />
  2632. The Python Software Foundation is a non-profit corporation.
  2633. <a href="https://www.python.org/psf/donations/">Please donate.</a>
  2634. <br />
  2635. <br />
  2636. Last updated on Apr 09, 2024 (13:47 UTC).
  2637. <a href="/bugs.html">Found a bug</a>?
  2638. <br />
  2639. Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 7.2.6.
  2640. </div>
  2641. </body>
  2642. </html>
上海开阖软件有限公司 沪ICP备12045867号-1