File tree Expand file tree Collapse file tree 2 files changed +8
-19
lines changed Expand file tree Collapse file tree 2 files changed +8
-19
lines changed Original file line number Diff line number Diff line change 3131# define PYBIND11_INTERNALS_VERSION 4
3232#endif
3333
34- #ifndef PYBIND11_LOCAL_INTERNALS_VERSION
35- # define PYBIND11_LOCAL_INTERNALS_VERSION 1
36- #endif
37-
3834PYBIND11_NAMESPACE_BEGIN (PYBIND11_NAMESPACE)
3935
4036using ExceptionTranslator = void (*)(std::exception_ptr);
@@ -514,10 +510,6 @@ struct local_internals {
514510 = static_cast <shared_loader_life_support_data *>(ptr)->loader_life_support_tls_key ;
515511 }
516512#endif // defined(WITH_THREAD) && PYBIND11_INTERNALS_VERSION == 4
517-
518- #if PYBIND11_LOCAL_INTERNALS_VERSION >= 1
519- const char *function_capsule_name = strdup(" pybind11_function_capsule" );
520- #endif
521513};
522514
523515// / Works like `get_internals`, but for things which are locally registered.
@@ -531,14 +523,6 @@ inline local_internals &get_local_internals() {
531523 return *locals;
532524}
533525
534- inline const char *get_function_capsule_name () {
535- #if PYBIND11_LOCAL_INTERNALS_VERSION >= 1
536- return get_local_internals ().function_capsule_name ;
537- #else
538- return nullptr ;
539- #endif
540- }
541-
542526// / Constructs a std::string with the given arguments, stores it in `internals`, and returns its
543527// / `c_str()`. Such strings objects have a long storage duration -- the internal strings are only
544528// / cleared when the program exits or after interpreter shutdown (when embedding), and so are
Original file line number Diff line number Diff line change @@ -69,9 +69,14 @@ inline bool apply_exception_translators(std::forward_list<ExceptionTranslator> &
6969 return false ;
7070}
7171
72+ constexpr const char * function_capsule_name = " pybind11_funciton_capsule_v1" ;
73+
7274inline bool is_function_record_capsule (const capsule &cap) {
7375 // Compare the pointers, not the values to ensure that each extension is unique
74- return cap.name () == get_function_capsule_name ();
76+ if (cap.name () == nullptr ) {
77+ return false ;
78+ }
79+ return (std::strcmp (cap.name (), function_capsule_name) == 0 );
7580}
7681
7782#if defined(_MSC_VER)
@@ -508,7 +513,7 @@ class cpp_function : public function {
508513
509514 capsule rec_capsule (unique_rec.release (),
510515 [](void *ptr) { destruct ((detail::function_record *) ptr); });
511- rec_capsule.set_name (detail::get_function_capsule_name () );
516+ rec_capsule.set_name (detail::function_capsule_name );
512517 guarded_strdup.release ();
513518
514519 object scope_module;
@@ -677,7 +682,7 @@ class cpp_function : public function {
677682
678683 /* Iterator over the list of potentially admissible overloads */
679684 const function_record *overloads = reinterpret_cast <function_record *>(
680- PyCapsule_GetPointer (self, get_function_capsule_name () )),
685+ PyCapsule_GetPointer (self, function_capsule_name )),
681686 *it = overloads;
682687 assert (overloads != nullptr );
683688
You can’t perform that action at this time.
0 commit comments