Pending removal in Python 3.16
- The import system:
- Setting
~module.__loader__on a module while failing to set__spec__.loader <importlib.machinery.ModuleSpec.loader>is deprecated. In Python 3.16,!__loader__will cease to be set or taken into consideration by the import system or the standard library. - Setting
~module.__package__on a module while failing to set__spec__.parent <importlib.machinery.ModuleSpec.parent>is deprecated. In Python 3.16,!__package__will cease to be taken into consideration by the import system or standard library. (97879)
- Setting
- The bundled copy of
libmpdec. array:- The
'u'format code (wchar_t) has been deprecated in documentation since Python 3.3 and at runtime since Python 3.13. Use the'w'format code (Py_UCS4) for Unicode characters instead.
- The
asyncio:-
!asyncio.iscoroutinefunctionis deprecated and will be removed in Python 3.16; useinspect.iscoroutinefunctioninstead. (Contributed by Jiahao Li and Kumar Aditya in122875.) -
asynciopolicy system is deprecated and will be removed in Python 3.16. In particular, the following classes and functions are deprecated:!asyncio.AbstractEventLoopPolicy!asyncio.DefaultEventLoopPolicy!asyncio.WindowsSelectorEventLoopPolicy!asyncio.WindowsProactorEventLoopPolicy!asyncio.get_event_loop_policy!asyncio.set_event_loop_policy
Users should use
asyncio.runorasyncio.Runnerwith loop_factory to use the desired event loop implementation.For example, to use
asyncio.SelectorEventLoopon Windows:import asyncio async def main(): ... asyncio.run(main(), loop_factory=asyncio.SelectorEventLoop)(Contributed by Kumar Aditya in
127949.)
-
builtins:- Bitwise inversion on boolean types,
~Trueor~Falsehas been deprecated since Python 3.12, as it produces surprising and unintuitive results (-2and-1). Usenot xinstead for the logical negation of a Boolean. In the rare case that you need the bitwise inversion of the underlying integer, convert tointexplicitly (~int(x)).
- Bitwise inversion on boolean types,
functools:- Calling the Python implementation of
functools.reducewith function or sequence as keyword arguments has been deprecated since Python 3.14.
- Calling the Python implementation of
logging:- Support for custom logging handlers with the strm argument is deprecated and scheduled for removal in Python 3.16. Define handlers with the stream argument instead. (Contributed by Mariusz Felisiak in
115032.)
- Support for custom logging handlers with the strm argument is deprecated and scheduled for removal in Python 3.16. Define handlers with the stream argument instead. (Contributed by Mariusz Felisiak in
mimetypes:- Valid extensions start with a '.' or are empty for
mimetypes.MimeTypes.add_type. Undotted extensions are deprecated and will raise aValueErrorin Python 3.16. (Contributed by Hugo van Kemenade in75223.)
- Valid extensions start with a '.' or are empty for
shutil:- The
!ExecErrorexception has been deprecated since Python 3.14. It has not been used by any function in!shutilsince Python 3.4, and is now an alias ofRuntimeError.
- The
symtable:- The
!symtable.Class.get_methodsmethod has been deprecated since Python 3.14.
- The
sys:- The
!_enablelegacywindowsfsencodingfunction has been deprecated since Python 3.13. Use thePYTHONLEGACYWINDOWSFSENCODINGenvironment variable instead.
- The
sysconfig:- The
!sysconfig.expand_makefile_varsfunction has been deprecated since Python 3.14. Use thevarsargument ofsysconfig.get_pathsinstead.
- The
tarfile:- The undocumented and unused
!TarInfo.tarfileattribute has been deprecated since Python 3.13.
- The undocumented and unused
这篇文档对你有帮助吗?
谢谢你的反馈!