python3.7.3-What’s New In Python 3.7

Improved Modules¶

argparse¶

The new ArgumentParser.parse_intermixed_args()

method allows intermixing options and positional arguments.

(Contributed by paul.j3 in bpo-14191.)

asyncio¶

The asyncio module has received many new features, usability and

performance improvements. Notable changes

include:

The new provisional asyncio.run() function can

be used to run a coroutine from synchronous code by automatically creating and

destroying the event loop.

(Contributed by Yury Selivanov in bpo-32314.)

asyncio gained support for contextvars.

loop.call_soon(),

loop.call_soon_threadsafe(),

loop.call_later(),

loop.call_at(), and

Future.add_done_callback()

have a new optional keyword-only context parameter.

Tasks now track their context automatically.

See PEP 567 for more details.

(Contributed by Yury Selivanov in bpo-32436.)

The new asyncio.create_task() function has been added as a shortcut

to asyncio.get_event_loop().create_task().

(Contributed by Andrew Svetlov in bpo-32311.)

The new loop.start_tls()

method can be used to upgrade an existing connection to TLS.

(Contributed by Yury Selivanov in bpo-23749.)

The new loop.sock_recv_into()

method allows reading data from a socket directly into a provided buffer making

it possible to reduce data copies.

(Contributed by Antoine Pitrou in bpo-31819.)

The new asyncio.current_task() function returns the currently running

Task instance, and the new asyncio.all_tasks()

function returns a set of all existing Task instances in a given loop.

The Task.current_task() and

Task.all_tasks() methods have been deprecated.

(Contributed by Andrew Svetlov in bpo-32250.)

The new provisional BufferedProtocol class allows

implementing streaming protocols with manual control over the receive buffer.

(Contributed by Yury Selivanov in bpo-32251.)

The new asyncio.get_running_loop() function returns the currently

running loop, and raises a RuntimeError if no loop is running.

This is in contrast with asyncio.get_event_loop(), which will create

a new event loop if none is running.

(Contributed by Yury Selivanov in bpo-32269.)

The new StreamWriter.wait_closed()

coroutine method allows waiting until the stream writer is closed. The new

StreamWriter.is_closing() method

can be used to determine if the writer is closing.

(Contributed by Andrew Svetlov in bpo-32391.)

The new loop.sock_sendfile()

coroutine method allows sending files using os.sendfile when possible.

(Contributed by Andrew Svetlov in bpo-32410.)

The new Future.get_loop() and

Task.get_loop() methods return the instance of the loop on which a task or

a future were created.

Server.get_loop() allows doing the same for

asyncio.Server objects.

(Contributed by Yury Selivanov in bpo-32415 and

Srinivas Reddy Thatiparthy in bpo-32418.)

It is now possible to control how instances of asyncio.Server begin

serving. Previously, the server would start serving immediately when created.

The new start_serving keyword argument to

loop.create_server() and

loop.create_unix_server(),

as well as Server.start_serving(), and

Server.serve_forever()

can be used to decouple server instantiation and serving. The new

Server.is_serving() method returns True

if the server is serving. Server objects are now

asynchronous context managers:

srv = await loop.create_server(...)

async with srv:

# some code

# At this point, srv is closed and no longer accepts new connections.

(Contributed by Yury Selivanov in bpo-32662.)

Callback objects returned by

loop.call_later()

gained the new when() method which

returns an absolute scheduled callback timestamp.

(Contributed by Andrew Svetlov in bpo-32741.)

The loop.create_datagram_endpoint() method

gained support for Unix sockets.

(Contributed by Quentin Dawans in bpo-31245.)

The asyncio.open_connection(), asyncio.start_server() functions,

loop.create_connection(),

loop.create_server(),

loop.create_accepted_socket()

methods and their corresponding UNIX socket variants now accept the

ssl_handshake_timeout keyword argument.

(Contributed by Neil Aspinall in bpo-29970.)

The new Handle.cancelled() method returns

True if the callback was cancelled.

(Contributed by Marat Sharafutdinov in bpo-31943.)

The asyncio source has been converted to use the

async/await syntax.

(Contributed by Andrew Svetlov in bpo-32193.)

The new ReadTransport.is_reading()

method can be used to determine the reading state of the transport.

Additionally, calls to

ReadTransport.resume_reading()

and ReadTransport.pause_reading()

are now idempotent.

(Contributed by Yury Selivanov in bpo-32356.)

Loop methods which accept socket paths now support passing

path-like objects.

(Contributed by Yury Selivanov in bpo-32066.)

In asyncio TCP sockets on Linux are now created with TCP_NODELAY

flag set by default.

(Contributed by Yury Selivanov and Victor Stinner in bpo-27456.)

Exceptions occurring in cancelled tasks are no longer logged.

(Contributed by Yury Selivanov in bpo-30508.)

New WindowsSelectorEventLoopPolicy and

WindowsProactorEventLoopPolicy classes.

(Contributed by Yury Selivanov in bpo-33792.)

Several asyncio APIs have been

deprecated.

binascii¶

The b2a_uu() function now accepts an optional backtick

keyword argument. When it’s true, zeros are represented by "`"

instead of spaces. (Contributed by Xiang Zhang in bpo-30103.)

calendar¶

The HTMLCalendar class has new class attributes which ease

the customization of CSS classes in the produced HTML calendar.

(Contributed by Oz Tiram in bpo-30095.)

collections¶

collections.namedtuple() now supports default values.

(Contributed by Raymond Hettinger in bpo-32320.)

compileall¶

compileall.compile_dir() learned the new invalidation_mode parameter,

which can be used to enable

hash-based .pyc invalidation. The invalidation

mode can also be specified on the command line using the new

--invalidation-mode argument.

(Contributed by Benjamin Peterson in bpo-31650.)

concurrent.futures¶

ProcessPoolExecutor and

ThreadPoolExecutor now

support the new initializer and initargs constructor arguments.

(Contributed by Antoine Pitrou in bpo-21423.)

The ProcessPoolExecutor

can now take the multiprocessing context via the new mp_context argument.

(Contributed by Thomas Moreau in bpo-31540.)

contextlib¶

The new nullcontext() is a simpler and faster no-op

context manager than ExitStack.

(Contributed by Jesse-Bakker in bpo-10049.)

The new asynccontextmanager(),

AbstractAsyncContextManager, and

AsyncExitStack have been added to

complement their synchronous counterparts. (Contributed

by Jelle Zijlstra in bpo-29679 and bpo-30241,

and by Alexander Mohr and Ilya Kulakov in bpo-29302.)

cProfile¶

The cProfile command line now accepts -m module_name as an

alternative to script path. (Contributed by Sanyam Khurana in bpo-21862.)

crypt¶

The crypt module now supports the Blowfish hashing method.

(Contributed by Serhiy Storchaka in bpo-31664.)

The mksalt() function now allows specifying the number of rounds

for hashing. (Contributed by Serhiy Storchaka in bpo-31702.)

datetime¶

The new datetime.fromisoformat()

method constructs a datetime object from a string

in one of the formats output by

datetime.isoformat().

(Contributed by Paul Ganssle in bpo-15873.)

The tzinfo class now supports sub-minute offsets.

(Contributed by Alexander Belopolsky in bpo-5288.)

dbm¶

dbm.dumb now supports reading read-only files and no longer writes the

index file when it is not changed.

decimal¶

The decimal module now uses context variables

to store the decimal context.

(Contributed by Yury Selivanov in bpo-32630.)

dis¶

The dis() function is now able to

disassemble nested code objects (the code of comprehensions, generator

expressions and nested functions, and the code used for building nested

classes). The maximum depth of disassembly recursion is controlled by

the new depth parameter.

(Contributed by Serhiy Storchaka in bpo-11822.)

distutils¶

README.rst is now included in the list of distutils standard READMEs and

therefore included in source distributions.

(Contributed by Ryan Gonzalez in bpo-11913.)

enum¶

The Enum learned the new _ignore_ class property,

which allows listing the names of properties which should not become

enum members.

(Contributed by Ethan Furman in bpo-31801.)

In Python 3.8, attempting to check for non-Enum objects in Enum

classes will raise a TypeError (e.g. 1 in Color); similarly,

attempting to check for non-Flag objects in a Flag member will

raise TypeError (e.g. 1 in Perm.RW); currently, both operations

return False instead and are deprecated.

(Contributed by Ethan Furman in bpo-33217.)

functools¶

functools.singledispatch() now supports registering implementations

using type annotations.

(Contributed by Łukasz Langa in bpo-32227.)

gc¶

The new gc.freeze() function allows freezing all objects tracked

by the garbage collector and excluding them from future collections.

This can be used before a POSIX fork() call to make the GC copy-on-write

friendly or to speed up collection. The new gc.unfreeze() functions

reverses this operation. Additionally, gc.get_freeze_count() can

be used to obtain the number of frozen objects.

(Contributed by Li Zekun in bpo-31558.)

hmac¶

The hmac module now has an optimized one-shot digest()

function, which is up to three times faster than HMAC().

(Contributed by Christian Heimes in bpo-32433.)

http.client¶

HTTPConnection and HTTPSConnection

now support the new blocksize argument for improved upload throughput.

(Contributed by Nir Soffer in bpo-31945.)

http.server¶

SimpleHTTPRequestHandler now supports the HTTP

If-Modified-Since header. The server returns the 304 response status if

the target file was not modified after the time specified in the header.

(Contributed by Pierre Quentel in bpo-29654.)

SimpleHTTPRequestHandler accepts the new directory

argument, in addition to the new --directory command line argument.

With this parameter, the server serves the specified directory, by default it

uses the current working directory.

(Contributed by Stéphane Wirtel and Julien Palard in bpo-28707.)

The new ThreadingHTTPServer class

uses threads to handle requests using ThreadingMixin.

It is used when http.server is run with -m.

(Contributed by Julien Palard in bpo-31639.)

idlelib and IDLE¶

Multiple fixes for autocompletion. (Contributed by Louie Lu in bpo-15786.)

Module Browser (on the File menu, formerly called Class Browser),

now displays nested functions and classes in addition to top-level

functions and classes.

(Contributed by Guilherme Polo, Cheryl Sabella, and Terry Jan Reedy

in bpo-1612262.)

The Settings dialog (Options, Configure IDLE) has been partly rewritten

to improve both appearance and function.

(Contributed by Cheryl Sabella and Terry Jan Reedy in multiple issues.)

The font sample now includes a selection of non-Latin characters so that

users can better see the effect of selecting a particular font.

(Contributed by Terry Jan Reedy in bpo-13802.)

The sample can be edited to include other characters.

(Contributed by Serhiy Storchaka in bpo-31860.)

The IDLE features formerly implemented as extensions have been reimplemented

as normal features. Their settings have been moved from the Extensions tab

to other dialog tabs.

(Contributed by Charles Wohlganger and Terry Jan Reedy in bpo-27099.)

Editor code context option revised. Box displays all context lines up to

maxlines. Clicking on a context line jumps the editor to that line. Context

colors for custom themes is added to Highlights tab of Settings dialog.

(Contributed by Cheryl Sabella and Terry Jan Reedy in bpo-33642,

bpo-33768, and bpo-33679.)

On Windows, a new API call tells Windows that tk scales for DPI. On Windows

8.1+ or 10, with DPI compatibility properties of the Python binary

unchanged, and a monitor resolution greater than 96 DPI, this should

make text and lines sharper. It should otherwise have no effect.

(Contributed by Terry Jan Reedy in bpo-33656.)

New in 3.7.1:

Output over N lines (50 by default) is squeezed down to a button.

N can be changed in the PyShell section of the General page of the

Settings dialog. Fewer, but possibly extra long, lines can be squeezed by

right clicking on the output. Squeezed output can be expanded in place

by double-clicking the button or into the clipboard or a separate window

by right-clicking the button. (Contributed by Tal Einat in bpo-1529353.)

The changes above have been backported to 3.6 maintenance releases.

NEW in 3.7.4:

Add “Run Customized” to the Run menu to run a module with customized

settings. Any command line arguments entered are added to sys.argv.

They re-appear in the box for the next customized run. One can also

suppress the normal Shell main module restart. (Contributed by Cheryl

Sabella, Terry Jan Reedy, and others in bpo-5680 and bpo-37627.)

