mirror of
https://github.com/python/cpython.git
synced 2025-11-25 04:34:37 +00:00
unused imports, pep8
This commit is contained in:
parent
6f73874edd
commit
4b42ff609d
2 changed files with 12 additions and 12 deletions
|
|
@ -69,7 +69,7 @@ def _r_long(int_bytes):
|
||||||
def _path_join(*args):
|
def _path_join(*args):
|
||||||
"""Replacement for os.path.join."""
|
"""Replacement for os.path.join."""
|
||||||
return path_sep.join(x[:-len(path_sep)] if x.endswith(path_sep) else x
|
return path_sep.join(x[:-len(path_sep)] if x.endswith(path_sep) else x
|
||||||
for x in args if x)
|
for x in args if x)
|
||||||
|
|
||||||
|
|
||||||
def _path_exists(path):
|
def _path_exists(path):
|
||||||
|
|
@ -406,14 +406,16 @@ class _LoaderBasics:
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
if _r_long(raw_timestamp) != source_mtime:
|
if _r_long(raw_timestamp) != source_mtime:
|
||||||
raise ImportError("bytecode is stale for {}".format(fullname))
|
raise ImportError(
|
||||||
|
"bytecode is stale for {}".format(fullname))
|
||||||
try:
|
try:
|
||||||
source_size = source_stats['size'] & 0xFFFFFFFF
|
source_size = source_stats['size'] & 0xFFFFFFFF
|
||||||
except KeyError:
|
except KeyError:
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
if _r_long(raw_size) != source_size:
|
if _r_long(raw_size) != source_size:
|
||||||
raise ImportError("bytecode is stale for {}".format(fullname))
|
raise ImportError(
|
||||||
|
"bytecode is stale for {}".format(fullname))
|
||||||
# Can't return the code object as errors from marshal loading need to
|
# Can't return the code object as errors from marshal loading need to
|
||||||
# propagate even when source is available.
|
# propagate even when source is available.
|
||||||
return data[12:]
|
return data[12:]
|
||||||
|
|
@ -519,7 +521,7 @@ class SourceLoader(_LoaderBasics):
|
||||||
code_object = compile(source_bytes, source_path, 'exec',
|
code_object = compile(source_bytes, source_path, 'exec',
|
||||||
dont_inherit=True)
|
dont_inherit=True)
|
||||||
if (not sys.dont_write_bytecode and bytecode_path is not None and
|
if (not sys.dont_write_bytecode and bytecode_path is not None and
|
||||||
source_mtime is not None):
|
source_mtime is not None):
|
||||||
# If e.g. Jython ever implements imp.cache_from_source to have
|
# If e.g. Jython ever implements imp.cache_from_source to have
|
||||||
# their own cached file format, this block of code will most likely
|
# their own cached file format, this block of code will most likely
|
||||||
# throw an exception.
|
# throw an exception.
|
||||||
|
|
@ -890,7 +892,7 @@ class _ImportLockContext:
|
||||||
|
|
||||||
def _resolve_name(name, package, level):
|
def _resolve_name(name, package, level):
|
||||||
"""Resolve a relative module name to an absolute one."""
|
"""Resolve a relative module name to an absolute one."""
|
||||||
bits = package.rsplit('.', level-1)
|
bits = package.rsplit('.', level - 1)
|
||||||
if len(bits) < level:
|
if len(bits) < level:
|
||||||
raise ValueError('attempted relative import beyond top-level package')
|
raise ValueError('attempted relative import beyond top-level package')
|
||||||
base = bits[0]
|
base = bits[0]
|
||||||
|
|
@ -1010,7 +1012,7 @@ def _handle_fromlist(module, fromlist, import_):
|
||||||
fromlist = list(fromlist)
|
fromlist = list(fromlist)
|
||||||
fromlist.remove('*')
|
fromlist.remove('*')
|
||||||
fromlist.extend(module.__all__)
|
fromlist.extend(module.__all__)
|
||||||
for x in (y for y in fromlist if not hasattr(module,y)):
|
for x in (y for y in fromlist if not hasattr(module, y)):
|
||||||
try:
|
try:
|
||||||
import_('{0}.{1}'.format(module.__name__, x))
|
import_('{0}.{1}'.format(module.__name__, x))
|
||||||
except ImportError:
|
except ImportError:
|
||||||
|
|
|
||||||
|
|
@ -1,15 +1,11 @@
|
||||||
"""Abstract base classes related to import."""
|
"""Abstract base classes related to import."""
|
||||||
from . import _bootstrap
|
from . import _bootstrap
|
||||||
from . import machinery
|
from . import machinery
|
||||||
from . import util
|
|
||||||
import abc
|
import abc
|
||||||
import imp
|
import imp
|
||||||
import io
|
|
||||||
import marshal
|
import marshal
|
||||||
import os.path
|
|
||||||
import sys
|
import sys
|
||||||
import tokenize
|
import tokenize
|
||||||
import types
|
|
||||||
import warnings
|
import warnings
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -256,7 +252,8 @@ class PyPycLoader(PyLoader):
|
||||||
try:
|
try:
|
||||||
magic = data[:4]
|
magic = data[:4]
|
||||||
if len(magic) < 4:
|
if len(magic) < 4:
|
||||||
raise ImportError("bad magic number in {}".format(fullname))
|
raise ImportError(
|
||||||
|
"bad magic number in {}".format(fullname))
|
||||||
raw_timestamp = data[4:8]
|
raw_timestamp = data[4:8]
|
||||||
if len(raw_timestamp) < 4:
|
if len(raw_timestamp) < 4:
|
||||||
raise EOFError("bad timestamp in {}".format(fullname))
|
raise EOFError("bad timestamp in {}".format(fullname))
|
||||||
|
|
@ -264,7 +261,8 @@ class PyPycLoader(PyLoader):
|
||||||
bytecode = data[8:]
|
bytecode = data[8:]
|
||||||
# Verify that the magic number is valid.
|
# Verify that the magic number is valid.
|
||||||
if imp.get_magic() != magic:
|
if imp.get_magic() != magic:
|
||||||
raise ImportError("bad magic number in {}".format(fullname))
|
raise ImportError(
|
||||||
|
"bad magic number in {}".format(fullname))
|
||||||
# Verify that the bytecode is not stale (only matters when
|
# Verify that the bytecode is not stale (only matters when
|
||||||
# there is source to fall back on.
|
# there is source to fall back on.
|
||||||
if source_timestamp:
|
if source_timestamp:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue