[Python-bugs-list] [ python-Bugs-438295 ] [Windows] __init__.py cause strange behavior

noreply@sourceforge.net noreply@sourceforge.net
Wed, 04 Jul 2001 20:49:47 -0700


Bugs item #438295, was opened at 2001-07-03 11:00
You can respond by visiting: 
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=438295&group_id=5470

Category: Python Interpreter Core
Group: Platform-specific
>Status: Closed
>Resolution: Fixed
Priority: 5
Submitted By: Nobody/Anonymous (nobody)
Assigned to: Tim Peters (tim_one)
Summary: [Windows] __init__.py cause strange behavior

Initial Comment:
I accidently created the file __INIT__.PY in my 'krw' 
package directory (WinNT4).  Everything appeared to 
work as it should, except I was getting a very strange 
AttributeError:

Python 2.1 (#15, Apr 16 2001, 18:25:49) [MSC 32 bit 
(Intel)] on win32
Type "copyright", "credits" or "license" for more 
information.
>>> import printerTable
>>> l = printerTable.buildFromServer( 'chachaptr1')
>>> l = printerTable.buildFromServer( 'chachaptr1')
>>> l = printerTable.buildFromServer( 'chachaptr1')
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
  File "printerTable.py", line 57, in buildFromServer
    host = krw.util.Host( hostAndPort[0])
AttributeError: '?' module has no attribute 'util'

At this point:

dir( printerTable.krw) => []

After 2 days trying to find out what was happening in 
the code, I decided to check out the package.  I ended 
up recreating the file as __init__.py and the problem 
went away.

I can rename the file back to __INIT__.PY and it 
produces the behavior mentioned above.


----------------------------------------------------------------------

>Comment By: Tim Peters (tim_one)
Date: 2001-07-04 20:49

Message:
Logged In: YES 
user_id=31435

There's really not enough info here to be sure I know what 
your problem is; for example, it's not clear what the 
intended relationship is between printerTable and krw.

I did fix *a* bug anyway, though:  Windows wasn't checking 
correctly for case-sensitivity on __init__ files 
specifically, causing half of the package import machinery 
to think __INIT__ was OK, but the other half not to (and 
then silently suppressing the error).

In the future, case-mismatching __init__ will act as if the 
file weren't there at all, probably leading to an 
ImportError.

Note that Python will tell you which files it's looking at 
when *trying* to do an import if you run python with the -v 
switch (or -vv for even more detailed info).

Python/import.c; new revision: 2.178

----------------------------------------------------------------------

Comment By: Tim Peters (tim_one)
Date: 2001-07-04 19:29

Message:
Logged In: YES 
user_id=31435

Assigned to me, added "[Windows]" to summary, changed group 
to Platform-specific.

----------------------------------------------------------------------

You can respond by visiting: 
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=438295&group_id=5470