[issue14846] Change in error when sys.path contains a nonexistent folder (importlib)

2012-08-19 Thread Roundup Robot

Roundup Robot added the comment:

New changeset bfd04bfb55c5 by Nick Coghlan in branch 'default':
Close #14846: Handle a sys.path entry going away
http://hg.python.org/cpython/rev/bfd04bfb55c5

--
nosy: +python-dev
resolution:  -> fixed
stage:  -> committed/rejected
status: open -> closed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue14846] Change in error when sys.path contains a nonexistent folder (importlib)

2012-05-17 Thread Eric V. Smith

Changes by Eric V. Smith :


--
nosy: +eric.smith

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue14846] Change in error when sys.path contains a nonexistent folder (importlib)

2012-05-17 Thread Eric Snow

Eric Snow  added the comment:

The caching mechanism is going to check for changes in the directory.  So the 
recommendation is to clear the cache manually:


  The default finders used by import now utilize a cache of what is contained
  within a specific directory. If you create a Python source file or sourceless
  bytecode file, make sure to call importlib.invalidate_caches() to clear out
  the cache for the finders to notice the new file.


(see http://docs.python.org/dev/whatsnew/3.3.html#porting-python-code)

That section doesn't really talk about the directory side of things, but 
calling importlib.invalidate_caches() works great to eliminate the error in 
your example.

--
nosy: +brett.cannon, eric.snow, pitrou

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue14846] Change in error when sys.path contains a nonexistent folder (importlib)

2012-05-17 Thread Eric Snow

Eric Snow  added the comment:

...rather, the error caused by your example.  :)

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue14846] Change in error when sys.path contains a nonexistent folder (importlib)

2012-05-17 Thread Thomas Kluyver

New submission from Thomas Kluyver :

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 
import random
  File "", line 1162, in _find_and_load
  File "", line 1124, in _find_and_load_unlocked
  File "", line 1078, in _find_module
  File "", line 927, in find_module
  File "", line 973, in find_module
  File "", 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)".

--
components: Interpreter Core
messages: 161025
nosy: takluyver
priority: normal
severity: normal
status: open
title: Change in error when sys.path contains a nonexistent folder (importlib)
type: behavior
versions: Python 3.3

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com