John Ehresman <j...@wingware.com> added the comment:
On 6/5/12 1:08 PM, Brett Cannon wrote:
>
> Brett Cannon<br...@python.org> added the comment:
>
> Does it work in Python 3.2, John? If it does then it's just an oversight
> thanks to the lack of tests in test_imp and it shouldn't be too difficult to
> support.
>
> But do realize I have deprecated the function. =)
Attached is a short test file to demonstrate this. It assumes the
standard win32 layout, but shouldn't be hard to modify. It does work in
Python 3.2, but the else: clause in 3.3's imp.load_module function
raises an ImportError. I think the fix is to add an elif C_EXTENSION:
clause that loads the .so / .pyd.
I've already rewritten my code to use importlib when running in Python 3.3.
----------
Added file: http://bugs.python.org/file25834/imptest.py
_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue13959>
_______________________________________
import imp
import importlib
import sys
dirname = r'c:\Python33\dlls'
name = '_bz2'
assert name not in sys.modules
use_imp = True
if use_imp:
fp, pathname, description = imp.find_module(name, [dirname])
mod = imp.load_module(name, fp, pathname, description)
else:
loader = importlib.machinery.PathFinder.find_module(name, [dirname])
mod = loader.load_module(name)
print (mod)
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com