From edee8d3157ffc59a33b30166a492261c2d629e14 Mon Sep 17 00:00:00 2001 From: Stephen Morton Date: Sun, 8 Dec 2024 14:10:41 -0800 Subject: [PATCH 1/2] add CLONE_NEWTIME to os.__all__ (#13221) --- .github/workflows/daily.yml | 4 +++- .github/workflows/stubtest_stdlib.yml | 4 +++- stdlib/@tests/stubtest_allowlists/linux-py312.txt | 10 ---------- stdlib/@tests/stubtest_allowlists/linux-py313.txt | 8 -------- stdlib/os/__init__.pyi | 1 + 5 files changed, 7 insertions(+), 20 deletions(-) diff --git a/.github/workflows/daily.yml b/.github/workflows/daily.yml index 548807e813cb..8ca4191afb5a 100644 --- a/.github/workflows/daily.yml +++ b/.github/workflows/daily.yml @@ -34,7 +34,9 @@ jobs: runs-on: ${{ matrix.os }} strategy: matrix: - os: ["ubuntu-latest", "windows-latest", "macos-latest"] + # As of 2024-10-18, ubuntu-latest can refer to different Ubuntu versions, + # which can can cause problems with os module constants. + os: ["ubuntu-24.04", "windows-latest", "macos-latest"] python-version: ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13"] fail-fast: false diff --git a/.github/workflows/stubtest_stdlib.yml b/.github/workflows/stubtest_stdlib.yml index 7224f0ea6380..9ae15305b06c 100644 --- a/.github/workflows/stubtest_stdlib.yml +++ b/.github/workflows/stubtest_stdlib.yml @@ -30,7 +30,9 @@ jobs: runs-on: ${{ matrix.os }} strategy: matrix: - os: ["ubuntu-latest", "windows-latest", "macos-latest"] + # As of 2024-10-18, ubuntu-latest can refer to different Ubuntu versions, + # which can can cause problems with os module constants. + os: ["ubuntu-24.04", "windows-latest", "macos-latest"] python-version: ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13"] fail-fast: false diff --git a/stdlib/@tests/stubtest_allowlists/linux-py312.txt b/stdlib/@tests/stubtest_allowlists/linux-py312.txt index a2c251dcd47c..a4083aa22ed7 100644 --- a/stdlib/@tests/stubtest_allowlists/linux-py312.txt +++ b/stdlib/@tests/stubtest_allowlists/linux-py312.txt @@ -1,13 +1,3 @@ -# ======= -# >= 3.12 -# ======= - -# These seem like they should be available on Linux, but they're not -# on GitHub Actions runners for some reason. -os.CLONE_NEWTIME -posix.CLONE_NEWTIME - - # ============================================================= # Allowlist entries that cannot or should not be fixed; <= 3.12 # ============================================================= diff --git a/stdlib/@tests/stubtest_allowlists/linux-py313.txt b/stdlib/@tests/stubtest_allowlists/linux-py313.txt index 046fd9e54c00..e69de29bb2d1 100644 --- a/stdlib/@tests/stubtest_allowlists/linux-py313.txt +++ b/stdlib/@tests/stubtest_allowlists/linux-py313.txt @@ -1,8 +0,0 @@ -# ======= -# >= 3.12 -# ======= - -# These seem like they should be available on Linux, but they're not -# on GitHub Actions runners for some reason. -os.CLONE_NEWTIME -posix.CLONE_NEWTIME diff --git a/stdlib/os/__init__.pyi b/stdlib/os/__init__.pyi index 98260b14e7ed..64691b514a48 100644 --- a/stdlib/os/__init__.pyi +++ b/stdlib/os/__init__.pyi @@ -231,6 +231,7 @@ if sys.platform == "linux" and sys.version_info >= (3, 12): "CLONE_NEWNET", "CLONE_NEWNS", "CLONE_NEWPID", + "CLONE_NEWTIME", "CLONE_NEWUSER", "CLONE_NEWUTS", "CLONE_SIGHAND", From 4664a1406ed4a6174c809933395ec4703a99fc90 Mon Sep 17 00:00:00 2001 From: Stephen Morton Date: Mon, 9 Dec 2024 14:16:15 -0800 Subject: [PATCH 2/2] move deliberately missing things to the appropriate section (#13203) --- stdlib/@tests/stubtest_allowlists/common.txt | 146 ++++++++++--------- 1 file changed, 77 insertions(+), 69 deletions(-) diff --git a/stdlib/@tests/stubtest_allowlists/common.txt b/stdlib/@tests/stubtest_allowlists/common.txt index 8a984022920d..acff6703b57d 100644 --- a/stdlib/@tests/stubtest_allowlists/common.txt +++ b/stdlib/@tests/stubtest_allowlists/common.txt @@ -104,16 +104,27 @@ idlelib # Module members that exist at runtime, but are deliberately missing from stubs # ============================================================================= +_collections_abc.Mapping.__reversed__ # set to None at runtime for a better error message + +# Adding these reflected dunders to `typing.AbstractSet` causes a large number of false-positives. See #7414. +_collections_abc.Set.__rand__ +_collections_abc.Set.__ror__ +_collections_abc.Set.__rsub__ +_collections_abc.Set.__rxor__ + # Undocumented implementation details of a deprecated class _frozen_importlib_external.WindowsRegistryFinder.DEBUG_BUILD _frozen_importlib_external.WindowsRegistryFinder.REGISTRY_KEY _frozen_importlib_external.WindowsRegistryFinder.REGISTRY_KEY_DEBUG -importlib._bootstrap_external.WindowsRegistryFinder.DEBUG_BUILD -importlib._bootstrap_external.WindowsRegistryFinder.REGISTRY_KEY -importlib._bootstrap_external.WindowsRegistryFinder.REGISTRY_KEY_DEBUG -importlib.machinery.WindowsRegistryFinder.DEBUG_BUILD -importlib.machinery.WindowsRegistryFinder.REGISTRY_KEY -importlib.machinery.WindowsRegistryFinder.REGISTRY_KEY_DEBUG + +builtins.OSError.characters_written # GetSetDescriptor that always raises AttributeError +builtins.float.__getformat__ # Internal method for CPython test suite + +# These super() dunders don't seem to be particularly useful, +# and having them pop up on autocomplete suggestions would be annoying +builtins.super.__self__ +builtins.super.__self_class__ +builtins.super.__thisclass__ # Undocumented implementation details email.contentmanager.get_and_fixup_unknown_message_content @@ -123,7 +134,19 @@ email.contentmanager.get_text_content email.contentmanager.set_bytes_content email.contentmanager.set_message_content email.contentmanager.set_text_content + ftplib.FTP.trust_server_pasv_ipv4_address # Dangerous to use, intentionally undocumented #6154 +hmac.HMAC.blocksize # use block_size instead + +# Undocumented implementation details of a deprecated class +importlib._bootstrap_external.WindowsRegistryFinder.DEBUG_BUILD +importlib._bootstrap_external.WindowsRegistryFinder.REGISTRY_KEY +importlib._bootstrap_external.WindowsRegistryFinder.REGISTRY_KEY_DEBUG +importlib.machinery.WindowsRegistryFinder.DEBUG_BUILD +importlib.machinery.WindowsRegistryFinder.REGISTRY_KEY +importlib.machinery.WindowsRegistryFinder.REGISTRY_KEY_DEBUG + +# Undocumented implementation details profile.Profile.dispatch profile.Profile.fake_code profile.Profile.fake_frame @@ -135,10 +158,54 @@ profile.Profile.trace_dispatch_i profile.Profile.trace_dispatch_l profile.Profile.trace_dispatch_mac profile.Profile.trace_dispatch_return -turtle.ScrolledCanvas.adjustScrolls -turtle.ScrolledCanvas.onResize -wave.Wave_read.initfp -wave.Wave_write.initfp + +re.Pattern.scanner # Undocumented and not useful. #6405 + +# Missing aliases to existing methods that not many people seem to use. +# Complicated multiple inheritance, confuses type checkers. +tkinter.Grid.bbox +tkinter.Grid.columnconfigure +tkinter.Grid.config +tkinter.Grid.configure +tkinter.Grid.forget +tkinter.Grid.grid_bbox +tkinter.Grid.grid_columnconfigure +tkinter.Grid.grid_location +tkinter.Grid.grid_propagate +tkinter.Grid.grid_rowconfigure +tkinter.Grid.grid_size +tkinter.Grid.grid_slaves +tkinter.Grid.info +tkinter.Grid.propagate +tkinter.Grid.rowconfigure +tkinter.Grid.slaves +tkinter.Pack.config +tkinter.Pack.configure +tkinter.Pack.info +tkinter.Pack.pack_propagate +tkinter.Pack.pack_slaves +tkinter.Pack.slaves +tkinter.Place.config +tkinter.Place.configure +tkinter.Place.forget +tkinter.Place.place_slaves +tkinter.Place.slaves + +turtle.ScrolledCanvas.adjustScrolls # Undocumented implementation detail +turtle.ScrolledCanvas.onResize # Undocumented implementation detail +typing_extensions.NewType.__mro_entries__ # just exists for an error message +uuid.bytes_ # Attributes that are intended to be private +uuid.int_ # Attributes that are intended to be private +wave.Wave_read.initfp # Undocumented implementation detail +wave.Wave_write.initfp # Undocumented implementation detail +_?weakref\.ProxyType\.__bytes__ # Doesn't actually exist + +# Undocumented and have a comment in the source code saying "State variables (don't mess with these)" +wsgiref.handlers.BaseHandler.bytes_sent +wsgiref.handlers.BaseHandler.headers +wsgiref.handlers.BaseHandler.headers_sent +wsgiref.handlers.BaseHandler.result +wsgiref.handlers.BaseHandler.status # ===================================== @@ -189,16 +256,9 @@ _collections_abc.Generator.gi_code _collections_abc.Generator.gi_frame _collections_abc.Generator.gi_running _collections_abc.Generator.gi_yieldfrom -_collections_abc.Mapping.__reversed__ # set to None at runtime for a better error message _collections_abc.Mapping.get # Adding None to the Union messed up mypy _collections_abc.Sequence.index # Supporting None in end is not mandatory -# Adding these reflected dunders to `typing.AbstractSet` causes a large number of false-positives. See #7414. -_collections_abc.Set.__rand__ -_collections_abc.Set.__ror__ -_collections_abc.Set.__rsub__ -_collections_abc.Set.__rxor__ - _ctypes.CFuncPtr # stubtest erroneously thinks it can't be subclassed # runtime is *args, **kwargs due to a wrapper; we have more accurate signatures in the stubs @@ -239,20 +299,12 @@ asyncio.locks.Condition.acquire asyncio.locks.Condition.locked asyncio.locks.Condition.release -builtins.OSError.characters_written # GetSetDescriptor that always raises AttributeError -builtins.float.__getformat__ # Internal method for CPython test suite builtins.memoryview.__contains__ # C type that implements __getitem__ builtins.object.__init__ # default C signature is incorrect builtins.reveal_locals # Builtins that type checkers pretends exist builtins.reveal_type # Builtins that type checkers pretends exist builtins.type.__dict__ # read-only but not actually a property; stubtest thinks it's a mutable attribute. -# These super() dunders don't seem to be particularly useful, -# and having them pop up on autocomplete suggestions would be annoying -builtins.super.__self__ -builtins.super.__self_class__ -builtins.super.__thisclass__ - # The following CodecInfo properties are added in __new__ codecs.CodecInfo.decode codecs.CodecInfo.encode @@ -313,7 +365,6 @@ enum.auto.__or__ # enum.auto is magic, see comments enum.auto.__and__ # enum.auto is magic, see comments enum.auto.__xor__ # enum.auto is magic, see comments _?hashlib.scrypt # Raises TypeError if salt, n, r or p are None -hmac.HMAC.blocksize # use block_size instead imaplib.IMAP4_SSL.ssl # Depends on the existence and flags of SSL # runtime is *args, **kwargs due to a wrapper; we have more accurate signatures in the stubs @@ -399,7 +450,6 @@ os._wrap_close.writelines # Methods that come from __getattr__() at runtime pickle._Pickler\..* # Best effort typing for undocumented internals pickle._Unpickler\..* # Best effort typing for undocumented internals _?queue.SimpleQueue.__init__ # C signature is broader than what is actually accepted -re.Pattern.scanner # Undocumented and not useful. #6405 ssl.PROTOCOL_SSLv2 # Depends on the existence and flags of SSL ssl.PROTOCOL_SSLv3 # Depends on the existence and flags of SSL sys.implementation # Actually SimpleNamespace but then you wouldn't have convenient attributes @@ -411,36 +461,6 @@ threading.Condition.release # Condition functions are exported in __init__ # Marking it as a function will make it impossible for users to use the Lock type as an annotation. threading.RLock -# Missing aliases to existing methods that not many people seem to use. -# Complicated multiple inheritance, confuses type checkers. -tkinter.Grid.bbox -tkinter.Grid.columnconfigure -tkinter.Grid.config -tkinter.Grid.configure -tkinter.Grid.forget -tkinter.Grid.grid_bbox -tkinter.Grid.grid_columnconfigure -tkinter.Grid.grid_location -tkinter.Grid.grid_propagate -tkinter.Grid.grid_rowconfigure -tkinter.Grid.grid_size -tkinter.Grid.grid_slaves -tkinter.Grid.info -tkinter.Grid.propagate -tkinter.Grid.rowconfigure -tkinter.Grid.slaves -tkinter.Pack.config -tkinter.Pack.configure -tkinter.Pack.info -tkinter.Pack.pack_propagate -tkinter.Pack.pack_slaves -tkinter.Pack.slaves -tkinter.Place.config -tkinter.Place.configure -tkinter.Place.forget -tkinter.Place.place_slaves -tkinter.Place.slaves - # Methods that come from __getattr__() at runtime tkinter.Tk.adderrorinfo tkinter.Tk.call @@ -518,7 +538,6 @@ typing_extensions\.NamedTuple typing._SpecialForm.__call__ # Typing-related weirdness typing._SpecialForm.__init__ # Typing-related weirdness -typing_extensions.NewType.__mro_entries__ # just exists for an error message # These are abstract properties at runtime, # but marking them as such in the stub breaks half the the typed-Python ecosystem (see #8726) @@ -551,25 +570,14 @@ unittest.runner._WritelnDecorator.write # Methods that come from __getattr__() urllib.response.addbase.write # Methods that come from __getattr__() at runtime urllib.response.addbase.writelines # Methods that come from __getattr__() at runtime urllib.request.HTTPPasswordMgrWithPriorAuth.__init__ # Args are passed as is to super, so super args are specified -uuid.bytes_ # Attributes that are intended to be private -uuid.int_ # Attributes that are intended to be private _?weakref\.CallableProxyType\.__getattr__ # Should have all attributes of proxy _?weakref\.(ref|ReferenceType)\.__init__ # C implementation has incorrect signature _?weakref\.(ref|ReferenceType)\.__call__ # C function default annotation is wrong -_?weakref\.ProxyType\.__bytes__ # Doesn't actually exist _?weakref\.ProxyType\.__getattr__ # Should have all attributes of proxy weakref.WeakValueDictionary.setdefault # has a default value for the "default" argument, but always errors out if no value is supplied for the parameter by the user webbrowser.UnixBrowser.remote_action # Always overridden in inheriting class webbrowser.UnixBrowser.remote_action_newtab # Always overridden in inheriting class webbrowser.UnixBrowser.remote_action_newwin # Always overridden in inheriting class - -# Undocumented and have a comment in the source code saying "State variables (don't mess with these)" -wsgiref.handlers.BaseHandler.bytes_sent -wsgiref.handlers.BaseHandler.headers -wsgiref.handlers.BaseHandler.headers_sent -wsgiref.handlers.BaseHandler.result -wsgiref.handlers.BaseHandler.status - xml.__all__ # __all__-related weirdness (see #6523) xml.dom # __all__-related weirdness (see #6523) xml.etree # __all__-related weirdness (see #6523)