Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit5163c35

Browse files
committed
Don't include trailing '/.' to FileFinder path
1 parent41aeca2 commit5163c35

File tree

3 files changed

+16
-10
lines changed

3 files changed

+16
-10
lines changed

‎Lib/importlib/_bootstrap_external.py‎

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1569,9 +1569,12 @@ def __init__(self, path, *loader_details):
15691569
loaders.extend((suffix,loader)forsuffixinsuffixes)
15701570
self._loaders=loaders
15711571
# Base (directory) path
1572-
self.path=pathor'.'
1573-
ifnot_path_isabs(self.path):
1574-
self.path=_path_join(_os.getcwd(),self.path)
1572+
ifnotpathorpath=='.':
1573+
self.path=_os.getcwd()
1574+
elifnot_path_isabs(path):
1575+
self.path=_path_join(_os.getcwd(),path)
1576+
else:
1577+
self.path=path
15751578
self._path_mtime=-1
15761579
self._path_cache=set()
15771580
self._relaxed_path_cache=set()

‎Lib/test/test_import/__init__.py‎

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -927,15 +927,15 @@ def test_missing_source_legacy(self):
927927
m=__import__(TESTFN)
928928
try:
929929
self.assertEqual(m.__file__,
930-
os.path.join(os.getcwd(),os.curdir,os.path.relpath(pyc_file)))
930+
os.path.join(os.getcwd(),os.path.relpath(pyc_file)))
931931
finally:
932932
os.remove(pyc_file)
933933

934934
deftest___cached__(self):
935935
# Modules now also have an __cached__ that points to the pyc file.
936936
m=__import__(TESTFN)
937937
pyc_file=importlib.util.cache_from_source(TESTFN+'.py')
938-
self.assertEqual(m.__cached__,os.path.join(os.getcwd(),os.curdir,pyc_file))
938+
self.assertEqual(m.__cached__,os.path.join(os.getcwd(),pyc_file))
939939

940940
@skip_if_dont_write_bytecode
941941
deftest___cached___legacy_pyc(self):
@@ -951,7 +951,7 @@ def test___cached___legacy_pyc(self):
951951
importlib.invalidate_caches()
952952
m=__import__(TESTFN)
953953
self.assertEqual(m.__cached__,
954-
os.path.join(os.getcwd(),os.curdir,os.path.relpath(pyc_file)))
954+
os.path.join(os.getcwd(),os.path.relpath(pyc_file)))
955955

956956
@skip_if_dont_write_bytecode
957957
deftest_package___cached__(self):
@@ -971,10 +971,10 @@ def cleanup():
971971
m=__import__('pep3147.foo')
972972
init_pyc=importlib.util.cache_from_source(
973973
os.path.join('pep3147','__init__.py'))
974-
self.assertEqual(m.__cached__,os.path.join(os.getcwd(),os.curdir,init_pyc))
974+
self.assertEqual(m.__cached__,os.path.join(os.getcwd(),init_pyc))
975975
foo_pyc=importlib.util.cache_from_source(os.path.join('pep3147','foo.py'))
976976
self.assertEqual(sys.modules['pep3147.foo'].__cached__,
977-
os.path.join(os.getcwd(),os.curdir,foo_pyc))
977+
os.path.join(os.getcwd(),foo_pyc))
978978

979979
deftest_package___cached___from_pyc(self):
980980
# Like test___cached__ but ensuring __cached__ when imported from a
@@ -998,10 +998,10 @@ def cleanup():
998998
m=__import__('pep3147.foo')
999999
init_pyc=importlib.util.cache_from_source(
10001000
os.path.join('pep3147','__init__.py'))
1001-
self.assertEqual(m.__cached__,os.path.join(os.getcwd(),os.curdir,init_pyc))
1001+
self.assertEqual(m.__cached__,os.path.join(os.getcwd(),init_pyc))
10021002
foo_pyc=importlib.util.cache_from_source(os.path.join('pep3147','foo.py'))
10031003
self.assertEqual(sys.modules['pep3147.foo'].__cached__,
1004-
os.path.join(os.getcwd(),os.curdir,foo_pyc))
1004+
os.path.join(os.getcwd(),foo_pyc))
10051005

10061006
deftest_recompute_pyc_same_second(self):
10071007
# Even when the source file doesn't change timestamp, a change in
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
:func:`importlib.invalidate_caches` now drops entries from
22
:data:`sys.path_importer_cache` with a relative path as name. This solves a
33
caching issue when a process changes its current working directory.
4+
5+
``FileFinder`` no longer inserts a dot in the path, e.g.
6+
``/egg/./spam`` is now ``/egg/spam``.

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp