1313
1414namespace boost { namespace python {
1515
16- class BOOST_PYTHON_DECL scope
17- : public object
16+ namespace detail
17+ {
18+ // Making this a namespace-scope variable to avoid Cygwin issues.
19+ // Use a PyObject* to avoid problems with static destruction after Py_Finalize
20+ extern BOOST_PYTHON_DECL PyObject* current_scope;
21+ }
22+
23+ class scope
24+ : public object
1825{
1926 public:
2027 inline scope (scope const &);
@@ -27,32 +34,27 @@ class BOOST_PYTHON_DECL scope
2734
2835 private: // unimplemented functions
2936 void operator =(scope const &);
30-
31- private: // static members
32-
33- // Use a PyObject* to avoid problems with static destruction after Py_Finalize
34- static PyObject* current_scope;
3537};
3638
3739inline scope::scope (object const & new_scope)
3840 : object(new_scope)
39- , m_previous_scope(current_scope)
41+ , m_previous_scope(detail:: current_scope)
4042{
41- current_scope = python::incref (new_scope.ptr ());
43+ detail:: current_scope = python::incref (new_scope.ptr ());
4244}
4345
4446inline scope::scope ()
4547 : object(detail::borrowed_reference(
46- current_scope ? current_scope : Py_None
48+ detail:: current_scope ? detail:: current_scope : Py_None
4749 ))
48- , m_previous_scope(python::xincref(current_scope))
50+ , m_previous_scope(python::xincref(detail:: current_scope))
4951{
5052}
5153
5254inline scope::~scope ()
5355{
54- python::xdecref (current_scope);
55- current_scope = m_previous_scope;
56+ python::xdecref (detail:: current_scope);
57+ detail:: current_scope = m_previous_scope;
5658}
5759
5860namespace converter
@@ -67,9 +69,9 @@ namespace converter
6769// Placing this after the specialization above suppresses a CWPro8.3 bug
6870inline scope::scope (scope const & new_scope)
6971 : object(new_scope)
70- , m_previous_scope(current_scope)
72+ , m_previous_scope(detail:: current_scope)
7173{
72- current_scope = python::incref (new_scope.ptr ());
74+ detail:: current_scope = python::incref (new_scope.ptr ());
7375}
7476
7577}} // namespace boost::python
0 commit comments