[IronPython] Bug With Packages

Michael Foord fuzzyman at voidspace.org.uk
Sat Jun 3 17:19:33 CEST 2006

Hello all,

I get a bug when importing names that don't exist from a package.

I created a package directory (called package), and place an empty 
"__init__.py" file in it.

I then created a file called "module.py", with nothing in it except :

    print "hello"

Below is an IronPython (beta 7) console session using these files :

IronPython 1.0.60523 (Beta) on .NET 2.0.50727.42
Copyright (c) Microsoft Corporation. All rights reserved.
 >>> from package.module import module
 >>> type(module)
<type 'module'>

You can see the 'hello' from when the module is imported. It should 
raise an "ImportError" when trying to import the name module. Instead it 
returns a "module" object.

Below is the same session in CPython :

Python 2.4.3 (#69, Mar 29 2006, 17:35:34) [MSC v.1310 32 bit (Intel)] on 
Type "help", "copyright", "credits" or "license" for more information.
 >>> from package.module import module
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
ImportError: cannot import name module

Michael Foord

More information about the Ironpython-users mailing list