Commit 77586fd6 by Wenzel Jakob

add version suffix to internal pybind11 data structures to avoid conflicts with future versions

parent 8d862b37
...@@ -34,12 +34,13 @@ PYBIND11_NOINLINE inline internals &get_internals() { ...@@ -34,12 +34,13 @@ PYBIND11_NOINLINE inline internals &get_internals() {
if (internals_ptr) if (internals_ptr)
return *internals_ptr; return *internals_ptr;
handle builtins(PyEval_GetBuiltins()); handle builtins(PyEval_GetBuiltins());
capsule caps(builtins["__pybind11__"]); const char *id = PYBIND11_INTERNALS_ID;
capsule caps(builtins[id]);
if (caps.check()) { if (caps.check()) {
internals_ptr = caps; internals_ptr = caps;
} else { } else {
internals_ptr = new internals(); internals_ptr = new internals();
builtins["__pybind11__"] = capsule(internals_ptr); builtins[id] = capsule(internals_ptr);
} }
return *internals_ptr; return *internals_ptr;
} }
......
...@@ -110,6 +110,10 @@ ...@@ -110,6 +110,10 @@
#endif #endif
#define PYBIND11_TRY_NEXT_OVERLOAD ((PyObject *) 1) // special failure return code #define PYBIND11_TRY_NEXT_OVERLOAD ((PyObject *) 1) // special failure return code
#define PYBIND11_STRINGIFY(x) #x
#define PYBIND11_TOSTRING(x) PYBIND11_STRINGIFY(x)
#define PYBIND11_INTERNALS_ID "__pybind11_" \
PYBIND11_TOSTRING(PYBIND11_VERSION_MAJOR) "_" PYBIND11_TOSTRING(PYBIND11_VERSION_MINOR) "__"
#define PYBIND11_PLUGIN(name) \ #define PYBIND11_PLUGIN(name) \
static PyObject *pybind11_init(); \ static PyObject *pybind11_init(); \
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment