Pending removal in Python 3.16¶
The import system:
Setting
__loader__on a module while failing to set__spec__.loaderis deprecated. In Python 3.16,__loader__will cease to be set or taken into consideration by the import system or the standard library.Setting
__package__on a module while failing to set__spec__.parentis deprecated. In Python 3.16,__package__will cease to be taken into consideration by the import system or standard library. (gh-97879)
-
asynciopolicy system is deprecated and will be removed in Python 3.16. In particular, the following classes and functions are deprecated:Users should use
asyncio.run()orasyncio.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 gh-127949.)
-
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)).