Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
gaoqiong
pybind11
Commits
aa1b316f
Commit
aa1b316f
authored
Mar 30, 2017
by
Wenzel Jakob
Browse files
adjusted module::add_object signature so that it accepts a py::handle
parent
194d8b99
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
2 additions
and
3 deletions
+2
-3
include/pybind11/pybind11.h
include/pybind11/pybind11.h
+2
-3
No files found.
include/pybind11/pybind11.h
View file @
aa1b316f
...
...
@@ -771,13 +771,12 @@ public:
//
// overwrite should almost always be false: attempting to overwrite objects that pybind11 has
// established will, in most cases, break things.
PYBIND11_NOINLINE
void
add_object
(
const
char
*
name
,
object
&
obj
,
bool
overwrite
=
false
)
{
PYBIND11_NOINLINE
void
add_object
(
const
char
*
name
,
handle
obj
,
bool
overwrite
=
false
)
{
if
(
!
overwrite
&&
hasattr
(
*
this
,
name
))
pybind11_fail
(
"Error during initialization: multiple incompatible definitions with name
\"
"
+
std
::
string
(
name
)
+
"
\"
"
);
obj
.
inc_ref
();
// PyModule_AddObject() steals a reference
PyModule_AddObject
(
ptr
(),
name
,
obj
.
ptr
());
PyModule_AddObject
(
ptr
(),
name
,
obj
.
inc_ref
().
ptr
()
/* steals a reference */
);
}
};
...
...
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