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: imputil must respect __path__ for package submodules
Type: Stage:
Components: Library (Lib) Versions: Python 2.3
process
Status: closed Resolution: accepted
Dependencies: Superseder:
Assigned To: Nosy List: loewis, sfiet
Priority: normal Keywords: patch

Created on 2003-02-12 11:51 by sfiet, last changed 2022-04-10 16:06 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
imputil.py.diff sfiet, 2003-02-12 12:52 enhance FilesystemImporter.get_code to use parent.__path__
Messages (4)
msg42835 - (view) Author: Soeren Fietzke (sfiet) Date: 2003-02-12 11:51
The imputil module does not look at the __path__ 
member of a package to find sub-modules. 
To reproduce, create a package with a submodule, i.e. 
directory structure like this:

p1/
  __init__.py
  sub/
     spam.py

contents of __init__.py:
  import os
  __path__.append(os.path.join(__path__[0], 'sub'))
  import spam

contents of spam.py:
  print 'imported spam'


Doing an "import p1" in a fresh Python session will 
succeed.

However, after loading and installing imputil, it will fail:
import imputil
imputil._test_revamp()
import p1  # <-- will not find module spam

msg42836 - (view) Author: Soeren Fietzke (sfiet) Date: 2003-02-12 11:58
Logged In: YES 
user_id=710276

Oops, spaces were stripped out, so just to clarify: 'sub' 
should be a subdirectory of 'p1' in the above example:
p1/__init__.py
p1/sub/spam.py
msg42837 - (view) Author: Soeren Fietzke (sfiet) Date: 2003-02-12 12:52
Logged In: YES 
user_id=710276

There's no uploaded file!  You have to check the
checkbox labeled "Check to Upload & Attach File"
when you upload a file.

Please try again.

(This is a SourceForge annoyance that we can do
nothing about. :-( )
msg42838 - (view) Author: Martin v. Löwis (loewis) * (Python committer) Date: 2007-02-13 08:35
Thanks for the patch. Committed as r53763 and r53764.
History
Date User Action Args
2022-04-10 16:06:46adminsetgithub: 37973
2003-02-12 11:51:51sfietcreate