8000 GH-81061: Fix refcount issue when returning `None` from a `ctypes.py_object` callback by dgelessus · Pull Request #13364 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

GH-81061: Fix refcount issue when returning None from a ctypes.py_object callback #13364

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

Merged
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Apply suggestions from code review
Co-authored-by: Eryk Sun <eryksun@gmail.com>
  • Loading branch information
dgelessus and eryksun committed Jan 3, 2023
commit fb17c68cd049f718b75fca287a6c058dcd4c04f6
7 changes: 3 additions & 4 deletions Lib/test/test_ctypes/test_refcounts.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,15 +99,14 @@ def func(a, b):

@support.refcount_test
def test_callback_py_object_none_return(self):
"""Test that returning ``None`` from a ``py_object`` callback
does not affect ``None``'s refcount (bpo-36880)."""
# bpo-36880: test that returning None from a py_object callback
# does not decrement the refcount of None.

import sys

for FUNCTYPE in (ctypes.CFUNCTYPE, ctypes.PYFUNCTYPE):
with self.subTest(FUNCTYPE=FUNCTYPE):
proto = FUNCTYPE(ctypes.py_object)
@proto
@FUNCTYPE(ctypes.py_object)
def func():
return None

Expand Down
0