Deprecations — Python 3.15.2 documentation
Navigation index modules | next | previous | Python » 3.15.2 documentation » Deprecations | Theme | Deprecations ¶ Pending removal in Python 3.16 ¶ The import system: Setting __loader__ on a module while failing to set __spec__.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. 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. asyncio : asyncio.iscoroutinefunction() is deprecated and will be removed in Python 3.16; use inspect.iscoroutinefunction() instead. (Contributed by Jiahao Li and Kumar Aditya in gh-122875 .) asyncio policy 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.run() or asyncio.Runner with loop_factory to use the desired event loop implementation.
For example, to use asyncio.SelectorEventLoop on Windows: import asyncio async def main (): ... asyncio . run ( main (), loop_factory = asyncio . SelectorEventLoop ) (Contributed by Kumar Aditya in gh-127949 .) builtins : Bitwise inversion on boolean types, ~True or ~False has been deprecated since Python 3.12, as it produces surprising and unintuitive results ( -2 and -1 ). Use not x instead for the logical negation of a Boolean.
In the rare case that you need the bitwise inversion of the underlying integer, convert to int explicitly ( ~int(x) ). functools : Calling the Python implementation of functools.reduce() with function or sequence as keyword arguments has been deprecated since Python 3.14. 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 gh-115032 .) mimetypes : Valid extensions start with a '.' or are empty for mimetypes.MimeTypes.add_type() .
Undotted extensions are deprecated and will raise a ValueError in Python 3.16. (Contributed by Hugo van Kemenade in gh-75223 .) shutil : The ExecError exception has been deprecated since Python 3.14. It has not been used by any function in shutil since Python 3.4, and is now an alias of RuntimeError . symtable : The Class.get_methods method has been deprecated since Python 3.14. sys : The _enablelegacywindowsfsencoding() function has been deprecated since Python 3.13.
Use the PYTHONLEGACYWINDOWSFSENCODING environment variable instead. sysconfig : The sysconfig.expand_makefile_vars() function has been deprecated since Python 3.14. Use the vars argument of sysconfig.get_paths() instead. tarfile : The undocumented and unused TarFile.tarfile attribute has been deprecated since Python 3.13. Pending removal in Python 3.17 ¶ datetime : strptime() calls using a format string containing %e (day of month) without a year.
This has been deprecated since Python 3.15. (Contributed by Stan Ulbrych in gh-70647 .) collections.abc : collections.abc.ByteString is scheduled for removal in Python 3.17. Use isinstance(obj, collections.abc.Buffer) to test if obj implements the buffer protocol at runtime. For use in type annotations, either use Buffer or a union that explicitly specifies the types your code supports (e.g., bytes | bytearray | memoryview ).
ByteString was originally intended to be an abstract class that would serve as a supertype of both bytes and bytearray . However, since the ABC never had any methods, knowing that an object was an instance of ByteString never actually told you anything useful about the object. Other common buffer types such as memoryview were also never understood as subtypes of ByteString (either at runtime or by static type checkers).
See PEP 688 for more details. (Contributed by Shantanu Jain in gh-91896 .) encodings : Passing non-ascii encoding names to encodings.normalize_encoding() is deprecated and scheduled for removal in Python 3.17. (Contributed by Stan Ulbrych in gh-136702 .) profile : The profile module is deprecated and will be removed in Python 3.17. Use profiling.tracing instead, which provides a compatible API. See PEP 799 for details. (Contributed by Pablo Galindo and László Kiss Kollár in gh-138122 .) webbrowser : webbrowser.MacOSXOSAScript is deprecated in favour of webbrowser.MacOS . ( gh-137586 ) typing : Before Python 3.14, old-style unions were implemented using the private class typing._UnionGenericAlias .
This class is no longer needed for the implementation, but it has been retained for backward compatibility, with removal scheduled for Python 3.17. Users should use documented introspection helpers like typing.get_origin() and typing.get_args() instead of relying on private implementation details. typing.ByteString , deprecated since Python 3.9, is scheduled for removal in Python 3.17. Use isinstance(obj, collections.abc.Buffer) to test if obj implements the buffer protocol at runtime.
For use in type annotations, either use Buffer or a union that explicitly specifies the types your code supports (e.g., bytes | bytearray | memoryview ). ByteString was originally intended to be an abstract class that would serve as a supertype of both bytes and bytearray . However, since the ABC never had any methods, knowing that an object was an instance of ByteString never actually told you anything useful about the object.
Other common buffer types such as memoryview were also never understood as subtypes of ByteString (either at runtime or by static type checkers). See PEP 688 for more details. (Contributed by Shantanu Jain in gh-91896 .) tkinter : The tkinter.Variable methods trace_variable() , trace() (an alias of trace_variable() ), trace_vdelete() and trace_vinfo() , deprecated since Python 3.14, are scheduled for removal in Python 3.17.
Use trace_add() , trace_remove() and trace_info() instead. (Contributed by Serhiy Storchaka in gh-120220 .) Pending removal in Python 3.18 ¶ No longer accept a boolean value when a file descriptor is expected. (Contributed by Serhiy Storchaka in gh-82626 .) decimal : The non-standard and undocumented Decimal format specifier 'N' , which is only supported in the decimal module's C implementation, has been deprecated since Python 3.13. (Contributed by Serhiy Storchaka in gh-89902 .) PEP 829 ਵੱਲੋਂ ਪਰਿਭਾਸ਼ਿਤ ਕੀਤੀਆਂ ਗਈਆਂ ਡਿਪ੍ਰੀਕੇਸ਼ਨਾਂ: import lines in name .pth files are silently ignored. (ਬੈਰੀ ਵਾਰਸਾ ਦੁਆਰਾ ਯੋਗਦਾਨ, gh-148641 ।) ਪਾਈਥਨ 3.19 ਵਿੱਚ ਹਟਾਏ ਜਾਣ ਦੀ ਉਡੀਕ ਵਿੱਚ ¶ ctypes : ਗੈਰ-ਵਿੰਡੋਜ਼ ਪਲੇਟਫਾਰਮਾਂ 'ਤੇ ਸਿਰਫ਼ _pack_ ਨੂੰ ਸੈੱਟ ਕਰਕੇ, ਪਰ _layout_ ਨੂੰ ਨਹੀਂ, ਅਸਪਸ਼ਟ ਤੌਰ 'ਤੇ MSVC-ਅਨੁਕੂਲ struct ਲੇਆਉਟ ਵੱਲ ਸਵਿੱਚ ਕਰਨਾ। hashlib : new() ਜਾਂ md5() ਅਤੇ sha256() ਵਰਗੇ ਹੈਸ਼ ਫੰਕਸ਼ਨ ਕੰਸਟਰਕਟਰਾਂ ਵਿੱਚ, ਉਹਨਾਂ ਦੇ ਵਿਕਲਪਿਕ initial data ਪੈਰਾਮੀਟਰ ਨੂੰ ਵੱਖ-ਵੱਖ hashlib ਇੰਪਲੀਮੇਂਟੇਸ਼ਨਾਂ ਵਿੱਚ data= ਜਾਂ string= ਨਾਮਕ ਕੀਵਰਡ ਆਰਗੂਮੈਂਟ ਵਜੋਂ ਵੀ ਭੇਜਿਆ ਜਾ ਸਕਦਾ ਹੈ। string ਕੀਵਰਡ ਆਰਗੂਮੈਂਟ ਨਾਮ ਲਈ ਸਹਾਇਤਾ ਹੁਣ ਡਿਪ੍ਰੀਕੇਟ ਕੀਤੀ ਗਈ ਹੈ ਅਤੇ Python 3.19 ਵਿੱਚ ਇਸਨੂੰ ਹਟਾਉਣ ਦੀ ਯੋਜਨਾ ਹੈ। Before Python 3.13, the string keyword parameter w
The rest of this page is on the live site.