mirror of
https://github.com/pybind/pybind11.git
synced 2024-11-25 22:52:01 +00:00
add version suffix to internal pybind11 data structures to avoid conflicts with future versions
This commit is contained in:
parent
8d862b37b4
commit
77586fd6a2
@ -34,12 +34,13 @@ PYBIND11_NOINLINE inline internals &get_internals() {
|
||||
if (internals_ptr)
|
||||
return *internals_ptr;
|
||||
handle builtins(PyEval_GetBuiltins());
|
||||
capsule caps(builtins["__pybind11__"]);
|
||||
const char *id = PYBIND11_INTERNALS_ID;
|
||||
capsule caps(builtins[id]);
|
||||
if (caps.check()) {
|
||||
internals_ptr = caps;
|
||||
} else {
|
||||
internals_ptr = new internals();
|
||||
builtins["__pybind11__"] = capsule(internals_ptr);
|
||||
builtins[id] = capsule(internals_ptr);
|
||||
}
|
||||
return *internals_ptr;
|
||||
}
|
||||
|
@ -110,6 +110,10 @@
|
||||
#endif
|
||||
|
||||
#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) \
|
||||
static PyObject *pybind11_init(); \
|
||||
|
Loading…
Reference in New Issue
Block a user