Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
P
pybind11
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
open
pybind11
Commits
64cb699e
Commit
64cb699e
authored
Dec 26, 2016
by
Wenzel Jakob
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
disable dynamic attribute test on pypy
parent
a3fec901
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
11 additions
and
0 deletions
+11
-0
include/pybind11/pybind11.h
+5
-0
tests/test_methods_and_attributes.cpp
+2
-0
tests/test_methods_and_attributes.py
+2
-0
tests/test_pickling.cpp
+2
-0
No files found.
include/pybind11/pybind11.h
View file @
64cb699e
...
@@ -785,6 +785,11 @@ protected:
...
@@ -785,6 +785,11 @@ protected:
/* Support dynamic attributes */
/* Support dynamic attributes */
if
(
rec
->
dynamic_attr
)
{
if
(
rec
->
dynamic_attr
)
{
#if defined(PYPY_VERSION)
pybind11_fail
(
std
::
string
(
rec
->
name
)
+
": dynamic attributes are "
"currently not supported in "
"conunction with PyPy!"
);
#endif
type
->
ht_type
.
tp_flags
|=
Py_TPFLAGS_HAVE_GC
;
type
->
ht_type
.
tp_flags
|=
Py_TPFLAGS_HAVE_GC
;
type
->
ht_type
.
tp_dictoffset
=
type
->
ht_type
.
tp_basicsize
;
// place the dict at the end
type
->
ht_type
.
tp_dictoffset
=
type
->
ht_type
.
tp_basicsize
;
// place the dict at the end
type
->
ht_type
.
tp_basicsize
+=
sizeof
(
PyObject
*
);
// and allocate enough space for it
type
->
ht_type
.
tp_basicsize
+=
sizeof
(
PyObject
*
);
// and allocate enough space for it
...
...
tests/test_methods_and_attributes.cpp
View file @
64cb699e
...
@@ -176,9 +176,11 @@ test_initializer methods_and_attributes([](py::module &m) {
...
@@ -176,9 +176,11 @@ test_initializer methods_and_attributes([](py::module &m) {
.
def_property_readonly
(
"rvalue"
,
&
TestPropRVP
::
get_rvalue
)
.
def_property_readonly
(
"rvalue"
,
&
TestPropRVP
::
get_rvalue
)
.
def_property_readonly_static
(
"static_rvalue"
,
[](
py
::
object
)
{
return
SimpleValue
();
});
.
def_property_readonly_static
(
"static_rvalue"
,
[](
py
::
object
)
{
return
SimpleValue
();
});
#if !defined(PYPY_VERSION)
py
::
class_
<
DynamicClass
>
(
m
,
"DynamicClass"
,
py
::
dynamic_attr
())
py
::
class_
<
DynamicClass
>
(
m
,
"DynamicClass"
,
py
::
dynamic_attr
())
.
def
(
py
::
init
());
.
def
(
py
::
init
());
py
::
class_
<
CppDerivedDynamicClass
,
DynamicClass
>
(
m
,
"CppDerivedDynamicClass"
)
py
::
class_
<
CppDerivedDynamicClass
,
DynamicClass
>
(
m
,
"CppDerivedDynamicClass"
)
.
def
(
py
::
init
());
.
def
(
py
::
init
());
#endif
});
});
tests/test_methods_and_attributes.py
View file @
64cb699e
...
@@ -180,6 +180,8 @@ def test_dynamic_attributes():
...
@@ -180,6 +180,8 @@ def test_dynamic_attributes():
assert
cstats
.
alive
()
==
0
assert
cstats
.
alive
()
==
0
# https://bitbucket.org/pypy/pypy/issues/2447
@pytest.unsupported_on_pypy
def
test_cyclic_gc
():
def
test_cyclic_gc
():
from
pybind11_tests
import
DynamicClass
from
pybind11_tests
import
DynamicClass
...
...
tests/test_pickling.cpp
View file @
64cb699e
...
@@ -57,6 +57,7 @@ test_initializer pickling([](py::module &m) {
...
@@ -57,6 +57,7 @@ test_initializer pickling([](py::module &m) {
p
.
setExtra2
(
t
[
2
].
cast
<
int
>
());
p
.
setExtra2
(
t
[
2
].
cast
<
int
>
());
});
});
#if !defined(PYPY_VERSION)
py
::
class_
<
PickleableWithDict
>
(
m
,
"PickleableWithDict"
,
py
::
dynamic_attr
())
py
::
class_
<
PickleableWithDict
>
(
m
,
"PickleableWithDict"
,
py
::
dynamic_attr
())
.
def
(
py
::
init
<
std
::
string
>
())
.
def
(
py
::
init
<
std
::
string
>
())
.
def_readwrite
(
"value"
,
&
PickleableWithDict
::
value
)
.
def_readwrite
(
"value"
,
&
PickleableWithDict
::
value
)
...
@@ -78,4 +79,5 @@ test_initializer pickling([](py::module &m) {
...
@@ -78,4 +79,5 @@ test_initializer pickling([](py::module &m) {
/* Assign Python state */
/* Assign Python state */
self
.
attr
(
"__dict__"
)
=
t
[
2
];
self
.
attr
(
"__dict__"
)
=
t
[
2
];
});
});
#endif
});
});
Write
Preview
Markdown
is supported
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