[Python-checkins] r61595 - in python/trunk: Lib/test/relimport.py Lib/test/test_import.py Misc/NEWS Python/ast.c
martin.v.loewis
python-checkins at python.org
Wed Mar 19 05:39:14 CET 2008
Author: martin.v.loewis
Date: Wed Mar 19 05:39:13 2008
New Revision: 61595
Added:
python/trunk/Lib/test/relimport.py
Modified:
python/trunk/Lib/test/test_import.py
python/trunk/Misc/NEWS
python/trunk/Python/ast.c
Log:
Issue #2400: Allow relative imports to "import *".
Added: python/trunk/Lib/test/relimport.py
==============================================================================
--- (empty file)
+++ python/trunk/Lib/test/relimport.py Wed Mar 19 05:39:13 2008
@@ -0,0 +1 @@
+from .test_import import *
Modified: python/trunk/Lib/test/test_import.py
==============================================================================
--- python/trunk/Lib/test/test_import.py (original)
+++ python/trunk/Lib/test/test_import.py Wed Mar 19 05:39:13 2008
@@ -254,8 +254,20 @@
self.assertEqual(mod.testdata, 'test_trailing_slash')
unload("test_trailing_slash")
+class RelativeImport(unittest.TestCase):
+ def tearDown(self):
+ try:
+ del sys.modules["test.relimport"]
+ except:
+ pass
+
+ def test_relimport_star(self):
+ # This will import * from .test_import.
+ import relimport
+ self.assertTrue(hasattr(relimport, "RelativeImport"))
+
def test_main(verbose=None):
- run_unittest(ImportTest, PathsTests)
+ run_unittest(ImportTest, PathsTests, RelativeImport)
if __name__ == '__main__':
test_main()
Modified: python/trunk/Misc/NEWS
==============================================================================
--- python/trunk/Misc/NEWS (original)
+++ python/trunk/Misc/NEWS Wed Mar 19 05:39:13 2008
@@ -12,6 +12,8 @@
Core and builtins
-----------------
+- Issue #2400: Allow relative imports to "import *".
+
- Issue 1745. Backport print function with:
from __future__ import print_function
Modified: python/trunk/Python/ast.c
==============================================================================
--- python/trunk/Python/ast.c (original)
+++ python/trunk/Python/ast.c Wed Mar 19 05:39:13 2008
@@ -2413,10 +2413,6 @@
/* from ... import * */
n = CHILD(n, idx);
n_children = 1;
- if (ndots) {
- ast_error(n, "'import *' not allowed with 'from .'");
- return NULL;
- }
break;
case LPAR:
/* from ... import (x, y, z) */
More information about the Python-checkins
mailing list