New in 3.7.5:

Add optional line numbers for IDLE editor windows. Windows

open without line numbers unless set otherwise in the General

tab of the configuration dialog. Line numbers for an existing

window are shown and hidden in the Options menu.

(Contributed by Tal Einat and Saimadhav Heblikar in bpo-17535.)

importlib¶

The importlib.abc.ResourceReader ABC was introduced to

support the loading of resources from packages. See also

importlib.resources.

(Contributed by Barry Warsaw, Brett Cannon in bpo-32248.)

importlib.reload() now raises ModuleNotFoundError if the module

lacks a spec.

(Contributed by Garvit Khatri in bpo-29851.)

importlib.find_spec() now raises ModuleNotFoundError instead of

AttributeError if the specified parent module is not a package (i.e.

lacks a __path__ attribute).

(Contributed by Milan Oberkirch in bpo-30436.)

The new importlib.source_hash() can be used to compute the hash of

the passed source. A hash-based .pyc file

embeds the value returned by this function.

io¶

The new TextIOWrapper.reconfigure()

method can be used to reconfigure the text stream with the new settings.

(Contributed by Antoine Pitrou in bpo-30526 and

INADA Naoki in bpo-15216.)

ipaddress¶

The new subnet_of() and supernet_of() methods of

ipaddress.IPv6Network and ipaddress.IPv4Network can

be used for network containment tests.

(Contributed by Michel Albert and Cheryl Sabella in bpo-20825.)

itertools¶

itertools.islice() now accepts

integer-like objects as start, stop,

and slice arguments.

(Contributed by Will Roberts in bpo-30537.)

locale¶

The new monetary argument to locale.format_string() can be used

to make the conversion use monetary thousands separators and

grouping strings. (Contributed by Garvit in bpo-10379.)

The locale.getpreferredencoding() function now always returns "UTF-8"

on Android or when in the forced UTF-8 mode.

logging¶

Logger instances can now be pickled.

(Contributed by Vinay Sajip in bpo-30520.)

The new StreamHandler.setStream()

method can be used to replace the logger stream after handler creation.

(Contributed by Vinay Sajip in bpo-30522.)

It is now possible to specify keyword arguments to handler constructors in

configuration passed to logging.config.fileConfig().

(Contributed by Preston Landers in bpo-31080.)

math¶

The new math.remainder() function implements the IEEE 754-style remainder

operation. (Contributed by Mark Dickinson in bpo-29962.)

mimetypes¶

The MIME type of .bmp has been changed from "image/x-ms-bmp" to

"image/bmp".

(Contributed by Nitish Chandra in bpo-22589.)

msilib¶

The new Database.Close() method can be used

to close the MSI database.

(Contributed by Berker Peksag in bpo-20486.)

multiprocessing¶

The new Process.close() method

explicitly closes the process object and releases all resources associated

with it. ValueError is raised if the underlying process is still

running.

(Contributed by Antoine Pitrou in bpo-30596.)

The new Process.kill() method can

be used to terminate the process using the SIGKILL signal on Unix.

(Contributed by Vitor Pereira in bpo-30794.)

Non-daemonic threads created by Process are now

joined on process exit.

(Contributed by Antoine Pitrou in bpo-18966.)

os¶

os.fwalk() now accepts the path argument as bytes.

(Contributed by Serhiy Storchaka in bpo-28682.)

os.scandir() gained support for file descriptors.

(Contributed by Serhiy Storchaka in bpo-25996.)

The new register_at_fork() function allows registering Python

callbacks to be executed at process fork.

(Contributed by Antoine Pitrou in bpo-16500.)

Added os.preadv() (combine the functionality of os.readv() and

os.pread()) and os.pwritev() functions (combine the functionality

of os.writev() and os.pwrite()). (Contributed by Pablo Galindo in

bpo-31368.)

The mode argument of os.makedirs() no longer affects the file

permission bits of newly-created intermediate-level directories.

(Contributed by Serhiy Storchaka in bpo-19930.)

os.dup2() now returns the new file descriptor. Previously, None

was always returned.

(Contributed by Benjamin Peterson in bpo-32441.)

