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
1769ea42
Commit
1769ea42
authored
Mar 15, 2017
by
Dean Moldovan
Committed by
GitHub
Mar 15, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add __module__ attribute to all pybind11 builtin types (#729)
Fixes #728.
parent
9f383a54
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
0 deletions
+14
-0
include/pybind11/class_support.h
+6
-0
tests/test_modules.py
+8
-0
No files found.
include/pybind11/class_support.h
View file @
1769ea42
...
@@ -57,6 +57,8 @@ inline PyTypeObject *make_static_property_type() {
...
@@ -57,6 +57,8 @@ inline PyTypeObject *make_static_property_type() {
if
(
PyType_Ready
(
type
)
<
0
)
if
(
PyType_Ready
(
type
)
<
0
)
pybind11_fail
(
"make_static_property_type(): failure in PyType_Ready()!"
);
pybind11_fail
(
"make_static_property_type(): failure in PyType_Ready()!"
);
setattr
((
PyObject
*
)
type
,
"__module__"
,
str
(
"pybind11_builtins"
));
return
type
;
return
type
;
}
}
...
@@ -170,6 +172,8 @@ inline PyTypeObject* make_default_metaclass() {
...
@@ -170,6 +172,8 @@ inline PyTypeObject* make_default_metaclass() {
if
(
PyType_Ready
(
type
)
<
0
)
if
(
PyType_Ready
(
type
)
<
0
)
pybind11_fail
(
"make_default_metaclass(): failure in PyType_Ready()!"
);
pybind11_fail
(
"make_default_metaclass(): failure in PyType_Ready()!"
);
setattr
((
PyObject
*
)
type
,
"__module__"
,
str
(
"pybind11_builtins"
));
return
type
;
return
type
;
}
}
...
@@ -270,6 +274,8 @@ inline PyObject *make_object_base_type(size_t instance_size) {
...
@@ -270,6 +274,8 @@ inline PyObject *make_object_base_type(size_t instance_size) {
if
(
PyType_Ready
(
type
)
<
0
)
if
(
PyType_Ready
(
type
)
<
0
)
pybind11_fail
(
"PyType_Ready failed in make_object_base_type():"
+
error_string
());
pybind11_fail
(
"PyType_Ready failed in make_object_base_type():"
+
error_string
());
setattr
((
PyObject
*
)
type
,
"__module__"
,
str
(
"pybind11_builtins"
));
assert
(
!
PyType_HasFeature
(
type
,
Py_TPFLAGS_HAVE_GC
));
assert
(
!
PyType_HasFeature
(
type
,
Py_TPFLAGS_HAVE_GC
));
return
(
PyObject
*
)
heap_type
;
return
(
PyObject
*
)
heap_type
;
}
}
...
...
tests/test_modules.py
View file @
1769ea42
...
@@ -52,3 +52,11 @@ def test_importing():
...
@@ -52,3 +52,11 @@ def test_importing():
assert
OD
is
OrderedDict
assert
OD
is
OrderedDict
assert
str
(
OD
([(
1
,
'a'
),
(
2
,
'b'
)]))
==
"OrderedDict([(1, 'a'), (2, 'b')])"
assert
str
(
OD
([(
1
,
'a'
),
(
2
,
'b'
)]))
==
"OrderedDict([(1, 'a'), (2, 'b')])"
def
test_pydoc
():
"""Pydoc needs to be able to provide help() for everything inside a pybind11 module"""
import
pybind11_tests
import
pydoc
assert
pydoc
.
text
.
docmodule
(
pybind11_tests
)
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