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

bpo-33591: Fix CDLL to accept PathLike objects #7032

Merged
merged 9 commits into from Feb 5, 2023

Conversation

mrh1997
Copy link
Contributor

@mrh1997 mrh1997 commented May 21, 2018

CDLL (and WinDLL, OleDLL, ...) accept now not only str objects but also PathLike objects.

https://bugs.python.org/issue33591

@the-knights-who-say-ni
Copy link

Hello, and thanks for your contribution!

I'm a bot set up to make sure that the project can legally accept your contribution by verifying you have signed the PSF contributor agreement (CLA).

Unfortunately our records indicate you have not signed the CLA. For legal reasons we need you to sign this before we can look at your contribution. Please follow the steps outlined in the CPython devguide to rectify this issue.

When your account is ready, please add a comment in this pull request
and a Python core developer will remove the CLA not signed label
to make the bot check again.

Thanks again to your contribution and we look forward to looking at it!

@mrh1997
Copy link
Contributor Author

mrh1997 commented May 21, 2018

I signed the CLA (my bugtracker name is "mrh1997").
Please remove the "CLA not signed label"

Due to issue23606 (find msvct does not work any more) test_load did not
work any more, as it used MSVCRT for testing DLL loading.
Now it uses _ctypes_test library, which is explicitly generated for
testing purposes.
CDLL accepts now not only paths of type 'str' but also of type
PathLike (like Path()).
Copy link
Member

@JelleZijlstra JelleZijlstra left a comment

Choose a reason for hiding this comment

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

I'm sorry this PR took so long to review. I dug it up from page 57 of the open PR list, but I think it's pretty close to ready.

I do have some comments:

:class:`ctypes.CDLL`, :class:`ctypes.OleDLL`, :class:`ctypes.WinDLL`,
and :class:`ctypes.PyDLL` now accept :term:`path-like objects
<path-like object>` as their ``name`` argument. Patch by Robert Hoelzl.

Lib/ctypes/test/test_loading.py Outdated Show resolved Hide resolved
iritkatriel
iritkatriel previously requested changes Nov 27, 2022
Copy link
Member

@iritkatriel iritkatriel left a comment

Choose a reason for hiding this comment

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

This has merge conflicts now.

@bedevere-bot
Copy link

A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated.

Once you have made the requested changes, please leave a comment on this pull request containing the phrase I have made the requested changes; please review again. I will then notify any core developers who have left a review that you're ready for them to take another look at this pull request.

@arhadthedev arhadthedev added expert-ctypes stdlib Python modules in the Lib dir labels Feb 3, 2023
@cpython-cla-bot
Copy link

cpython-cla-bot bot commented Feb 3, 2023

All commit authors signed the Contributor License Agreement.
CLA signed

@arhadthedev
Copy link
Member

arhadthedev commented Feb 3, 2023

@mrh1997 Could you sign the new CLA by clicking not signed button in the cpython-cla-bot's message, please?

@arhadthedev
Copy link
Member

Non-Linux tests failed with the following error:

======================================================================
ERROR: test_load (test.test_ctypes.test_loading.LoaderTest.test_load)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "D:\a\cpython\cpython\Lib\test\test_ctypes\test_loading.py", line 44, in test_load
    CDLL(CTypesTestPathLikeCls())
  File "D:\a\cpython\cpython\Lib\ctypes\__init__.py", line 367, in __init__
    if '/' in name or '\\' in name:
       ^^^^^^^^^^^
TypeError: argument of type 'CTypesTestPathLikeCls' is not iterable

I'm investigating it.

@arhadthedev
Copy link
Member

Fixed; there were two missed lines that continued to use name function argument directly instead of stringified self._name.

Lib/ctypes/__init__.py Outdated Show resolved Hide resolved
Lib/ctypes/__init__.py Show resolved Hide resolved
@bedevere-bot
Copy link

A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated.

Once you have made the requested changes, please leave a comment on this pull request containing the phrase I have made the requested changes; please review again. I will then notify any core developers who have left a review that you're ready for them to take another look at this pull request.

@kumaraditya303 kumaraditya303 self-assigned this Feb 5, 2023
@arhadthedev
Copy link
Member

I have made the requested changes; please review again.

@kumaraditya303 kumaraditya303 merged commit f7e9fba into python:main Feb 5, 2023
17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
expert-ctypes stdlib Python modules in the Lib dir
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

9 participants