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

Handle failure to call dlopen(NULL) #294

Merged
merged 2 commits into from
May 23, 2020

Conversation

indygreg
Copy link
Contributor

See the inline comment for the explanation.

I have been running into this bug on PyOxidizer when using
Python distributions built against musl libc. For reference:

$ ldd python/install/bin/python3.7m
     not a dynamic executable

$ python/install/bin/python3.7m
Python 3.7.7 (default, Apr  5 2020, 06:02:52)
[Clang 9.0.1 ] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import ctypes
>>> ctypes.CDLL(None)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/gps/src/pyoxidizer.git/build/python_distributions/python.c1ffa330c730/python/install/lib/python3.7/ctypes/__init__.py", line 364, in __init__
    self._handle = _dlopen(self._name, mode)
OSError: Dynamic loading not supported

Interestingly, OSError is incomplete (possibly a CPython ctypes bug?):

>>> try:
...     ctypes.CDLL(None)
... except OSError as e:
...     err = e
...
>>> err
OSError('Dynamic loading not supported')
>>> err.errno
None
>>> err.strerror
None
>>> err.args
('Dynamic loading not supported',)

Copy link
Member

@brettcannon brettcannon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Happy to take the fix, but we need a test to make sure we don't break this in the future.

CHANGELOG.rst Outdated Show resolved Hide resolved
packaging/tags.py Outdated Show resolved Hide resolved
See the inline comment for the explanation.

I have been running into this bug on PyOxidizer when using
Python distributions built against musl libc. For reference:

    $ ldd python/install/bin/python3.7m
         not a dynamic executable

    $ python/install/bin/python3.7m
    Python 3.7.7 (default, Apr  5 2020, 06:02:52)
    [Clang 9.0.1 ] on linux
    Type "help", "copyright", "credits" or "license" for more information.
    >>> import ctypes
    >>> ctypes.CDLL(None)
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
      File "/home/gps/src/pyoxidizer.git/build/python_distributions/python.c1ffa330c730/python/install/lib/python3.7/ctypes/__init__.py", line 364, in __init__
        self._handle = _dlopen(self._name, mode)
    OSError: Dynamic loading not supported

Interestingly, OSError is incomplete (possibly a CPython ctypes bug?):

    >>> try:
    ...     ctypes.CDLL(None)
    ... except OSError as e:
    ...     err = e
    ...
    >>> err
    OSError('Dynamic loading not supported')
    >>> err.errno
    None
    >>> err.strerror
    None
    >>> err.args
    ('Dynamic loading not supported',)
@indygreg
Copy link
Contributor Author

@brettcannon I believe this is ready for a re-review.

@brettcannon brettcannon self-requested a review May 11, 2020 19:47
@brettcannon brettcannon merged commit 19fbc45 into pypa:master May 23, 2020
@di di mentioned this pull request Oct 20, 2020
indygreg added a commit to indygreg/python-build-standalone that referenced this pull request Nov 17, 2021
setuptools finally upgraded the vendored packaging package, so we
can remove the patch we contributed upstream in
pypa/packaging#294.

A similar patch for pip still lingers (perhaps we haven't tried to
contribute that upstream yet).
indygreg added a commit to indygreg/python-build-standalone that referenced this pull request Nov 17, 2021
setuptools finally upgraded the vendored packaging package, so we
can remove the patch we contributed upstream in
pypa/packaging#294.

A similar patch for pip still lingers (perhaps we haven't tried to
contribute that upstream yet).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants