[Python-checkins] r51979 - python/branches/theller_modulefinder/Lib/modulefinder.py
thomas.heller
python-checkins at python.org
Fri Sep 22 13:59:40 CEST 2006
Author: thomas.heller
Date: Fri Sep 22 13:59:40 2006
New Revision: 51979
Modified:
python/branches/theller_modulefinder/Lib/modulefinder.py
Log:
Reenable Python 2.2 comatibility.
Raise NotImplementedError instead of RuntimeError on absolute or
relative imports.
Modified: python/branches/theller_modulefinder/Lib/modulefinder.py
==============================================================================
--- python/branches/theller_modulefinder/Lib/modulefinder.py (original)
+++ python/branches/theller_modulefinder/Lib/modulefinder.py Fri Sep 22 13:59:40 2006
@@ -1,7 +1,7 @@
"""Find modules used by a script, using introspection."""
-
# This module should be kept compatible with Python 2.2, see PEP 291.
+from __future__ import generators
import dis
import imp
import marshal
@@ -325,7 +325,6 @@
code = co.co_code
names = co.co_names
consts = co.co_consts
- LOAD_AND_IMPORT = LOAD_CONST + IMPORT_NAME
while code:
c = code[0]
if c in STORE_OPS:
@@ -333,7 +332,7 @@
yield "store", (names[oparg],)
code = code[3:]
continue
- if code[:6:3] == LOAD_AND_IMPORT:
+ if c == LOAD_CONST and code[3] == IMPORT_NAME:
oparg_1, oparg_2 = unpack('<xHxH', code[:6])
yield "import", (consts[oparg_1], names[oparg_2])
code = code[6:]
@@ -411,9 +410,9 @@
else:
m.starimports[name] = 1
elif what == "absolute_import":
- raise RuntimeError("absolute import not yet implemented")
+ raise NotImplementedError("absolute import not yet implemented")
elif what == "relative_import":
- raise RuntimeError("relative import not yet implemented")
+ raise NotImplementedError("relative import not yet implemented")
else:
# We don't expect anything else from the generator.
raise RuntimeError(what)
More information about the Python-checkins
mailing list