-
-
Notifications
You must be signed in to change notification settings - Fork 34.5k
gh-143304: Fix ctypes.CDLL to honor handle parameter on POSIX systems #143318
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
Changes from 1 commit
8634db5
bb4c92e
d8b9ed3
32eb34d
6d95eff
d3f65b6
cdb8f6e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
The handle parameter was being ignored in the POSIX implementation of CDLL._load_library(), causing it to always call _dlopen() even when a valid handle was provided. This was a regression introduced in recent refactoring. This commit adds the missing handle check to match the Windows implementation behavior, and includes a regression test. Fixes gh-143304
- Loading branch information
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -106,6 +106,20 @@ def test_load_without_name_and_with_handle(self): | |||||
| lib = ctypes.WinDLL(name=None, handle=handle) | ||||||
| self.assertIs(handle, lib._handle) | ||||||
|
|
||||||
| @unittest.skipIf(os.name == "nt", 'POSIX-specific test') | ||||||
| def test_load_without_name_and_with_handle_posix(self): | ||||||
| # Test that CDLL honors the handle parameter on POSIX systems | ||||||
| # This is a regression test for gh-143304 | ||||||
| if libc_name is None: | ||||||
|
picnixz marked this conversation as resolved.
Outdated
|
||||||
| self.skipTest('could not find libc') | ||||||
| # First load a library normally to get a handle | ||||||
|
picnixz marked this conversation as resolved.
Outdated
|
||||||
| lib1 = CDLL(libc_name) | ||||||
| handle = lib1._handle | ||||||
| # Now create a new CDLL instance with the same handle | ||||||
| lib2 = CDLL(name=None, handle=handle) | ||||||
| # The handle should be used directly, not ignored | ||||||
| self.assertIs(handle, lib2._handle) | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Can you check whether there were tests for Python 3.12 where we had this handle? or if the tests were rewritten as well (see the PRs mentioned on the issue).
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I checked the
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok thx! |
||||||
|
|
||||||
| @unittest.skipUnless(os.name == "nt", 'Windows-specific test') | ||||||
| def test_1703286_A(self): | ||||||
| # On winXP 64-bit, advapi32 loads at an address that does | ||||||
|
|
||||||
Uh oh!
There was an error while loading. Please reload this page.