GeezerVison is showing github.com — fixup for __module__ attribute setting · ssam18/python@2e3ae9d
File tree
Expand file treeCollapse file tree
Open diff view settings
include/boost/python/detail
Expand file treeCollapse file tree
Open diff view settings
Collapse file
Copy file name to clipboardExpand all lines: include/boost/python/detail/module_base.hpp +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -27,7 +27,7 @@ class BOOST_PYTHON_DECL module_base |
27 | 27 | inline ref object() const; |
28 | 28 |
|
29 | 29 | protected: |
30 | | - void generic_add_class(ref class_obj); |
| 30 | + void add_class(ref const& class_obj); |
31 | 31 |
|
32 | 32 | private: |
33 | 33 | ref m_module; |
|
Collapse file
Copy file name to clipboardExpand all lines: src/module.cpp +12-7Lines changed: 12 additions & 7 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -45,15 +45,20 @@ void module_base::add_type(ref x) |
45 | 45 | add((PyTypeObject*)x.release()); |
46 | 46 | } |
47 | 47 |
|
48 | | -void module_base::generic_add_class(ref class_obj) |
| 48 | +void module_base::add_class(ref const& class_obj) |
49 | 49 | { |
50 | | - Py_INCREF(class_obj.get()); |
51 | 50 | this->add_type(class_obj); |
52 | | - ref module_name(PyObject_GetAttrString(m_module.get(), |
53 | | - const_cast<char*>("__name__"))); |
54 | | - int status = PyObject_SetAttrString(class_obj.get(), |
55 | | - const_cast<char*>("__module__"), module_name.get()); |
56 | | - if (status == -1) throw_error_already_set(); |
| 51 | + |
| 52 | + ref module_name( |
| 53 | + PyObject_GetAttrString( |
| 54 | + m_module.get(), const_cast<char*>("__name__")) |
| 55 | + ); |
| 56 | + |
| 57 | + int status = PyObject_SetAttrString( |
| 58 | + class_obj.get(), const_cast<char*>("__module__"), module_name.get()); |
| 59 | + |
| 60 | + if (status == -1) |
| 61 | + throw_error_already_set(); |
57 | 62 | } |
58 | 63 |
|
59 | 64 | PyMethodDef module_base::initial_methods[] = { { 0, 0, 0, 0 } }; |
|