diff options
author | Thomas Wouters <thomas@python.org> | 2000-08-17 22:55:00 (GMT) |
---|---|---|
committer | Thomas Wouters <thomas@python.org> | 2000-08-17 22:55:00 (GMT) |
commit | 5215225ea1e3200b572775639d567f5e3f489a15 (patch) | |
tree | 8202d4aebf513dc8c8a80adf018f13270386e658 /Lib | |
parent | 1d75a79c009e500923128716a02efbe86135e64e (diff) | |
download | cpython-5215225ea1e3200b572775639d567f5e3f489a15.zip cpython-5215225ea1e3200b572775639d567f5e3f489a15.tar.gz cpython-5215225ea1e3200b572775639d567f5e3f489a15.tar.bz2 |
Apply SF patch #101135, adding 'import module as m' and 'from module import
name as n'. By doing some twists and turns, "as" is not a reserved word.
There is a slight change in semantics for 'from module import name' (it will
now honour the 'global' keyword) but only in cases that are explicitly
undocumented.
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/dis.py | 2 | ||||
-rw-r--r-- | Lib/test/output/test_pkg | 7 | ||||
-rw-r--r-- | Lib/test/test_pkg.py | 27 |
3 files changed, 35 insertions, 1 deletions
@@ -195,7 +195,7 @@ def_op('BREAK_LOOP', 80) def_op('LOAD_LOCALS', 82) def_op('RETURN_VALUE', 83) - +def_op('IMPORT_STAR', 84) def_op('EXEC_STMT', 85) def_op('POP_BLOCK', 87) diff --git a/Lib/test/output/test_pkg b/Lib/test/output/test_pkg index 4cb503e..4e67f8c 100644 --- a/Lib/test/output/test_pkg +++ b/Lib/test/output/test_pkg @@ -36,3 +36,10 @@ t6.ham loading t6.eggs loading ['__all__', '__builtins__', '__doc__', '__file__', '__name__', '__path__', 'eggs', 'ham', 'spam'] ['eggs', 'ham', 'spam', 't6'] +running test t7 +t7 loading +['__builtins__', '__doc__', '__file__', '__name__', '__path__'] +['__builtins__', '__doc__', '__file__', '__name__', '__path__'] +t7.sub.subsub loading +['__builtins__', '__doc__', '__file__', '__name__', '__path__', 'spam'] +t7.sub.subsub.spam = 1 diff --git a/Lib/test/test_pkg.py b/Lib/test/test_pkg.py index fd22612..a99da35 100644 --- a/Lib/test/test_pkg.py +++ b/Lib/test/test_pkg.py @@ -165,6 +165,33 @@ from t6 import * print dir(t6) print dir() """), + + ("t7", [ + ("t7.py", "print 'Importing t7.py'"), + ("t7", None), + ("t7 __init__.py", "print __name__, 'loading'"), + ("t7 sub.py", "print 'THIS SHOULD NOT BE PRINTED (sub.py)'"), + ("t7 sub", None), + ("t7 sub __init__.py", ""), + ("t7 sub subsub.py", "print 'THIS SHOULD NOT BE PRINTED (subsub.py)'"), + ("t7 sub subsub", None), + ("t7 sub subsub __init__.py", "print __name__, 'loading'; spam = 1"), + ], +""" +t7, sub, subsub = None, None, None +import t7 as tas +print dir(tas) +assert not t7 +from t7 import sub as subpar +print dir(subpar) +assert not t7 and not sub +from t7.sub import subsub as subsubsub +print dir(subsubsub) +assert not t7 and not sub and not subsub +from t7.sub.subsub import spam as ham +print "t7.sub.subsub.spam =", ham +assert not t7 and not sub and not subsub +"""), ] |