Skip to content

Commit 8763fd1

Browse files
committed
scope default constructor gets current scope; killed scope::get()
[SVN r14599]
1 parent 5976005 commit 8763fd1

2 files changed

Lines changed: 11 additions & 8 deletions

File tree

include/boost/python/scope.hpp

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ class BOOST_PYTHON_DECL scope : public object, noncopyable
1616
{
1717
public:
1818
inline scope(object const&);
19+
inline scope();
1920
inline ~scope();
20-
static inline object get();
2121

2222
private: // data members
2323
PyObject* m_previous_scope;
@@ -35,15 +35,18 @@ inline scope::scope(object const& new_scope)
3535
current_scope = python::incref(new_scope.ptr());
3636
}
3737

38-
inline scope::~scope()
38+
inline scope::scope()
39+
: object(detail::borrowed_reference(
40+
current_scope
41+
))
42+
, m_previous_scope(python::incref(current_scope))
3943
{
40-
python::decref(current_scope);
41-
current_scope = m_previous_scope;
4244
}
4345

44-
inline object scope::get()
46+
inline scope::~scope()
4547
{
46-
return object(detail::borrowed_reference(current_scope));
48+
python::decref(current_scope);
49+
current_scope = m_previous_scope;
4750
}
4851

4952
namespace converter

src/module.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ namespace boost { namespace python { namespace detail {
1919
module_base::module_base(const char* name)
2020
: m_module(
2121
allow_null(python::borrowed(
22-
scope::get().ptr()
22+
scope().ptr()
2323
)))
2424
{
2525
}
@@ -94,6 +94,6 @@ BOOST_PYTHON_DECL void init_module(char const* name, void(*init_function)())
9494

9595
namespace boost { namespace python {
9696

97-
BOOST_PYTHON_DECL PyObject* scope::current_scope;
97+
BOOST_PYTHON_DECL PyObject* scope::current_scope = Py_None;
9898

9999
}}

0 commit comments

Comments
 (0)