Skip to content
3.5.txt 77.7 KiB
Newer Older
Ryott Glayzer's avatar
Ryott Glayzer committed
2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388

(Contributed by Victor Stinner in bpo-18395.)

A new "PyCodec_NameReplaceErrors()" function to replace the unicode
encode error with "\N{...}" escapes. (Contributed by Serhiy Storchaka
in bpo-19676.)

A new "PyErr_FormatV()" function similar to "PyErr_Format()", but
accepts a "va_list" argument. (Contributed by Antoine Pitrou in
bpo-18711.)

A new "PyExc_RecursionError" exception. (Contributed by Georg Brandl
in bpo-19235.)

New "PyModule_FromDefAndSpec()", "PyModule_FromDefAndSpec2()", and
"PyModule_ExecDef()" functions introduced by **PEP 489** -- multi-
phase extension module initialization. (Contributed by Petr Viktorin
in bpo-24268.)

New "PyNumber_MatrixMultiply()" and "PyNumber_InPlaceMatrixMultiply()"
functions to perform matrix multiplication. (Contributed by Benjamin
Peterson in bpo-21176.  See also **PEP 465** for details.)

The "PyTypeObject.tp_finalize" slot is now part of the stable ABI.

Windows builds now require Microsoft Visual C++ 14.0, which is
available as part of Visual Studio 2015.

