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
5116b02e
Commit
5116b02e
authored
Sep 05, 2015
by
Wenzel Jakob
Browse files
python 2.7 fix
parent
57082210
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
6 additions
and
3 deletions
+6
-3
example/example2.cpp
example/example2.cpp
+1
-1
include/pybind/pybind.h
include/pybind/pybind.h
+5
-2
No files found.
example/example2.cpp
View file @
5116b02e
...
...
@@ -100,7 +100,7 @@ const int Example2::value2 = 5;
void
init_ex2
(
py
::
module
&
m
)
{
/* No constructor is explicitly defined below. An exception is raised when
trying to construct it directly from Python */
py
::
class_
<
Example2
>
(
m
,
"Example2"
)
py
::
class_
<
Example2
>
(
m
,
"Example2"
,
"Example 2 documentation"
)
.
def
(
"get_dict"
,
&
Example2
::
get_dict
,
"Return a Python dictionary"
)
.
def
(
"get_dict_2"
,
&
Example2
::
get_dict_2
,
"Return a C++ dictionary"
)
.
def
(
"get_list"
,
&
Example2
::
get_list
,
"Return a Python list"
)
...
...
include/pybind/pybind.h
View file @
5116b02e
...
...
@@ -510,6 +510,11 @@ public:
type
->
ht_type
.
tp_as_sequence
=
&
type
->
as_sequence
;
type
->
ht_type
.
tp_as_mapping
=
&
type
->
as_mapping
;
type
->
ht_type
.
tp_base
=
(
PyTypeObject
*
)
parent
;
if
(
doc
)
{
size_t
size
=
strlen
(
doc
)
+
1
;
type
->
ht_type
.
tp_doc
=
(
char
*
)
PyObject_MALLOC
(
size
);
memcpy
((
void
*
)
type
->
ht_type
.
tp_doc
,
doc
,
size
);
}
Py_XINCREF
(
parent
);
if
(
PyType_Ready
(
&
type
->
ht_type
)
<
0
)
...
...
@@ -525,8 +530,6 @@ public:
type_info
.
type_size
=
type_size
;
type_info
.
init_holder
=
init_holder
;
attr
(
"__pybind__"
)
=
capsule
(
&
type_info
);
if
(
doc
)
attr
(
"__doc__"
)
=
pybind
::
str
(
doc
);
scope
.
attr
(
name
)
=
*
this
;
}
...
...
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