Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nested namespace imports do not work inside zip archives #65098

Closed
AndreyAntsut mannequin opened this issue Mar 12, 2014 · 3 comments
Closed

Nested namespace imports do not work inside zip archives #65098

AndreyAntsut mannequin opened this issue Mar 12, 2014 · 3 comments
Labels
type-bug An unexpected behavior, bug, or error

Comments

@AndreyAntsut
Copy link
Mannequin

AndreyAntsut mannequin commented Mar 12, 2014

BPO 20899
Nosy @Yhg1s, @warsaw, @gpshead, @ncoghlan, @ericvsmith, @ericsnowcurrently, @serhiy-storchaka, @jonnyhsu, @iritkatriel
Files
  • reproduce.zip
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = None
    closed_at = <Date 2021-12-09.00:15:16.850>
    created_at = <Date 2014-03-12.20:30:25.235>
    labels = ['type-bug']
    title = 'Nested namespace imports do not work inside zip archives'
    updated_at = <Date 2021-12-09.00:15:16.847>
    user = 'https://bugs.python.org/AndreyAntsut'

    bugs.python.org fields:

    activity = <Date 2021-12-09.00:15:16.847>
    actor = 'iritkatriel'
    assignee = 'none'
    closed = True
    closed_date = <Date 2021-12-09.00:15:16.850>
    closer = 'iritkatriel'
    components = []
    creation = <Date 2014-03-12.20:30:25.235>
    creator = 'Andrey.Antsut'
    dependencies = []
    files = ['34380']
    hgrepos = []
    issue_num = 20899
    keywords = []
    message_count = 3.0
    messages = ['213290', '364937', '408056']
    nosy_count = 10.0
    nosy_names = ['twouters', 'barry', 'gregory.p.smith', 'ncoghlan', 'eric.smith', 'eric.snow', 'serhiy.storchaka', 'Andrey.Antsut', 'Jonathan Hsu', 'iritkatriel']
    pr_nums = []
    priority = 'normal'
    resolution = 'out of date'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue20899'
    versions = ['Python 3.4', 'Python 3.5']

    @AndreyAntsut
    Copy link
    Mannequin Author

    AndreyAntsut mannequin commented Mar 12, 2014

    Importing modules from subdirectories as "implicit namespace packages" (PEP-420) inside a ZIP archive only works one level deep. Imports from within nested namespaces fail with "ImportError: No module named 'XXX'".

    I am attaching an archive with example directory/file structure. To reproduce the problem, run the following from where you unzipped it:

    python
    >>> import sys
    >>> sys.path += ['project1', 'project2.zip', 'project3', 'project4.zip']
    >>> import parent.child.hello1
    Hello 1
    >>> import parent.child.hello2
    ImportError: No module named 'parent.child.hello2'
    >>> import parent.child.hello3
    Hello 3
    >>> import parent.child.hello4
    ImportError: No module named 'parent.child.hello4'
    >>> import boo
    boo!
    >>> import parent.boo
    boo!

    Tested on WinXP SP3 with Python 3.3.5 and 3.4.0rc3.

    @AndreyAntsut AndreyAntsut mannequin added the type-bug An unexpected behavior, bug, or error label Mar 12, 2014
    @jonnyhsu
    Copy link
    Mannequin

    jonnyhsu mannequin commented Mar 24, 2020

    It appears this issue has been fixed, as I am unable to reproduce it on Windows 10/Python 3.7:

    Python 3.7.7 (tags/v3.7.7:d7c567b08f, Mar 10 2020, 10:41:24) [MSC v.1900 64 bit (AMD64)] on win32
    Type "help", "copyright", "credits" or "license" for more information.
    >>> import sys
    >>> sys.path += ['project1', 'project2.zip', 'project3', 'project4.zip']
    >>> import parent.child.hello1
    Hello 1
    >>> import parent.child.hello2
    Hello 2
    >>> import parent.child.hello3
    Hello 3
    >>> import parent.child.hello4
    Hello 4
    >>> import boo
    boo!
    >>> import parent.boo
    boo!

    @iritkatriel
    Copy link
    Member

    I got the same results as Jonathan.

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    type-bug An unexpected behavior, bug, or error
    Projects
    None yet
    Development

    No branches or pull requests

    1 participant