This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author takluyver
Recipients takluyver
Date 2012-05-17.23:35:07
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1337297708.76.0.21488172689.issue14846@psf.upfronthosting.co.za>
In-reply-to
Content
I've come across a difference from 3.2 to 3.3 while running the IPython test suite. It occurs when a directory on sys.path has been used for an import, then deleted without being removed from sys.path. Previous versions of Python ignore the nonexistent folder, but in 3.3 a FileNotFound error appears.

This might be by design (errors should never pass silently), but I haven't found it mentioned in the What's New for 3.3.

$ cat import.py
import sys, os, shutil
os.mkdir('foo')
with open('foo/bar.py', 'w'):
    pass
sys.path.insert(0, 'foo/')
import bar   # Caches a FileFinder for foo/
shutil.rmtree('foo')
import random   # Comes later on sys.path

$ python3.2 import.py

$ python3.3 import.py
Traceback (most recent call last):
  File "import.py", line 8, in <module>
    import random
  File "<frozen importlib._bootstrap>", line 1162, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1124, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 1078, in _find_module
  File "<frozen importlib._bootstrap>", line 927, in find_module
  File "<frozen importlib._bootstrap>", line 973, in find_module
  File "<frozen importlib._bootstrap>", line 1005, in _fill_cache
FileNotFoundError: [Errno 2] No such file or directory: 'foo/'

The last entry in that traceback is calling "_os.listdir(path)".
History
Date User Action Args
2012-05-17 23:35:08takluyversetrecipients: + takluyver
2012-05-17 23:35:08takluyversetmessageid: <1337297708.76.0.21488172689.issue14846@psf.upfronthosting.co.za>
2012-05-17 23:35:08takluyverlinkissue14846 messages
2012-05-17 23:35:07takluyvercreate