diff --git a/compiler/stmt.py b/compiler/stmt.py index 98051a8d..d0f5dbbb 100644 --- a/compiler/stmt.py +++ b/compiler/stmt.py @@ -378,13 +378,15 @@ def visit_Import(self, node): self.block.bind_var(self.writer, asname, mod.expr) def visit_ImportFrom(self, node): - # Wildcard imports are not yet supported. + self._write_py_context(node.lineno) for alias in node.names: if alias.name == '*': - msg = 'wildcard member import is not implemented: from %s import %s' % ( - node.module, alias.name) - raise util.ParseError(node, msg) - self._write_py_context(node.lineno) + module_name = node.module + + with self._import(module_name, module_name.count('.')) as module: + self.writer.write_checked_call1( + 'πg.LoadMembers(πF, {})', module.expr) + return if node.module.startswith(_NATIVE_MODULE_PREFIX): values = [alias.name for alias in node.names] with self._import_native(node.module, values) as mod: diff --git a/compiler/stmt_test.py b/compiler/stmt_test.py index 5c351c12..df5f25b6 100644 --- a/compiler/stmt_test.py +++ b/compiler/stmt_test.py @@ -366,14 +366,12 @@ def testImportFromFutureParseError(self): self.assertRaisesRegexp(util.ParseError, want_regexp, stmt.import_from_future, node) - def testImportWildcardMemberRaises(self): - regexp = r'wildcard member import is not implemented: from foo import *' - self.assertRaisesRegexp(util.ParseError, regexp, _ParseAndVisit, - 'from foo import *') - regexp = (r'wildcard member import is not ' - r'implemented: from __go__.foo import *') - self.assertRaisesRegexp(util.ParseError, regexp, _ParseAndVisit, - 'from __go__.foo import *') + def testImportWildcard(self): + result = _GrumpRun(textwrap.dedent("""\ + from time import * + print sleep""")) + self.assertEqual(0, result[0]) + self.assertIn('