Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Lib/_pyio.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
_setmode = None

import io
from io import (__all__, SEEK_SET, SEEK_CUR, SEEK_END)
from io import (__all__, SEEK_SET, SEEK_CUR, SEEK_END) # noqa

valid_seek_flags = {0, 1, 2} # Hardwired values
if hasattr(os, 'SEEK_HOLE') :
Expand Down
2 changes: 1 addition & 1 deletion Lib/code.py
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,7 @@ def interact(banner=None, readfunc=None, local=None, exitmsg=None, local_exit=Fa
console.raw_input = readfunc
else:
try:
import readline
import readline # noqa
except ImportError:
pass
console.interact(banner, exitmsg)
Expand Down
2 changes: 1 addition & 1 deletion Lib/codecs.py
Original file line number Diff line number Diff line change
Expand Up @@ -1129,4 +1129,4 @@ def make_encoding_map(decoding_map):
# package
_false = 0
if _false:
import encodings
import encodings # noqa
2 changes: 1 addition & 1 deletion Lib/collections/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
_collections_abc.MutableSequence.register(deque)

try:
from _collections import _deque_iterator
from _collections import _deque_iterator # noqa
except ImportError:
pass
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

test_collections passes for me if I remove this import. Does it need to stay? It was added in 52f96d3

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@erlend-aasland @kumaraditya303: Do you know/recall why this symbol is exposed?

Copy link
Member

@AlexWaygood AlexWaygood Jun 12, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, test_deque fails if the import is removed. I expected deque to be tested as part of test_collections, but apparently it has its own test file. Could you add a comment that it is (apparently) required to expose it in the collections module in order for deque iterators to be pickled?

======================================================================
ERROR: test_iterator_pickle (test.test_deque.TestBasic.test_iterator_pickle)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/alexw/dev/cpython/Lib/test/test_deque.py", line 640, in test_iterator_pickle
    dump = pickle.dumps((itorg, orig), proto)
_pickle.PicklingError: Can't pickle <class 'collections._deque_iterator'>: attribute lookup _deque_iterator on collections failed

----------------------------------------------------------------------

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, I added a comment.


Expand Down
4 changes: 2 additions & 2 deletions Lib/collections/abc.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
from _collections_abc import *
from _collections_abc import __all__
from _collections_abc import _CallableGenericAlias
from _collections_abc import __all__ # noqa
from _collections_abc import _CallableGenericAlias # noqa
2 changes: 1 addition & 1 deletion Lib/concurrent/futures/process.py
Original file line number Diff line number Diff line change
Expand Up @@ -589,7 +589,7 @@ def _check_system_limits():
raise NotImplementedError(_system_limited)
_system_limits_checked = True
try:
import multiprocessing.synchronize
import multiprocessing.synchronize # noqa
except ImportError:
_system_limited = (
"This Python build lacks multiprocessing.synchronize, usually due "
Expand Down
28 changes: 14 additions & 14 deletions Lib/ctypes/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@

__version__ = "1.1.0"

from _ctypes import Union, Structure, Array
from _ctypes import _Pointer
from _ctypes import CFuncPtr as _CFuncPtr
from _ctypes import __version__ as _ctypes_version
from _ctypes import RTLD_LOCAL, RTLD_GLOBAL
from _ctypes import ArgumentError
from _ctypes import SIZEOF_TIME_T
from _ctypes import Union, Structure, Array # noqa
from _ctypes import _Pointer # noqa
from _ctypes import CFuncPtr as _CFuncPtr # noqa
from _ctypes import __version__ as _ctypes_version # noqa
from _ctypes import RTLD_LOCAL, RTLD_GLOBAL # noqa
from _ctypes import ArgumentError # noqa
from _ctypes import SIZEOF_TIME_T # noqa

from struct import calcsize as _calcsize

Expand Down Expand Up @@ -138,9 +138,9 @@ class WinFunctionType(_CFuncPtr):
elif _os.name == "posix":
from _ctypes import dlopen as _dlopen

from _ctypes import sizeof, byref, addressof, alignment, resize
from _ctypes import get_errno, set_errno
from _ctypes import _SimpleCData
from _ctypes import sizeof, byref, addressof, alignment, resize # noqa
from _ctypes import get_errno, set_errno # noqa
from _ctypes import _SimpleCData # noqa

def _check_size(typ, typecode=None):
# Check if sizeof(ctypes_type) against struct.calcsize. This
Expand Down Expand Up @@ -252,7 +252,7 @@ class c_void_p(_SimpleCData):
class c_bool(_SimpleCData):
_type_ = "?"

from _ctypes import POINTER, pointer, _pointer_type_cache
from _ctypes import POINTER, pointer, _pointer_type_cache # noqa

class c_wchar_p(_SimpleCData):
_type_ = "Z"
Expand Down Expand Up @@ -492,7 +492,7 @@ def LoadLibrary(self, name):
oledll = LibraryLoader(OleDLL)

GetLastError = windll.kernel32.GetLastError
from _ctypes import get_last_error, set_last_error
from _ctypes import get_last_error, set_last_error # noqa

def WinError(code=None, descr=None):
if code is None:
Expand Down Expand Up @@ -568,8 +568,8 @@ def DllCanUnloadNow():
return 0 # S_OK
return ccom.DllCanUnloadNow()

from ctypes._endian import BigEndianStructure, LittleEndianStructure
from ctypes._endian import BigEndianUnion, LittleEndianUnion
from ctypes._endian import BigEndianStructure, LittleEndianStructure # noqa
from ctypes._endian import BigEndianUnion, LittleEndianUnion # noqa

# Fill in specifically-sized types
c_int8 = c_byte
Expand Down
4 changes: 2 additions & 2 deletions Lib/curses/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,9 @@ def start_color():
# Import Python has_key() implementation if _curses doesn't contain has_key()

try:
has_key
has_key # noqa
except NameError:
from .has_key import has_key
from .has_key import has_key # noqa

# Wrapper for the entire curses-based application. Runs a function which
# should be the rest of your curses-based application. If the application
Expand Down
4 changes: 2 additions & 2 deletions Lib/datetime.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
try:
from _datetime import *
from _datetime import __doc__
from _datetime import __doc__ # noqa
except ImportError:
from _pydatetime import *
from _pydatetime import __doc__
from _pydatetime import __doc__ # noqa

__all__ = ("date", "datetime", "time", "timedelta", "timezone", "tzinfo",
"MINYEAR", "MAXYEAR", "UTC")
8 changes: 4 additions & 4 deletions Lib/decimal.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,9 @@

try:
from _decimal import *
from _decimal import __version__
from _decimal import __libmpdec_version__
from _decimal import __version__ # noqa
from _decimal import __libmpdec_version__ # noqa
except ImportError:
from _pydecimal import *
from _pydecimal import __version__
from _pydecimal import __libmpdec_version__
from _pydecimal import __version__ # noqa
from _pydecimal import __libmpdec_version__ # noqa
2 changes: 1 addition & 1 deletion Lib/hashlib.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ def __hash_new(name, data=b'', **kwargs):

try:
# OpenSSL's scrypt requires OpenSSL 1.1+
from _hashlib import scrypt
from _hashlib import scrypt # noqa
except ImportError:
pass

Expand Down
28 changes: 14 additions & 14 deletions Lib/importlib/machinery.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
"""The machinery of importlib: finders, loaders, hooks, etc."""

from ._bootstrap import ModuleSpec
from ._bootstrap import BuiltinImporter
from ._bootstrap import FrozenImporter
from ._bootstrap_external import (SOURCE_SUFFIXES, DEBUG_BYTECODE_SUFFIXES,
OPTIMIZED_BYTECODE_SUFFIXES, BYTECODE_SUFFIXES,
EXTENSION_SUFFIXES)
from ._bootstrap_external import WindowsRegistryFinder
from ._bootstrap_external import PathFinder
from ._bootstrap_external import FileFinder
from ._bootstrap_external import SourceFileLoader
from ._bootstrap_external import SourcelessFileLoader
from ._bootstrap_external import ExtensionFileLoader
from ._bootstrap_external import AppleFrameworkLoader
from ._bootstrap_external import NamespaceLoader
from ._bootstrap import ModuleSpec # noqa
from ._bootstrap import BuiltinImporter # noqa
from ._bootstrap import FrozenImporter # noqa
from ._bootstrap_external import (SOURCE_SUFFIXES, DEBUG_BYTECODE_SUFFIXES, # noqa
OPTIMIZED_BYTECODE_SUFFIXES, BYTECODE_SUFFIXES, # noqa
EXTENSION_SUFFIXES) # noqa
from ._bootstrap_external import WindowsRegistryFinder # noqa
from ._bootstrap_external import PathFinder # noqa
from ._bootstrap_external import FileFinder # noqa
from ._bootstrap_external import SourceFileLoader # noqa
from ._bootstrap_external import SourcelessFileLoader # noqa
from ._bootstrap_external import ExtensionFileLoader # noqa
from ._bootstrap_external import AppleFrameworkLoader # noqa
from ._bootstrap_external import NamespaceLoader # noqa


def all_suffixes():
Expand Down
14 changes: 7 additions & 7 deletions Lib/importlib/util.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
"""Utility code for constructing importers, etc."""
from ._abc import Loader
from ._bootstrap import module_from_spec
from ._bootstrap import module_from_spec # noqa
from ._bootstrap import _resolve_name
from ._bootstrap import spec_from_loader
from ._bootstrap import spec_from_loader # noqa
from ._bootstrap import _find_spec
from ._bootstrap_external import MAGIC_NUMBER
from ._bootstrap_external import MAGIC_NUMBER # noqa
from ._bootstrap_external import _RAW_MAGIC_NUMBER
from ._bootstrap_external import cache_from_source
from ._bootstrap_external import decode_source
from ._bootstrap_external import source_from_cache
from ._bootstrap_external import spec_from_file_location
from ._bootstrap_external import cache_from_source # noqa
from ._bootstrap_external import decode_source # noqa
from ._bootstrap_external import source_from_cache # noqa
from ._bootstrap_external import spec_from_file_location # noqa

import _imp
import sys
Expand Down
2 changes: 1 addition & 1 deletion Lib/lzma.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
import io
import os
from _lzma import *
from _lzma import _encode_filter_properties, _decode_filter_properties
from _lzma import _encode_filter_properties, _decode_filter_properties # noqa
import _compression


Expand Down
2 changes: 1 addition & 1 deletion Lib/multiprocessing/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ def allow_connection_pickling(self):
'''
# This is undocumented. In previous versions of multiprocessing
# its only effect was to make socket objects inheritable on Windows.
from . import connection
from . import connection # noqa

def set_executable(self, executable):
'''Sets the path to a python.exe or pythonw.exe binary used to run
Expand Down
2 changes: 1 addition & 1 deletion Lib/multiprocessing/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import atexit
import threading # we want threading to install it's
# cleanup function before multiprocessing does
from subprocess import _args_from_interpreter_flags
from subprocess import _args_from_interpreter_flags # noqa

from . import process

Expand Down
4 changes: 2 additions & 2 deletions Lib/opcode.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
import _opcode
from _opcode import stack_effect

from _opcode_metadata import (_specializations, _specialized_opmap, opmap,
HAVE_ARGUMENT, MIN_INSTRUMENTED_OPCODE)
from _opcode_metadata import (_specializations, _specialized_opmap, opmap, # noqa
HAVE_ARGUMENT, MIN_INSTRUMENTED_OPCODE) # noqa
EXTENDED_ARG = opmap['EXTENDED_ARG']

opname = ['<%r>' % (op,) for op in range(max(opmap.values()) + 1)]
Expand Down
2 changes: 1 addition & 1 deletion Lib/operator.py
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,7 @@ def ixor(a, b):
except ImportError:
pass
else:
from _operator import __doc__
from _operator import __doc__ # noqa

# All of these "__func__ = func" assignments have to happen after importing
# from _operator to make sure they're set to the right function
Expand Down
2 changes: 1 addition & 1 deletion Lib/platform.py
Original file line number Diff line number Diff line change
Expand Up @@ -546,7 +546,7 @@ def java_ver(release='', vendor='', vminfo=('', '', ''), osinfo=('', '', '')):
warnings._deprecated('java_ver', remove=(3, 15))
# Import the needed APIs
try:
import java.lang
import java.lang # noqa
except ImportError:
return release, vendor, vminfo, osinfo

Expand Down
2 changes: 1 addition & 1 deletion Lib/pstats.py
Original file line number Diff line number Diff line change
Expand Up @@ -611,7 +611,7 @@ def f8(x):
if __name__ == '__main__':
import cmd
try:
import readline
import readline # noqa
except ImportError:
pass

Expand Down
5 changes: 3 additions & 2 deletions Lib/pydoc.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,9 @@ class or function within a module or module in a package. If the
from reprlib import Repr
from traceback import format_exception_only

from _pyrepl.pager import (get_pager, plain, escape_less, pipe_pager,
plain_pager, tempfile_pager, tty_pager)
from _pyrepl.pager import (get_pager, escape_less, pipe_pager,
plain_pager, tempfile_pager, tty_pager,
plain) # noqa


# --------------------------------------------------------- old names
Expand Down
2 changes: 1 addition & 1 deletion Lib/re/_constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

MAGIC = 20230612

from _sre import MAXREPEAT, MAXGROUPS
from _sre import MAXREPEAT, MAXGROUPS # noqa

# SRE standard exception (access as sre.error)
# should this really be here?
Expand Down
12 changes: 6 additions & 6 deletions Lib/site.py
Original file line number Diff line number Diff line change
Expand Up @@ -485,10 +485,10 @@ def register_readline():
"""
import atexit
try:
import readline
import rlcompleter
import _pyrepl.readline
import _pyrepl.unix_console
import readline # noqa
import rlcompleter # noqa
import _pyrepl.readline # noqa
import _pyrepl.unix_console # noqa
except ImportError:
return

Expand Down Expand Up @@ -603,7 +603,7 @@ def execsitecustomize():
"""Run custom site specific code, if available."""
try:
try:
import sitecustomize
import sitecustomize # noqa
except ImportError as exc:
if exc.name == 'sitecustomize':
pass
Expand All @@ -623,7 +623,7 @@ def execusercustomize():
"""Run custom user specific code, if available."""
try:
try:
import usercustomize
import usercustomize # noqa
except ImportError as exc:
if exc.name == 'usercustomize':
pass
Expand Down
2 changes: 1 addition & 1 deletion Lib/sqlite3/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ def main(*args):
# No SQL provided; start the REPL.
console = SqliteInteractiveConsole(con)
try:
import readline
import readline # noqa
except ImportError:
pass
console.interact(banner, exitmsg="")
Expand Down
20 changes: 10 additions & 10 deletions Lib/ssl.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,26 +99,26 @@

import _ssl # if we can't import it, let the error propagate

from _ssl import OPENSSL_VERSION_NUMBER, OPENSSL_VERSION_INFO, OPENSSL_VERSION
from _ssl import _SSLContext, MemoryBIO, SSLSession
from _ssl import OPENSSL_VERSION_NUMBER, OPENSSL_VERSION_INFO, OPENSSL_VERSION # noqa
from _ssl import _SSLContext, MemoryBIO, SSLSession # noqa
from _ssl import (
SSLError, SSLZeroReturnError, SSLWantReadError, SSLWantWriteError,
SSLSyscallError, SSLEOFError, SSLCertVerificationError
SSLError, SSLZeroReturnError, SSLWantReadError, SSLWantWriteError, # noqa
SSLSyscallError, SSLEOFError, SSLCertVerificationError # noqa
)
from _ssl import txt2obj as _txt2obj, nid2obj as _nid2obj
from _ssl import RAND_status, RAND_add, RAND_bytes
from _ssl import RAND_status, RAND_add, RAND_bytes # noqa
try:
from _ssl import RAND_egd
from _ssl import RAND_egd # noqa
except ImportError:
# RAND_egd is not supported on some platforms
pass


from _ssl import (
HAS_SNI, HAS_ECDH, HAS_NPN, HAS_ALPN, HAS_SSLv2, HAS_SSLv3, HAS_TLSv1,
HAS_TLSv1_1, HAS_TLSv1_2, HAS_TLSv1_3, HAS_PSK
HAS_SNI, HAS_ECDH, HAS_NPN, HAS_ALPN, HAS_SSLv2, HAS_SSLv3, HAS_TLSv1, # noqa
HAS_TLSv1_1, HAS_TLSv1_2, HAS_TLSv1_3, HAS_PSK # noqa
)
from _ssl import _DEFAULT_CIPHERS, _OPENSSL_API_VERSION
from _ssl import _DEFAULT_CIPHERS, _OPENSSL_API_VERSION # noqa

_IntEnum._convert_(
'_SSLMethod', __name__,
Expand Down Expand Up @@ -255,7 +255,7 @@ class _TLSMessageType:


if sys.platform == "win32":
from _ssl import enum_certificates, enum_crls
from _ssl import enum_certificates, enum_crls # noqa

from socket import socket, SOCK_STREAM, create_connection
from socket import SOL_SOCKET, SO_TYPE, _GLOBAL_DEFAULT_TIMEOUT
Expand Down
4 changes: 2 additions & 2 deletions Lib/struct.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@
]

from _struct import *
from _struct import _clearcache
from _struct import __doc__
from _struct import _clearcache # noqa
from _struct import __doc__ # noqa
Loading