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

Misleading error message upon dependent DLL resolution failure #83574

Closed
plimkilde mannequin opened this issue Jan 20, 2020 · 5 comments
Closed

Misleading error message upon dependent DLL resolution failure #83574

plimkilde mannequin opened this issue Jan 20, 2020 · 5 comments
Labels
3.8 only security fixes 3.9 only security fixes easy extension-modules C modules in the Modules dir OS-windows topic-ctypes type-bug An unexpected behavior, bug, or error

Comments

@plimkilde
Copy link
Mannequin

plimkilde mannequin commented Jan 20, 2020

BPO 39393
Nosy @pfmoore, @tjguk, @zware, @eryksun, @zooba, @miss-islington, @plimkilde
PRs
  • bpo-39393: Misleading error message on dependent DLL resolution failure #18093
  • [3.8] bpo-39393: Misleading error message on dependent DLL resolution failure (GH-18093) #18230
  • 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 2020-01-28.09:58:31.572>
    created_at = <Date 2020-01-20.09:27:30.061>
    labels = ['easy', 'type-bug', '3.8', '3.9', 'extension-modules', 'ctypes', 'OS-windows']
    title = 'Misleading error message upon dependent DLL resolution failure'
    updated_at = <Date 2020-01-28.10:00:20.458>
    user = 'https://github.com/plimkilde'

    bugs.python.org fields:

    activity = <Date 2020-01-28.10:00:20.458>
    actor = 'miss-islington'
    assignee = 'none'
    closed = True
    closed_date = <Date 2020-01-28.09:58:31.572>
    closer = 'steve.dower'
    components = ['Extension Modules', 'Windows', 'ctypes']
    creation = <Date 2020-01-20.09:27:30.061>
    creator = 'plimkilde'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 39393
    keywords = ['patch', 'easy (C)']
    message_count = 5.0
    messages = ['360305', '360323', '360848', '360851', '360855']
    nosy_count = 7.0
    nosy_names = ['paul.moore', 'tim.golden', 'zach.ware', 'eryksun', 'steve.dower', 'miss-islington', 'plimkilde']
    pr_nums = ['18093', '18230']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue39393'
    versions = ['Python 3.8', 'Python 3.9']

    @plimkilde
    Copy link
    Mannequin Author

    plimkilde mannequin commented Jan 20, 2020

    Under Windows with Python 3.8+, trying to load a DLL whose dependencies cannot be resolved may produce a misleading error message.

    For example, if we are trying to load a library foo.dll that depends on bar.dll, and bar.dll cannot be resolved while foo.dll itself can, Python gives this error message:
    "FileNotFoundError: Could not find module 'foo.dll'. Try using the full path with constructor syntax."
    (behavior introduced with PR bpo-12302)

    Personally, I'd be happy to see a fix that simply adds " (or one of its dependencies)" to the error message.

    @plimkilde plimkilde mannequin added 3.8 only security fixes 3.9 only security fixes OS-windows topic-ctypes type-bug An unexpected behavior, bug, or error labels Jan 20, 2020
    @eryksun
    Copy link
    Contributor

    eryksun commented Jan 20, 2020

    That clarification seems okay to me. The error message is in load_library in Modules/_ctypes/callproc.c.

    The underlying problem is that the directory of the DLL is only added to the search path (in CDLL.__init__ in Lib/ctypes/init.py) if the caller uses a qualified path. This is an OS limit that we can't avoid.

    Also note that the suggestion to use a qualified path won't necessarily resolve the problem, in which case scripts will have to use os.add_dll_directory, and find a reliable way to identify the required directories.

    @eryksun eryksun added easy extension-modules C modules in the Modules dir labels Jan 20, 2020
    @zooba
    Copy link
    Member

    zooba commented Jan 28, 2020

    New changeset 13c1c35 by Steve Dower (Zackery Spytz) in branch 'master':
    bpo-39393: Misleading error message on dependent DLL resolution failure (GH-18093)
    13c1c35

    @zooba
    Copy link
    Member

    zooba commented Jan 28, 2020

    Thanks, Zackery!

    @zooba zooba closed this as completed Jan 28, 2020
    @zooba zooba closed this as completed Jan 28, 2020
    @miss-islington
    Copy link
    Contributor

    New changeset 46735c7 by Miss Islington (bot) in branch '3.8':
    bpo-39393: Misleading error message on dependent DLL resolution failure (GH-18093)
    46735c7

    @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
    3.8 only security fixes 3.9 only security fixes easy extension-modules C modules in the Modules dir OS-windows topic-ctypes type-bug An unexpected behavior, bug, or error
    Projects
    None yet
    Development

    No branches or pull requests

    3 participants