bpo-44070: No longer eagerly makes import filenames absolute, except for extension modules (GH-26025)

This commit is contained in:
Steve Dower 2021-05-10 23:45:50 +01:00 committed by GitHub
parent fbd9b9939c
commit 23822e2c65
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 1848 additions and 1845 deletions

View File

@ -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):

View File

@ -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,

View File

@ -0,0 +1,2 @@
No longer eagerly makes import filenames absolute, except for extension
modules.

File diff suppressed because it is too large Load Diff