GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — zipimporter find_module fullname mis-documented · Issue #52647 · python/cpython

zipimporter find_module fullname mis-documented #52647

New issue
Copy link
New issue
Copy link
Closed
Closed
zipimporter find_module fullname mis-documented#52647
Copy link
Labels
3.7 (EOL)end of lifeend of life3.8 (EOL)end of lifeend of lifetype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error

Description

kmtracey
mannequin
opened on Apr 14, 2010
Issue body actions
BPO 8400
Nosy @gpshead, @kmtracey, @cool-RR, @ericsnowcurrently, @serhiy-storchaka, @tirkarthi

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 = None
created_at = <Date 2010-04-14.15:20:40.742>
labels = ['3.8', 'type-bug', '3.7']
title = 'zipimporter find_module fullname mis-documented'
updated_at = <Date 2020-01-24.23:26:31.133>
user = 'https://github.com/kmtracey'

bugs.python.org fields:

activity = <Date 2020-01-24.23:26:31.133>
actor = 'brett.cannon'
assignee = 'none'
closed = False
closed_date = None
closer = None
components = []
creation = <Date 2010-04-14.15:20:40.742>
creator = 'kmtracey'
dependencies = []
files = []
hgrepos = []
issue_num = 8400
keywords = []
message_count = 8.0
messages = ['103132', '109467', '134584', '175527', '175565', '175566', '342587', '342665']
nosy_count = 9.0
nosy_names = ['gregory.p.smith', 'kmtracey', 'rfk', 'cool-RR', 'tjd.rodgers', 'eric.snow', 'serhiy.storchaka', 'superluser', 'xtreak']
pr_nums = []
priority = 'normal'
resolution = None
stage = 'test needed'
status = 'open'
superseder = None
type = 'behavior'
url = 'https://bugs.python.org/issue8400'
versions = ['Python 3.7', 'Python 3.8']

Activity

  1. kmtracey commented on Apr 14, 2010

    @kmtracey
    kmtraceymannequin
    on Apr 14, 2010
    MannequinAuthor
    More actions

    The fullname parameter to zipimporter find_module is documented to be a "fully qualified (dotted) module name". (From http://docs.python.org/library/zipimport.html#zipimport.zipimporter.find_module.) However, passing a fully-qualified dotted module appears to never work. Rather it appears that you must use the file system path separator instead of dots. For example on Windows:

    C:\>echo %pythonpath%
    \tmp\blah-1.0-py2.6.egg

    C:\>python
    Python 2.6.5 (r265:79096, Mar 19 2010, 21:48:26) [MSC v.1500 32 bit (Intel)] on win32
    Type "help", "copyright", "credits" or "license" for more information.
    >>> from blah.models import speak
    >>> speak.__file__
    'C:\\tmp\\blah-1.0-py2.6.egg\\blah\\models\\speak.pyc'
    >>> speak.sayhi()
    Hi from blah.models.speak sayhi function.

    The egg has top-level blah package and under it models, it appears to work fine for normal use. But zipimport zipimporter find_module won't find the models sub-module using dotted path notation:

    >>> import sys
    >>> sys.path[1]
    'C:\\tmp\\blah-1.0-py2.6.egg'
    >>> import zipimport
    >>> zi = zipimport.zipimporter(sys.path[1])
    >>> zi.find_module('blah')
    <zipimporter object "C:\tmp\blah-1.0-py2.6.egg">
    >>> zi.find_module('blah.models')
    >>> zi.find_module('blah/models')
    >>> zi.find_module('blah\\models')
    <zipimporter object "C:\tmp\blah-1.0-py2.6.egg">
    >>>

    On Linux, the 'blah/models' version is the one that works.

    Tested as far back as Python2.3 and as far forward as 2.7a3.

  2. kmtracey
    added
    type-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
    on Apr 14, 2010
  3. rfk commented on Jul 7, 2010

    @rfk
    rfkmannequin
    on Jul 7, 2010
    Mannequin
    More actions

    Was also just bitten by this, trying to muck with PEP-302-style import hooks. Note that the documented behaviour of zipimporter is also the behaviour required by PEP-302, i.e. full dotted module name.

  4. cool-RR commented on Apr 27, 2011

    @cool-RR
    cool-RRmannequin
    on Apr 27, 2011
    Mannequin
    More actions

    I was bitten now as well...

  5. tjdrodgers commented on Nov 13, 2012

    @tjdrodgers
    tjdrodgersmannequin
    on Nov 13, 2012
    Mannequin
    More actions

    I have also just been bitten by this. Is there anyway that this can be updated to support the dotted notation?

  6. tjdrodgers commented on Nov 14, 2012

    @tjdrodgers
    tjdrodgersmannequin
    on Nov 14, 2012
    Mannequin
    More actions

    It gets worse. Even though find_module works with the path separator, load_module fails.

    >>> zi.find_module("lib\\ui")
    <zipimporter object "dist/Test_Editor-1.0-py3.2.zip">
    >>> zi.load_module("lib\\ui")
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
      File "dist/Test_Editor-1.0-py3.2.zip\lib\ui\__init__.py", line 9, in <module>
      File "dist\Test_Editor-1.0-py3.2.zip\lib\ui\texteditorwindow.py", line 5, in <module>
      File "dist\Test_Editor-1.0-py3.2.zip\lib\ui\designer\__init__.py", line 5, in <module>
    ValueError: Attempted relative import beyond toplevel package
  7. tjdrodgers commented on Nov 14, 2012

    @tjdrodgers
    tjdrodgersmannequin
    on Nov 14, 2012
    Mannequin
    More actions

    Disregard the last...error on my part (so embarrassing!)

  8. tirkarthi commented on May 15, 2019

    @tirkarthi
    tirkarthi
    on May 15, 2019
    Member
    More actions

    This still exists after zipimport rewrite in Python with 3.8 . Is this a documentation issue or an enhancement to be made as noted in msg109467 ?

  9. tirkarthi
    added
    3.7 (EOL)end of lifeend of life
    3.8 (EOL)end of lifeend of life
    on May 15, 2019
  10. brettcannon commented on May 16, 2019

    @brettcannon
    brettcannon
    on May 16, 2019
    Member
    More actions

    Actually find_module() should be deprecated and find_spec() should be defined instead (and the same goes for load_module(); see bpo-9699). So I'm personally fine w/ making this a doc problem w/ the plan to eventually deprecate the method.

  11. ezio-melotti
    transferred this issue fromon Apr 10, 2022
  12. hugovk commented on Aug 16, 2022

    @hugovk
    hugovk
    on Aug 16, 2022
    Member
    More actions

    Closing this as find_module is deprecated since 3.10 and slated for 3.12 removal:

    • https://docs.python.org/3/library/zipimport.html#zipimport.zipimporter.find_module
    • https://docs.python.org/3/whatsnew/3.10.html#deprecated
    • Raise ImportWarning when loader.load_module() is used #70319
    • gh-70319: Deprecate usage of load_module() #23469
  13. hugovk
    closed this as completedon Aug 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    3.7 (EOL)end of lifeend of life3.8 (EOL)end of lifeend of lifetype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402520 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.