Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
PyPy
pypy
Commits
2664d29f2ece
Commit
77384d83
authored
Jan 01, 2023
by
Matti Picus
Browse files
allow creating ctypes.py_object() on a weakref (issue 3883)
parent
5eff3deb0aff
Pipeline
#60345
passed with stage
in 8 minutes and 44 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
extra_tests/ctypes_tests/test_structures.py
View file @
2664d29f
...
...
@@ -2,6 +2,7 @@ from ctypes import *
import
pytest
import
sys
import
weakref
def
test_subclass_initializer
():
...
...
@@ -214,3 +215,14 @@ def test_memoryview():
assert
mv
.
format
==
'T{>h:a:>h:b:}'
assert
mv
.
shape
==
(
2
,
3
)
assert
mv
.
itemsize
==
4
def
test_weakref
():
# issue 3883: py_object of weakref
class
Empty
():
pass
e
=
Empty
()
r
=
weakref
.
ref
(
e
)
pr
=
py_object
(
r
)
assert
pr
.
value
is
e
lib_pypy/_ctypes/primitive.py
View file @
2664d29f
...
...
@@ -51,7 +51,10 @@ class GlobalPyobjContainer(object):
def
add
(
self
,
obj
):
num
=
len
(
self
.
objs
)
self
.
objs
.
append
(
weakref
.
ref
(
obj
))
if
isinstance
(
obj
,
weakref
.
ReferenceType
):
self
.
objs
.
append
(
obj
)
else
:
self
.
objs
.
append
(
weakref
.
ref
(
obj
))
return
num
def
get
(
self
,
num
):
...
...
Matti Picus
@mattip
mentioned in issue
#3883 (closed)
·
Jan 01, 2023
mentioned in issue
#3883 (closed)
mentioned in issue #3883
Toggle commit list
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment