Skip to content

gh-153903: Use @ctypes.util.wrap_dll_function() with pythonapi#154030

Merged
vstinner merged 5 commits into
python:mainfrom
vstinner:ctypes_wrap
Jul 19, 2026
Merged

gh-153903: Use @ctypes.util.wrap_dll_function() with pythonapi#154030
vstinner merged 5 commits into
python:mainfrom
vstinner:ctypes_wrap

Conversation

@vstinner

@vstinner vstinner commented Jul 18, 2026

Copy link
Copy Markdown
Member

Use the @ctypes.util.wrap_dll_function() decorator with ctypes.pythonapi to wrap Python C API functions in the test suite.

Use the @ctypes.util.wrap_dll_function() decorator with
ctypes.pythonapi to wrap Python C API functions in the test suite.
@vstinner

Copy link
Copy Markdown
Member Author

cc @ZeroIntensity

@ZeroIntensity ZeroIntensity left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The readability improvement is really nice

Comment thread Lib/test/test_capi/test_misc.py Outdated
@vstinner

Copy link
Copy Markdown
Member Author

The readability improvement is really nice

Readability is nice, but my first motivation is correctness. The new syntax reduces the risk of typo when declaring a ctypes function.

@vstinner
vstinner enabled auto-merge (squash) July 19, 2026 10:14
@vstinner

Copy link
Copy Markdown
Member Author

Tests / Windows / Build and test (x64, switch-case) (pull_request)Failing after 21m

Ah, test_logging failed. I just re-ran the job.

FAIL: test_rollover_at_midnight (test.test_logging.TimedRotatingFileHandlerTest.test_rollover_at_midnight)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "D:\a\cpython\cpython\Lib\test\test_logging.py", line 6749, in test_rollover_at_midnight
    self.assertIn(f'testing2 {i}', line)
    ~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^
AssertionError: 'testing2 0' not found in '2026-07-19 11:25:12,102 testing1 0\n'

@vstinner
vstinner merged commit 84897d2 into python:main Jul 19, 2026
87 of 89 checks passed
@vstinner
vstinner deleted the ctypes_wrap branch July 19, 2026 12:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

skip news tests Tests in the Lib/test dir

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants