[IronPython] from X import Y brokenness

Jonathan Jacobs korpse-ironpython at kaydash.za.net
Tue Jul 5 16:39:48 CEST 2005


Hi,

Recently, I've run across a bit of a bug while importing things with the
"from X import Y" syntax, when Y is anything but an an attribute of X
that already exists.

Demonstration:

IronPython 0.7.6 on .NET 2.0.50215.44
Copyright (c) Microsoft Corporation. All rights reserved.
  >>> from foo import bar
  >>> repr(bar)
'None'
  >>> from foo.bar import quux
  >>> repr(quux)
'<function quux at 0x00EA7F4A>'

One can work around the problem by doing a "regular" import first:

  >>> import foo.bar
  >>> from foo import bar
  >>> repr(bar)
'<module foo.bar from "C:\\Documents and
Settings\\JJ\\Desktop\\IronPython-0.7.6-orig\\bin\\foo\\bar.py">'

After doing some digging I've come up with a solution. Even though I
don't really think it is a clean solution, I've attached the patch anyway.

--
Jonathan

-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: from-import.patch
URL: <http://mail.python.org/pipermail/ironpython-users/attachments/20050705/c6113eda/attachment.ksh>


More information about the Ironpython-users mailing list