This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: [Windows] __init__.py cause strange behavior
Type: Stage:
Components: Interpreter Core Versions:
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: tim.peters Nosy List: tim.peters
Priority: normal Keywords:

Created on 2001-07-03 18:00 by anonymous, last changed 2022-04-10 16:04 by admin. This issue is now closed.

Messages (3)
msg5261 - (view) Author: Nobody/Anonymous (nobody) Date: 2001-07-03 18:00
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.
msg5262 - (view) Author: Tim Peters (tim.peters) * (Python committer) Date: 2001-07-05 02:29
Logged In: YES 
user_id=31435

Assigned to me, added "[Windows]" to summary, changed group 
to Platform-specific.
msg5263 - (view) Author: Tim Peters (tim.peters) * (Python committer) Date: 2001-07-05 03:49
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
History
Date User Action Args
2022-04-10 16:04:10adminsetgithub: 34697
2001-07-03 18:00:14anonymouscreate