Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
10 changes: 5 additions & 5 deletions Lib/importlib/_bootstrap_external.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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):
Expand Down
4 changes: 2 additions & 2 deletions Lib/test/test_importlib/test_spec.py
Original file line number Diff line number Diff line change
Expand Up @@ -815,10 +815,10 @@ def test_spec_from_file_location_relative_path(self):

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,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
No longer eagerly makes import filenames absolute, except for extension

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

For the NEWS reader it is worth noting the version when this behavior started.

modules.
Loading