The structure returned by os.stat() now contains the

st_fstype attribute on Solaris and its derivatives.

(Contributed by Jesús Cea Avión in bpo-32659.)

pathlib¶

The new Path.is_mount() method is now available

on POSIX systems and can be used to determine whether a path is a mount point.

(Contributed by Cooper Ry Lees in bpo-30897.)

pdb¶

pdb.set_trace() now takes an optional header keyword-only

argument. If given, it is printed to the console just before debugging

begins. (Contributed by Barry Warsaw in bpo-31389.)

pdb command line now accepts -m module_name as an alternative to

script file. (Contributed by Mario Corchero in bpo-32206.)

py_compile¶

py_compile.compile() – and by extension, compileall – now

respects the SOURCE_DATE_EPOCH environment variable by

unconditionally creating .pyc files for hash-based validation.

This allows for guaranteeing

reproducible builds of .pyc

files when they are created eagerly. (Contributed by Bernhard M. Wiedemann

in bpo-29708.)

pydoc¶

The pydoc server can now bind to an arbitrary hostname specified by the

new -n command-line argument.

(Contributed by Feanil Patel in bpo-31128.)

queue¶

The new SimpleQueue class is an unbounded FIFO queue.

(Contributed by Antoine Pitrou in bpo-14976.)

re¶

The flags re.ASCII, re.LOCALE and re.UNICODE

can be set within the scope of a group.

(Contributed by Serhiy Storchaka in bpo-31690.)

re.split() now supports splitting on a pattern like r"",

"^$" or (?=-) that matches an empty string.

(Contributed by Serhiy Storchaka in bpo-25054.)

Regular expressions compiled with the re.LOCALE flag no longer

depend on the locale at compile time. Locale settings are applied only

when the compiled regular expression is used.

(Contributed by Serhiy Storchaka in bpo-30215.)

FutureWarning is now emitted if a regular expression contains

character set constructs that will change semantically in the future,

such as nested sets and set operations.

(Contributed by Serhiy Storchaka in bpo-30349.)

Compiled regular expression and match objects can now be copied

using copy.copy() and copy.deepcopy().

(Contributed by Serhiy Storchaka in bpo-10076.)

signal¶

The new warn_on_full_buffer argument to the signal.set_wakeup_fd()

function makes it possible to specify whether Python prints a warning on

stderr when the wakeup buffer overflows.

(Contributed by Nathaniel J. Smith in bpo-30050.)

socket¶

The new socket.getblocking() method

returns True if the socket is in blocking mode and False otherwise.

(Contributed by Yury Selivanov in bpo-32373.)

The new socket.close() function closes the passed socket file descriptor.

This function should be used instead of os.close() for better

compatibility across platforms.

(Contributed by Christian Heimes in bpo-32454.)

The socket module now exposes the socket.TCP_CONGESTION

(Linux 2.6.13), socket.TCP_USER_TIMEOUT (Linux 2.6.37), and

socket.TCP_NOTSENT_LOWAT (Linux 3.12) constants.

(Contributed by Omar Sandoval in bpo-26273 and

Nathaniel J. Smith in bpo-29728.)

Support for socket.AF_VSOCK sockets has been added to allow

communication between virtual machines and their hosts.

(Contributed by Cathy Avery in bpo-27584.)

Sockets now auto-detect family, type and protocol from file descriptor

by default.

(Contributed by Christian Heimes in bpo-28134.)

socketserver¶

socketserver.ThreadingMixIn.server_close() now waits until all non-daemon

threads complete. socketserver.ForkingMixIn.server_close() now waits

until all child processes complete.

Add a new socketserver.ForkingMixIn.block_on_close class attribute to

socketserver.ForkingMixIn and socketserver.ThreadingMixIn

classes. Set the class attribute to False to get the pre-3.7 behaviour.

sqlite3¶

sqlite3.Connection now exposes the backup()

method when the underlying SQLite library is at version 3.6.11 or higher.

(Contributed by Lele Gaifax in bpo-27645.)

The database argument of sqlite3.connect() now accepts any

path-like object, instead of just a string.

(Contributed by Anders Lorentsen in bpo-31843.)

ssl¶

The ssl module now uses OpenSSL’s builtin API instead of

match_hostname() to check a host name or an IP address. Values

are validated during TLS handshake. Any certificate validation error

including failing the host name check now raises

SSLCertVerificationError and aborts the handshake with a proper

TLS Alert message. The new exception contains additional information.

Host name validation can be customized with

SSLContext.hostname_checks_common_name.

(Contributed by Christian Heimes in bpo-31399.)

Note

The improved host name check requires a libssl implementation compatible

with OpenSSL 1.0.2 or 1.1. Consequently, OpenSSL 0.9.8 and 1.0.1 are no

longer supported (see Platform Support Removals for more details).

The ssl module is mostly compatible with LibreSSL 2.7.2 and newer.

The ssl module no longer sends IP addresses in SNI TLS extension.

(Contributed by Christian Heimes in bpo-32185.)

match_hostname() no longer supports partial wildcards like

www*.example.org.

(Contributed by Mandeep Singh in bpo-23033 and Christian Heimes in

bpo-31399.)

The default cipher suite selection of the ssl module now uses a blacklist

approach rather than a hard-coded whitelist. Python no longer re-enables

ciphers that have been blocked by OpenSSL security updates. Default cipher

suite selection can be configured at compile time.

(Contributed by Christian Heimes in bpo-31429.)

Validation of server certificates containing internationalized domain names

(IDNs) is now supported. As part of this change, the

SSLSocket.server_hostname attribute

now stores the expected hostname in A-label form ("xn--pythn-mua.org"),

rather than the U-label form ("pythön.org"). (Contributed by

Nathaniel J. Smith and Christian Heimes in bpo-28414.)

The ssl module has preliminary and experimental support for TLS 1.3 and

OpenSSL 1.1.1. At the time of Python 3.7.0 release, OpenSSL 1.1.1 is still

under development and TLS 1.3 hasn’t been finalized yet. The TLS 1.3

handshake and protocol behaves slightly differently than TLS 1.2 and earlier,

see TLS 1.3.

(Contributed by Christian Heimes in bpo-32947, bpo-20995,

bpo-29136, bpo-30622 and bpo-33618)

SSLSocket and SSLObject no longer have a public

constructor. Direct instantiation was never a documented and supported

feature. Instances must be created with SSLContext methods

wrap_socket() and wrap_bio().

(Contributed by Christian Heimes in bpo-32951)

OpenSSL 1.1 APIs for setting the minimum and maximum TLS protocol version are

available as SSLContext.minimum_version

and SSLContext.maximum_version.

Supported protocols are indicated by several new flags, such as

HAS_TLSv1_1.

(Contributed by Christian Heimes in bpo-32609.)

Added SSLContext.post_handshake_auth to enable and

ssl.SSLSocket.verify_client_post_handshake() to initiate TLS 1.3

post-handshake authentication.

(Contributed by Christian Heimes in bpo-34670.)

string¶

string.Template now lets you to optionally modify the regular

expression pattern for braced placeholders and non-braced placeholders

separately. (Contributed by Barry Warsaw in bpo-1198569.)

subprocess¶

The subprocess.run() function accepts the new capture_output

keyword argument. When true, stdout and stderr will be captured.

This is equivalent to passing subprocess.PIPE as stdout and

stderr arguments.

(Contributed by Bo Bayles in bpo-32102.)

The subprocess.run function and the subprocess.Popen constructor

now accept the text keyword argument as an alias

to universal_newlines.

(Contributed by Andrew Clegg in bpo-31756.)

On Windows the default for close_fds was changed from False to

True when redirecting the standard handles. It’s now possible to set

close_fds to true when redirecting the standard handles. See

subprocess.Popen. This means that close_fds now defaults to

True on all supported platforms.

(Contributed by Segev Finer in bpo-19764.)

The subprocess module is now more graceful when handling

KeyboardInterrupt during subprocess.call(),

subprocess.run(), or in a Popen

context manager. It now waits a short amount of time for the child

to exit, before continuing the handling of the KeyboardInterrupt

exception.

(Contributed by Gregory P. Smith in bpo-25942.)

sys¶

The new sys.breakpointhook() hook function is called by the

