Pending removal in Python 3.14¶
引入系統 (import system):
在模組上設定
__loader__
而沒有設定__spec__.loader
的做法已被棄用。在 Python 3.14 中,引入系統或標準函式庫將不再設定或考慮__loader__
。
argparse
:argparse.BooleanOptionalAction
的 type、choices 和 metavar 參數已被棄用,將在 3.14 中移除。 (由 Nikita Sobolev 於 gh-92248 貢獻。)ast
:自 Python 3.8 起,下列功能已在文件中被棄用,現在在存取或使用時會於 runtime 發出DeprecationWarning
,並將在 Python 3.14 中移除:ast.Num
ast.Str
ast.Bytes
ast.NameConstant
ast.Ellipsis
請改用
ast.Constant
。(由 Serhiy Storchaka 於 gh-90953 貢獻。)-
The child watcher classes
asyncio.MultiLoopChildWatcher
,asyncio.FastChildWatcher
,asyncio.AbstractChildWatcher
andasyncio.SafeChildWatcher
are deprecated and will be removed in Python 3.14. (Contributed by Kumar Aditya in gh-94597.)asyncio.set_child_watcher()
,asyncio.get_child_watcher()
,asyncio.AbstractEventLoopPolicy.set_child_watcher()
andasyncio.AbstractEventLoopPolicy.get_child_watcher()
are deprecated and will be removed in Python 3.14. (Contributed by Kumar Aditya in gh-94597.)預設事件迴圈策略的
get_event_loop()
方法現在會在沒有設定目前事件迴圈且決定建立一個時發出DeprecationWarning
。 (由 Serhiy Storchaka 和 Guido van Rossum 於 gh-100160 貢獻。)
collections.abc
: Deprecatedcollections.abc.ByteString
. PreferSequence
orBuffer
. For use in typing, prefer a union, likebytes | bytearray
, orcollections.abc.Buffer
. (Contributed by Shantanu Jain in gh-91896.)email
:已棄用email.utils.localtime()
中的 isdst 參數。(由 Alan Williams 於 gh-72346 貢獻。)importlib.abc
的已棄用類別:importlib.abc.ResourceReader
importlib.abc.Traversable
importlib.abc.TraversableResources
請改用
importlib.resources.abc
類別:(由 Jason R. Coombs 和 Hugo van Kemenade 貢獻於 gh-93963。)
itertools
有不以文件記錄、效率低下、過去常有 bug 且不一致的 copy、deepcopy 和 pickle 操作支援。將在 3.14 中移除以大幅減少程式碼量和維護負擔。 (由 Raymond Hettinger 於 gh-101588 貢獻。)multiprocessing
:預設的啟動方法將在 Linux、BSD 和其他非 macOS POSIX 平台上更改為更安全的 方法,目前'fork'
是預設值 (gh-84559)。對此增加一個 runtime 警告被認為太過擾人,因為 大多數程式碼不會在意。請使用get_context()
或set_start_method()
API 來明確指定你的程式碼何時需要'fork'
。請參閱 Contexts and start methods。pathlib
:已棄用is_relative_to()
和relative_to()
:額外引數的傳遞已被棄用。pkgutil
:find_loader()
和get_loader()
現在會引發DeprecationWarning
;請改用importlib.util.find_spec()
。 (由 Nikita Sobolev 於 gh-97850 貢獻。)pty
:master_open()
:請用pty.openpty()
。slave_open()
:請用pty.openpty()
。
-
version
andversion_info
.execute()
和executemany()
,如果使用 named placeholders 且 parameters 是序列而不是dict
。date 和 datetime 的適配器 (adapter)、date 和 timestamp 轉換器 (converter):請參閱
sqlite3
文件以獲得建議的替代方案。
types.CodeType
:自 3.10 起,存取co_lnotab
已在 PEP 626 中被棄用,並計劃在 3.12 中移除,但只在 3.12 中於適當時發出DeprecationWarning
。可能在 3.14 中移除。(由 Nikita Sobolev 於 gh-101866 貢獻。)typing
:typing.ByteString
, deprecated since Python 3.9, now causes aDeprecationWarning
to be emitted when it is used.urllib
:urllib.parse.Quoter
已被棄用:它並非預期的公開 API。(由 Gregory P. Smith 於 gh-88168 貢獻。)