Extension modules now include a platform information tag in their
filename on some platforms (the tag is optional, and CPython will
import extensions without it, although if the tag is present and
mismatched, the extension won't be loaded):

* On Linux, extension module filenames end with
  ".cpython-<major><minor>m-<architecture>-<os>.pyd":

  * "<major>" is the major number of the Python version; for Python
    3.5 this is "3".

  * "<minor>" is the minor number of the Python version; for Python
    3.5 this is "5".

  * "<architecture>" is the hardware architecture the extension module
    was built to run on. It's most commonly either "i386" for 32-bit
    Intel platforms or "x86_64" for 64-bit Intel (and AMD) platforms.

  * "<os>" is always "linux-gnu", except for extensions built to talk
    to the 32-bit ABI on 64-bit platforms, in which case it is "linux-
    gnu32" (and "<architecture>" will be "x86_64").

* On Windows, extension module filenames end with
  "<debug>.cp<major><minor>-<platform>.pyd":

  * "<major>" is the major number of the Python version; for Python
    3.5 this is "3".

  * "<minor>" is the minor number of the Python version; for Python
    3.5 this is "5".

  * "<platform>" is the platform the extension module was built for,
    either "win32" for Win32, "win_amd64" for Win64, "win_ia64" for
    Windows Itanium 64, and "win_arm" for Windows on ARM.

  * If built in debug mode, "<debug>" will be "_d", otherwise it will
    be blank.

* On OS X platforms, extension module filenames now end with
  "-darwin.so".

* On all other platforms, extension module filenames are the same as
  they were with Python 3.4.


Deprecated
==========


New Keywords
------------

"async" and "await" are not recommended to be used as variable, class,
function or module names.  Introduced by **PEP 492** in Python 3.5,
they will become proper keywords in Python 3.7.


Deprecated Python Behavior
--------------------------

Raising the "StopIteration" exception inside a generator will now
generate a silent "PendingDeprecationWarning", which will become a
non-silent deprecation warning in Python 3.6 and will trigger a
"RuntimeError" in Python 3.7. See PEP 479: Change StopIteration
handling inside generators for details.


Unsupported Operating Systems
-----------------------------

Windows XP is no longer supported by Microsoft, thus, per **PEP 11**,
CPython 3.5 is no longer officially supported on this OS.


Deprecated Python modules, functions and methods
------------------------------------------------

The "formatter" module has now graduated to full deprecation and is
still slated for removal in Python 3.6.

The "asyncio.async()" function is deprecated in favor of
"ensure_future()".

The "smtpd" module has in the past always decoded the DATA portion of
email messages using the "utf-8" codec.  This can now be controlled by
the new *decode_data* keyword to "SMTPServer".  The default value is
"True", but this default is deprecated.  Specify the *decode_data*
keyword with an appropriate value to avoid the deprecation warning.

Directly assigning values to the "key", "value" and "coded_value" of
"http.cookies.Morsel" objects is deprecated.  Use the "set()" method
instead.  In addition, the undocumented *LegalChars* parameter of
"set()" is deprecated, and is now ignored.

Passing a format string as keyword argument *format_string* to the
"format()" method of the "string.Formatter" class has been deprecated.
(Contributed by Serhiy Storchaka in bpo-23671.)

The "platform.dist()" and "platform.linux_distribution()" functions
are now deprecated.  Linux distributions use too many different ways
of describing themselves, so the functionality is left to a package.
(Contributed by Vajrasky Kok and Berker Peksag in bpo-1322.)

The previously undocumented "from_function" and "from_builtin" methods
of "inspect.Signature" are deprecated.  Use the new
"Signature.from_callable()" method instead. (Contributed by Yury
Selivanov in bpo-24248.)

The "inspect.getargspec()" function is deprecated and scheduled to be
removed in Python 3.6.  (See bpo-20438 for details.)

The "inspect" "getfullargspec()", "getcallargs()", and
"formatargspec()" functions are deprecated in favor of the
"inspect.signature()" API. (Contributed by Yury Selivanov in
bpo-20438.)

"getargvalues()" and "formatargvalues()" functions were inadvertently
marked as deprecated with the release of Python 3.5.0.

Use of "re.LOCALE" flag with str patterns or "re.ASCII" is now
deprecated.  (Contributed by Serhiy Storchaka in bpo-22407.)

Use of unrecognized special sequences consisting of "'\'" and an ASCII
letter in regular expression patterns and replacement patterns now
raises a deprecation warning and will be forbidden in Python 3.6.
(Contributed by Serhiy Storchaka in bpo-23622.)

The undocumented and unofficial *use_load_tests* default argument of
the "unittest.TestLoader.loadTestsFromModule()" method now is
deprecated and ignored. (Contributed by Robert Collins and Barry A.
Warsaw in bpo-16662.)


Removed
=======


API and Feature Removals
------------------------

The following obsolete and previously deprecated APIs and features
have been removed:

* The "__version__" attribute has been dropped from the email package.
  The email code hasn't been shipped separately from the stdlib for a
  long time, and the "__version__" string was not updated in the last
  few releases.

* The internal "Netrc" class in the "ftplib" module was deprecated in
  3.4, and has now been removed. (Contributed by Matt Chaput in
  bpo-6623.)

* The concept of ".pyo" files has been removed.

* The JoinableQueue class in the provisional "asyncio" module was
  deprecated in 3.4.4 and is now removed. (Contributed by A. Jesse
  Jiryu Davis in bpo-23464.)


Porting to Python 3.5
=====================

This section lists previously described changes and other bugfixes
that may require changes to your code.


Changes in Python behavior
--------------------------

* Due to an oversight, earlier Python versions erroneously accepted
  the following syntax:

     f(1 for x in [1], *args)
     f(1 for x in [1], **kwargs)

  Python 3.5 now correctly raises a "SyntaxError", as generator
  expressions must be put in parentheses if not a sole argument to a
  function.


Changes in the Python API
-------------------------

* **PEP 475**: System calls are now retried when interrupted by a
  signal instead of raising "InterruptedError" if the Python signal
  handler does not raise an exception.

* Before Python 3.5, a "datetime.time" object was considered to be
  false if it represented midnight in UTC.  This behavior was
  considered obscure and error-prone and has been removed in Python
  3.5.  See bpo-13936 for full details.

* The "ssl.SSLSocket.send()" method now raises either
  "ssl.SSLWantReadError" or "ssl.SSLWantWriteError" on a non-blocking
  socket if the operation would block.  Previously, it would return
  "0".  (Contributed by Nikolaus Rath in bpo-20951.)

* The "__name__" attribute of generators is now set from the function
  name, instead of being set from the code name. Use
  "gen.gi_code.co_name" to retrieve the code name. Generators also
  have a new "__qualname__" attribute, the qualified name, which is
  now used for the representation of a generator ("repr(gen)").
  (Contributed by Victor Stinner in bpo-21205.)

* The deprecated "strict" mode and argument of "HTMLParser",
  "HTMLParser.error()", and the "HTMLParserError" exception have been
  removed.  (Contributed by Ezio Melotti in bpo-15114.) The
  *convert_charrefs* argument of "HTMLParser" is now "True" by
  default.  (Contributed by Berker Peksag in bpo-21047.)

* Although it is not formally part of the API, it is worth noting for
  porting purposes (ie: fixing tests) that error messages that were
  previously of the form "'sometype' does not support the buffer
  protocol" are now of the form "a *bytes-like object* is required,
  not 'sometype'". (Contributed by Ezio Melotti in bpo-16518.)

* If the current directory is set to a directory that no longer exists
  then "FileNotFoundError" will no longer be raised and instead
  "find_spec()" will return "None" **without** caching "None" in
  "sys.path_importer_cache", which is different than the typical case
  (bpo-22834).

* HTTP status code and messages from "http.client" and "http.server"
  were refactored into a common "HTTPStatus" enum.  The values in
  "http.client" and "http.server" remain available for backwards
  compatibility.  (Contributed by Demian Brecht in bpo-21793.)

* When an import loader defines
  "importlib.machinery.Loader.exec_module()" it is now expected to
  also define "create_module()" (raises a "DeprecationWarning" now,
  will be an error in Python 3.6). If the loader inherits from
  "importlib.abc.Loader" then there is nothing to do, else simply
  define "create_module()" to return "None".  (Contributed by Brett
  Cannon in bpo-23014.)

* The "re.split()" function always ignored empty pattern matches, so
  the ""x*"" pattern worked the same as ""x+"", and the ""\b"" pattern
  never worked.  Now "re.split()" raises a warning if the pattern
  could match an empty string.  For compatibility, use patterns that
  never match an empty string (e.g. ""x+"" instead of ""x*"").
  Patterns that could only match an empty string (such as ""\b"") now
  raise an error. (Contributed by Serhiy Storchaka in bpo-22818.)

* The "http.cookies.Morsel" dict-like interface has been made self
  consistent:  morsel comparison now takes the "key" and "value" into
  account, "copy()" now results in a "Morsel" instance rather than a
  "dict", and "update()" will now raise an exception if any of the
  keys in the update dictionary are invalid.  In addition, the
  undocumented *LegalChars* parameter of "set()" is deprecated and is
  now ignored.  (Contributed by Demian Brecht in bpo-2211.)

* **PEP 488** has removed ".pyo" files from Python and introduced the
  optional "opt-" tag in ".pyc" file names. The
  "importlib.util.cache_from_source()" has gained an *optimization*
  parameter to help control the "opt-" tag. Because of this, the
  *debug_override* parameter of the function is now deprecated. *.pyo*
  files are also no longer supported as a file argument to the Python
  interpreter and thus serve no purpose when distributed on their own
  (i.e. sourceless code distribution). Due to the fact that the magic
  number for bytecode has changed in Python 3.5, all old *.pyo* files
  from previous versions of Python are invalid regardless of this PEP.

* The "socket" module now exports the "CAN_RAW_FD_FRAMES" constant on
  linux 3.6 and greater.

* The "ssl.cert_time_to_seconds()" function now interprets the input
  time as UTC and not as local time, per **RFC 5280**.  Additionally,
  the return value is always an "int". (Contributed by Akira Li in
  bpo-19940.)

* The "pygettext.py" Tool now uses the standard +NNNN format for
  timezones in the POT-Creation-Date header.

* The "smtplib" module now uses "sys.stderr" instead of the previous
  module-level "stderr" variable for debug output.  If your (test)
  program depends on patching the module-level variable to capture the
  debug output, you will need to update it to capture sys.stderr
  instead.

* The "str.startswith()" and "str.endswith()" methods no longer return
  "True" when finding the empty string and the indexes are completely
  out of range.  (Contributed by Serhiy Storchaka in bpo-24284.)

* The "inspect.getdoc()" function now returns documentation strings
  inherited from base classes.  Documentation strings no longer need
  to be duplicated if the inherited documentation is appropriate.  To
  suppress an inherited string, an empty string must be specified (or
  the documentation may be filled in).  This change affects the output
  of the "pydoc" module and the "help()" function. (Contributed by
  Serhiy Storchaka in bpo-15582.)

* Nested "functools.partial()" calls are now flattened.  If you were
  relying on the previous behavior, you can now either add an
  attribute to a "functools.partial()" object or you can create a
  subclass of "functools.partial()". (Contributed by Alexander
  Belopolsky in bpo-7830.)


Changes in the C API
--------------------

* The undocumented "format" member of the (non-public)
  "PyMemoryViewObject" structure has been removed. All extensions
  relying on the relevant parts in "memoryobject.h" must be rebuilt.

* The "PyMemAllocator" structure was renamed to "PyMemAllocatorEx" and
  a new "calloc" field was added.

* Removed non-documented macro "PyObject_REPR" which leaked
  references. Use format character "%R" in
  "PyUnicode_FromFormat()"-like functions to format the "repr()" of
  the object. (Contributed by Serhiy Storchaka in bpo-22453.)

* Because the lack of the "__module__" attribute breaks pickling and
  introspection, a deprecation warning is now raised for builtin types
  without the "__module__" attribute.  This would be an AttributeError
  in the future. (Contributed by Serhiy Storchaka in bpo-20204.)

* As part of the **PEP 492** implementation, the "tp_reserved" slot of
  "PyTypeObject" was replaced with a "tp_as_async" slot.  Refer to
  Coroutine Objects for new types, structures and functions.


Notable changes in Python 3.5.4
===============================


New "make regen-all" build target
---------------------------------

To simplify cross-compilation, and to ensure that CPython can reliably
be compiled without requiring an existing version of Python to already
be available, the autotools-based build system no longer attempts to
implicitly recompile generated files based on file modification times.

Instead, a new "make regen-all" command has been added to force
regeneration of these files when desired (e.g. after an initial
version of Python has already been built based on the pregenerated
versions).

More selective regeneration targets are also defined - see
Makefile.pre.in for details.

(Contributed by Victor Stinner in bpo-23404.)

New in version 3.5.4.


Removal of "make touch" build target
------------------------------------

The "make touch" build target previously used to request implicit
regeneration of generated files by updating their modification times
has been removed.

It has been replaced by the new "make regen-all" target.

(Contributed by Victor Stinner in bpo-23404.)

Changed in version 3.5.4.