Skip to content

Commit e49aaea

Browse files
committed
Revert internal version bump
1 parent 1f18585 commit e49aaea

File tree

4 files changed

+24
-5
lines changed

4 files changed

+24
-5
lines changed

include/pybind11/detail/class.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,12 +226,14 @@ extern "C" inline void pybind11_meta_dealloc(PyObject *obj) {
226226
local_internals.registered_types_cpp.erase(tinfo->cpptype);
227227
} else {
228228
internals.registered_types_cpp.erase(tindex);
229+
#if PYBIND11_INTERNALS_VERSION >= 12
229230
internals.registered_types_cpp_fast.erase(tinfo->cpptype);
230231
for (const std::type_info *alias : tinfo->alias_chain) {
231232
auto num_erased = internals.registered_types_cpp_fast.erase(alias);
232233
(void) num_erased;
233234
assert(num_erased > 0);
234235
}
236+
#endif
235237
}
236238
internals.registered_types_py.erase(tinfo->type);
237239

include/pybind11/detail/internals.h

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,11 @@
3939
/// further ABI-incompatible changes may be made before the ABI is officially
4040
/// changed to the new version.
4141
#ifndef PYBIND11_INTERNALS_VERSION
42-
# define PYBIND11_INTERNALS_VERSION 12
42+
# define PYBIND11_INTERNALS_VERSION 11
4343
#endif
4444

45-
#if PYBIND11_INTERNALS_VERSION < 12
46-
# error "PYBIND11_INTERNALS_VERSION 12 is the minimum for all platforms for pybind11v3."
45+
#if PYBIND11_INTERNALS_VERSION < 11
46+
# error "PYBIND11_INTERNALS_VERSION 11 is the minimum for all platforms for pybind11v3."
4747
#endif
4848

4949
PYBIND11_NAMESPACE_BEGIN(PYBIND11_NAMESPACE)
@@ -242,12 +242,14 @@ struct internals {
242242
pymutex mutex;
243243
pymutex exception_translator_mutex;
244244
#endif
245+
#if PYBIND11_INTERNALS_VERSION >= 12
245246
// non-normative but fast "hint" for registered_types_cpp. Meant
246247
// to be used as the first level of a two-level lookup: successful
247248
// lookups are correct, but unsuccessful lookups need to try
248249
// registered_types_cpp and then backfill this map if they find
249250
// anything.
250251
fast_type_map<type_info *> registered_types_cpp_fast;
252+
#endif
251253

252254
// std::type_index -> pybind11's type information
253255
type_map<type_info *> registered_types_cpp;
@@ -273,6 +275,9 @@ struct internals {
273275
PyObject *instance_base = nullptr;
274276
// Unused if PYBIND11_SIMPLE_GIL_MANAGEMENT is defined:
275277
thread_specific_storage<PyThreadState> tstate;
278+
#if PYBIND11_INTERNALS_VERSION <= 11
279+
thread_specific_storage<loader_life_support> loader_life_support_tls; // OBSOLETE (PR #5830)
280+
#endif
276281
// Unused if PYBIND11_SIMPLE_GIL_MANAGEMENT is defined:
277282
PyInterpreterState *istate = nullptr;
278283

@@ -353,6 +358,7 @@ struct type_info {
353358
void *(*module_local_load)(PyObject *, const type_info *) = nullptr;
354359
holder_enum_t holder_enum_v = holder_enum_t::undefined;
355360

361+
#if PYBIND11_INTERNALS_VERSION >= 12
356362
// When a type appears in multiple DSOs,
357363
// internals::registered_types_cpp_fast will have multiple distinct
358364
// keys (the std::type_info from each DSO) mapped to the same
@@ -363,6 +369,7 @@ struct type_info {
363369
// nb_alias_chain` added in
364370
// https://github.com/wjakob/nanobind/commit/b515b1f7f2f4ecc0357818e6201c94a9f4cbfdc2
365371
std::forward_list<const std::type_info *> alias_chain;
372+
#endif
366373

367374
/* A simple type never occurs as a (direct or indirect) parent
368375
* of a class that makes use of multiple inheritance.

include/pybind11/detail/type_caster_base.h

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -227,26 +227,32 @@ inline detail::type_info *get_global_type_info_lock_held(const std::type_info &t
227227
// next time.
228228
detail::type_info *type_info = nullptr;
229229
auto &internals = get_internals();
230+
#if PYBIND11_INTERNALS_VERSION >= 12
230231
auto &fast_types = internals.registered_types_cpp_fast;
232+
#endif
231233
auto &types = internals.registered_types_cpp;
234+
#if PYBIND11_INTERNALS_VERSION >= 12
232235
auto fast_it = fast_types.find(&tp);
233236
if (fast_it != fast_types.end()) {
234-
#ifndef NDEBUG
237+
# ifndef NDEBUG
235238
auto types_it = types.find(std::type_index(tp));
236239
assert(types_it != types.end());
237240
assert(types_it->second == fast_it->second);
238-
#endif
241+
# endif
239242
return fast_it->second;
240243
}
244+
#endif // PYBIND11_INTERNALS_VERSION >= 12
241245

242246
auto it = types.find(std::type_index(tp));
243247
if (it != types.end()) {
248+
#if PYBIND11_INTERNALS_VERSION >= 12
244249
// We found the type in the slow map but not the fast one, so
245250
// some other DSO added it (otherwise it would be in the fast
246251
// map under &tp) and therefore we must be an alias. Record
247252
// that.
248253
it->second->alias_chain.push_front(&tp);
249254
fast_types.emplace(&tp, it->second);
255+
#endif
250256
type_info = it->second;
251257
}
252258
return type_info;

include/pybind11/pybind11.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1692,7 +1692,9 @@ class generic_type : public object {
16921692
local_internals.registered_types_cpp[rec.type] = tinfo;
16931693
} else {
16941694
internals.registered_types_cpp[tindex] = tinfo;
1695+
#if PYBIND11_INTERNALS_VERSION >= 12
16951696
internals.registered_types_cpp_fast[rec.type] = tinfo;
1697+
#endif
16961698
}
16971699

16981700
PYBIND11_WARNING_PUSH
@@ -2199,7 +2201,9 @@ class class_ : public detail::generic_type {
21992201
type_info *const val
22002202
= internals.registered_types_cpp[std::type_index(typeid(type))];
22012203
internals.registered_types_cpp[std::type_index(typeid(type_alias))] = val;
2204+
#if PYBIND11_INTERNALS_VERSION >= 12
22022205
internals.registered_types_cpp_fast[&typeid(type_alias)] = val;
2206+
#endif
22032207
}
22042208
});
22052209
}

0 commit comments

Comments
 (0)