[Python-Dev] [Python-checkins] cpython: Issue #18416: Fix various os calls in importlib.machinery.FileFinder (original) (raw)
Brett Cannon brett at python.org
Sat Oct 19 15:54:52 CEST 2013
- Previous message: [Python-Dev] [Python-checkins] cpython: Issue #18416: Fix various os calls in importlib.machinery.FileFinder
- Next message: [Python-Dev] [Python-checkins] cpython: Issue #18810: Be optimistic with stat calls when seeing if a directory
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On Fri, Oct 18, 2013 at 8:55 PM, Nick Coghlan <ncoghlan at gmail.com> wrote:
On 19 Oct 2013 02:01, "brett.cannon" <python-checkins at python.org> wrote: > > http://hg.python.org/cpython/rev/33844153cd02 > changeset: 86438:33844153cd02 > user: Brett Cannon <brett at python.org> > date: Fri Oct 18 12:01:06 2013 -0400 > summary: > Issue #18416: Fix various os calls in importlib.machinery.FileFinder > now that self.path is no longer forced to '.'. Hmm, could this break subclasses in a similar way? It may be safer to keep the empty string -> period conversion, even though PathFinder itself doesn't rely on it any more.
Good point. I'll revert it.
-Brett
Cheers, Nick.
> > files: > Lib/importlib/bootstrap.py | 4 +- > Python/importlib.h | 1554 +++++++++++----------- > 2 files changed, 780 insertions(+), 778 deletions(-) > > > diff --git a/Lib/importlib/bootstrap.py b/Lib/importlib/bootstrap.py > --- a/Lib/importlib/bootstrap.py > +++ b/Lib/importlib/bootstrap.py > @@ -1390,7 +1390,7 @@ > isnamespace = False > tailmodule = fullname.rpartition('.')[2] > try: > - mtime = os.stat(self.path).stmtime > + mtime = os.stat(self.path or os.getcwd()).stmtime > except OSError: > mtime = -1 > if mtime != self.pathmtime: > @@ -1432,7 +1432,7 @@ > """Fill the cache of potential modules and packages for this directory.""" > path = self.path > try: > - contents = os.listdir(path) > + contents = os.listdir(path or os.getcwd()) > except (FileNotFoundError, PermissionError, NotADirectoryError): > # Directory has either been removed, turned into a file, or made > # unreadable. > diff --git a/Python/importlib.h b/Python/importlib.h > --- a/Python/importlib.h > +++ b/Python/importlib.h > [stripped] > > -- > Repository URL: http://hg.python.org/cpython > _> ________________________ > Python-checkins mailing list > Python-checkins at python.org > https://mail.python.org/mailman/listinfo/python-checkins >
Python-checkins mailing list Python-checkins at python.org https://mail.python.org/mailman/listinfo/python-checkins -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.python.org/pipermail/python-dev/attachments/20131019/d421522f/attachment.html>
- Previous message: [Python-Dev] [Python-checkins] cpython: Issue #18416: Fix various os calls in importlib.machinery.FileFinder
- Next message: [Python-Dev] [Python-checkins] cpython: Issue #18810: Be optimistic with stat calls when seeing if a directory
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]