built-in breakpoint().

(Contributed by Barry Warsaw in bpo-31353.)

On Android, the new sys.getandroidapilevel() returns the build-time

Android API version.

(Contributed by Victor Stinner in bpo-28740.)

The new sys.get_coroutine_origin_tracking_depth() function returns

the current coroutine origin tracking depth, as set by

the new sys.set_coroutine_origin_tracking_depth(). asyncio

has been converted to use this new API instead of

the deprecated sys.set_coroutine_wrapper().

(Contributed by Nathaniel J. Smith in bpo-32591.)

time¶

PEP 564 adds six new functions with nanosecond resolution to the

time module:

New clock identifiers have been added:

time.CLOCK_BOOTTIME (Linux): Identical to

time.CLOCK_MONOTONIC, except it also includes any time that the

system is suspended.

time.CLOCK_PROF (FreeBSD, NetBSD and OpenBSD): High-resolution

per-process CPU timer.

time.CLOCK_UPTIME (FreeBSD, OpenBSD): Time whose absolute value is

the time the system has been running and not suspended, providing accurate

uptime measurement.

The new time.thread_time() and time.thread_time_ns() functions

can be used to get per-thread CPU time measurements.

(Contributed by Antoine Pitrou in bpo-32025.)

The new time.pthread_getcpuclockid() function returns the clock ID

of the thread-specific CPU-time clock.

tkinter¶

The new tkinter.ttk.Spinbox class is now available.

(Contributed by Alan Moore in bpo-32585.)

tracemalloc¶

tracemalloc.Traceback behaves more like regular tracebacks,

sorting the frames from oldest to most recent.

Traceback.format()

now accepts negative limit, truncating the result to the

abs(limit) oldest frames. To get the old behaviour, use

the new most_recent_first argument to Traceback.format().

(Contributed by Jesse Bakker in bpo-32121.)

types¶

The new WrapperDescriptorType,

MethodWrapperType, MethodDescriptorType,

and ClassMethodDescriptorType classes are now available.

(Contributed by Manuel Krebber and Guido van Rossum in bpo-29377,

and Serhiy Storchaka in bpo-32265.)

The new types.resolve_bases() function resolves MRO entries

dynamically as specified by PEP 560.

(Contributed by Ivan Levkivskyi in bpo-32717.)

unicodedata¶

The internal unicodedata database has been upgraded to use Unicode 11. (Contributed by Benjamin

Peterson.)

unittest¶

The new -k command-line option allows filtering tests by a name

substring or a Unix shell-like pattern.

For example, python -m unittest -k foo runs

foo_tests.SomeTest.test_something, bar_tests.SomeTest.test_foo,

but not bar_tests.FooTest.test_something.

(Contributed by Jonas Haag in bpo-32071.)

unittest.mock¶

The sentinel attributes now preserve their identity

when they are copied or pickled. (Contributed by

Serhiy Storchaka in bpo-20804.)

The new seal() function allows sealing

Mock instances, which will disallow further creation

of attribute mocks. The seal is applied recursively to all attributes that

are themselves mocks.

(Contributed by Mario Corchero in bpo-30541.)

urllib.parse¶

urllib.parse.quote() has been updated from RFC 2396 to RFC 3986,

adding ~ to the set of characters that are never quoted by default.

(Contributed by Christian Theune and Ratnadeep Debnath in bpo-16285.)

uu¶

The uu.encode() function now accepts an optional backtick

keyword argument. When it’s true, zeros are represented by "`"

instead of spaces. (Contributed by Xiang Zhang in bpo-30103.)

uuid¶

The new UUID.is_safe attribute relays information

from the platform about whether generated UUIDs are generated with a

multiprocessing-safe method.

(Contributed by Barry Warsaw in bpo-22807.)

uuid.getnode() now prefers universally administered

MAC addresses over locally administered MAC addresses.

This makes a better guarantee for global uniqueness of UUIDs returned

from uuid.uuid1(). If only locally administered MAC addresses are

available, the first such one found is returned.

(Contributed by Barry Warsaw in bpo-32107.)

warnings¶

The initialization of the default warnings filters has changed as follows:

warnings

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值