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 31
31
# define PYBIND11_INTERNALS_VERSION 4
32
32
#endif
33
33
34
- #ifndef PYBIND11_LOCAL_INTERNALS_VERSION
35
- # define PYBIND11_LOCAL_INTERNALS_VERSION 1
36
- #endif
37
-
38
34
PYBIND11_NAMESPACE_BEGIN (PYBIND11_NAMESPACE)
39
35
40
36
using ExceptionTranslator = void (*)(std::exception_ptr);
@@ -514,10 +510,6 @@ struct local_internals {
514
510
= static_cast <shared_loader_life_support_data *>(ptr)->loader_life_support_tls_key ;
515
511
}
516
512
#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
521
513
};
522
514
523
515
// / Works like `get_internals`, but for things which are locally registered.
@@ -531,14 +523,6 @@ inline local_internals &get_local_internals() {
531
523
return *locals;
532
524
}
533
525
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
-
542
526
// / Constructs a std::string with the given arguments, stores it in `internals`, and returns its
543
527
// / `c_str()`. Such strings objects have a long storage duration -- the internal strings are only
544
528
// / 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> &
69
69
return false ;
70
70
}
71
71
72
+ constexpr const char * function_capsule_name = " pybind11_funciton_capsule_v1" ;
73
+
72
74
inline bool is_function_record_capsule (const capsule &cap) {
73
75
// 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 );
75
80
}
76
81
77
82
#if defined(_MSC_VER)
@@ -508,7 +513,7 @@ class cpp_function : public function {
508
513
509
514
capsule rec_capsule (unique_rec.release (),
510
515
[](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 );
512
517
guarded_strdup.release ();
513
518
514
519
object scope_module;
@@ -677,7 +682,7 @@ class cpp_function : public function {
677
682
678
683
/* Iterator over the list of potentially admissible overloads */
679
684
const function_record *overloads = reinterpret_cast <function_record *>(
680
- PyCapsule_GetPointer (self, get_function_capsule_name () )),
685
+ PyCapsule_GetPointer (self, function_capsule_name )),
681
686
*it = overloads;
682
687
assert (overloads != nullptr );
683
688
You can’t perform that action at this time.
0 commit comments