mirror of
https://github.com/python/cpython.git
synced 2026-01-27 05:05:50 +00:00
bpo-44070: No longer eagerly makes import filenames absolute, except for extension modules (GH-26025)
This commit is contained in:
parent
fbd9b9939c
commit
23822e2c65
@ -718,11 +718,6 @@ def spec_from_file_location(name, location=None, *, loader=None,
|
||||
pass
|
||||
else:
|
||||
location = _os.fspath(location)
|
||||
if not _path_isabs(location):
|
||||
try:
|
||||
location = _path_join(_os.getcwd(), location)
|
||||
except OSError:
|
||||
pass
|
||||
|
||||
# If the location is on the filesystem, but doesn't actually exist,
|
||||
# we could return None here, indicating that the location is not
|
||||
@ -1159,6 +1154,11 @@ class ExtensionFileLoader(FileLoader, _LoaderBasics):
|
||||
|
||||
def __init__(self, name, path):
|
||||
self.name = name
|
||||
if not _path_isabs(path):
|
||||
try:
|
||||
path = _path_join(_os.getcwd(), path)
|
||||
except OSError:
|
||||
pass
|
||||
self.path = path
|
||||
|
||||
def __eq__(self, other):
|
||||
|
||||
@ -815,10 +815,10 @@ class FactoryTests:
|
||||
|
||||
self.assertEqual(spec.name, self.name)
|
||||
self.assertEqual(spec.loader, self.fileloader)
|
||||
self.assertEqual(spec.origin, self.path)
|
||||
self.assertEqual(spec.origin, os.path.basename(self.path))
|
||||
self.assertIs(spec.loader_state, None)
|
||||
self.assertIs(spec.submodule_search_locations, None)
|
||||
self.assertEqual(spec.cached, self.cached)
|
||||
self.assertEqual(spec.cached, os.path.relpath(self.cached))
|
||||
self.assertTrue(spec.has_location)
|
||||
|
||||
(Frozen_FactoryTests,
|
||||
|
||||
@ -0,0 +1,2 @@
|
||||
No longer eagerly makes import filenames absolute, except for extension
|
||||
modules.
|
||||
3677
Python/importlib_external.h
generated
3677
Python/importlib_external.h
generated
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user