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
11f756f5
Commit
11f756f5
authored
Sep 16, 2020
by
Henry Fredrick Schreiner
Committed by
Henry Schreiner
Sep 16, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: type bug intruduced in #2492
This now tests the old form too, and fixes the bug introduced.
parent
dec33c29
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
12 additions
and
3 deletions
+12
-3
include/pybind11/pytypes.h
+2
-3
tests/test_class.cpp
+4
-0
tests/test_class.py
+6
-0
No files found.
include/pybind11/pytypes.h
View file @
11f756f5
...
...
@@ -153,7 +153,7 @@ public:
/// Return the object's current reference count
int
ref_count
()
const
{
return
static_cast
<
int
>
(
Py_REFCNT
(
derived
().
ptr
()));
}
PYBIND11_DEPRECATED
(
"Call py::type::handle_of(h) or py::type::of(h) instead of h.get_type()"
)
// TODO
PYBIND11_DEPRECATED("Call py::type::handle_of(h) or py::type::of(h) instead of h.get_type()")
handle
get_type
()
const
;
private
:
...
...
@@ -1580,8 +1580,7 @@ template <typename D>
str_attr_accessor
object_api
<
D
>::
doc
()
const
{
return
attr
(
"__doc__"
);
}
template
<
typename
D
>
PYBIND11_DEPRECATED
(
"Use py::type::of(h) instead of h.get_type()"
)
handle
object_api
<
D
>::
get_type
()
const
{
return
type
::
handle_of
(
*
this
);
}
handle
object_api
<
D
>::
get_type
()
const
{
return
type
::
handle_of
(
derived
());
}
template
<
typename
D
>
bool
object_api
<
D
>::
rich_compare
(
object_api
const
&
other
,
int
value
)
const
{
...
...
tests/test_class.cpp
View file @
11f756f5
...
...
@@ -152,6 +152,10 @@ TEST_SUBMODULE(class_, m) {
return
py
::
type
::
of
(
ob
);
});
m
.
def
(
"get_type_classic"
,
[](
py
::
handle
h
)
{
return
h
.
get_type
();
});
m
.
def
(
"as_type"
,
[](
py
::
object
ob
)
{
auto
tp
=
py
::
type
(
ob
);
if
(
py
::
isinstance
<
py
::
type
>
(
ob
))
...
...
tests/test_class.py
View file @
11f756f5
...
...
@@ -45,6 +45,12 @@ def test_type_of_py():
assert
m
.
get_type_of
(
int
)
==
type
def
test_type_of_classic
():
assert
m
.
get_type_classic
(
1
)
==
int
assert
m
.
get_type_classic
(
m
.
DerivedClass1
())
==
m
.
DerivedClass1
assert
m
.
get_type_classic
(
int
)
==
type
def
test_type_of_py_nodelete
():
# If the above test deleted the class, this will segfault
assert
m
.
get_type_of
(
m
.
DerivedClass1
())
==
m
.
DerivedClass1
...
...
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