Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
a43f0ca9
Commit
a43f0ca9
authored
Oct 18, 2013
by
Brett Cannon
Browse files
Options
Browse Files
Download
Plain Diff
merge
parents
43cc842e
5d348335
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
3471 additions
and
3223 deletions
+3471
-3223
Doc/library/importlib.rst
Doc/library/importlib.rst
+7
-0
Doc/whatsnew/3.4.rst
Doc/whatsnew/3.4.rst
+11
-0
Lib/importlib/_bootstrap.py
Lib/importlib/_bootstrap.py
+2
-2
Lib/test/test_importlib/import_/test_path.py
Lib/test/test_importlib/import_/test_path.py
+2
-2
Misc/NEWS
Misc/NEWS
+7
-0
Python/importlib.h
Python/importlib.h
+3442
-3219
No files found.
Doc/library/importlib.rst
View file @
a43f0ca9
...
...
@@ -722,6 +722,10 @@ find and load modules.
Calls :meth:`importlib.abc.PathEntryFinder.invalidate_caches` on all
finders stored in :attr:`sys.path_importer_cache`.
.. versionchanged:: 3.4
Calls objects in :data:sys.path_hooks with the current working directory
for ``''`` (i.e. the empty string).
.. class:: FileFinder(path, \*loader_details)
...
...
@@ -748,6 +752,9 @@ find and load modules.
.. versionadded:: 3.3
.. versionchange:: 3.4
The empty string is no longer special-cased to be changed into ``'
.
'``.
.. attribute:: path
The path the finder will search in.
...
...
Doc/whatsnew/3.4.rst
View file @
a43f0ca9
...
...
@@ -675,3 +675,14 @@ that may require changes to your code.
:c:func:`PyMem_RawRealloc`, or *NULL* if an error occurred, instead of a
string allocated by :c:func:`PyMem_Malloc` or :c:func:`PyMem_Realloc`.
* :cls:`importlib.machinery.PathFinder` now passes on the current working
directory to objects in :data:`sys.path_hooks` for the empty string. This
results in :data:`sys.path_importer_cache` never containing ``''``, thus
iterating through :data:`sys.path_importer_cache` based on :data:`sys.path`
will not find all keys. A module's ``__file__`` when imported in the current
working directory will also now have an absolute path, including when using
``-m`` with the interpreter (this does not influence when the path to a file
is specified on the command-line).
* :cls:`importlib.machinery.FileFinder` no longer special-cases the empty string
to be changed to ``'.'``.
Lib/importlib/_bootstrap.py
View file @
a43f0ca9
...
...
@@ -1302,7 +1302,7 @@ class PathFinder:
"""
if
path
==
''
:
path
=
'.'
path
=
_os
.
getcwd
()
try
:
finder
=
sys
.
path_importer_cache
[
path
]
except
KeyError
:
...
...
@@ -1373,7 +1373,7 @@ class FileFinder:
loaders
.
extend
((
suffix
,
loader
)
for
suffix
in
suffixes
)
self
.
_loaders
=
loaders
# Base (directory) path
self
.
path
=
path
or
'.'
self
.
path
=
path
self
.
_path_mtime
=
-
1
self
.
_path_cache
=
set
()
self
.
_relaxed_path_cache
=
set
()
...
...
Lib/test/test_importlib/import_/test_path.py
View file @
a43f0ca9
...
...
@@ -82,11 +82,11 @@ class FinderTests(unittest.TestCase):
path
=
''
module
=
'<test module>'
importer
=
util
.
mock_modules
(
module
)
hook
=
import_util
.
mock_path_hook
(
os
.
curdir
,
importer
=
importer
)
hook
=
import_util
.
mock_path_hook
(
os
.
getcwd
()
,
importer
=
importer
)
with
util
.
import_state
(
path
=
[
path
],
path_hooks
=
[
hook
]):
loader
=
machinery
.
PathFinder
.
find_module
(
module
)
self
.
assertIs
(
loader
,
importer
)
self
.
assertIn
(
os
.
curdir
,
sys
.
path_importer_cache
)
self
.
assertIn
(
os
.
getcwd
()
,
sys
.
path_importer_cache
)
def
test_None_on_sys_path
(
self
):
# Putting None in sys.path[0] caused an import regression from Python
...
...
Misc/NEWS
View file @
a43f0ca9
...
...
@@ -10,6 +10,13 @@ Projected release date: 2013-10-20
Core and Builtins
-----------------
- Issue #18416: importlib.machinery.PathFinder now treats '' as the cwd and
importlib.machinery.FileFinder no longer special-cases '' to '
.
'. This leads
to modules imported from cwd to now possess an absolute file path for
__file__ (this does not affect modules specified by path on the CLI but it
does affect -m/runpy). It also allows FileFinder to be more consistent by not
having an edge case.
- Issue #4555: All exported C symbols are now prefixed with either
"Py" or "_Py".
...
...
Python/importlib.h
View file @
a43f0ca9
This source diff could not be displayed because it is too large. You can
view the blob
instead.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment