Skip to content

Commit

Permalink
Python 3.12 fix
Browse files Browse the repository at this point in the history
Crash in ``Py_AtExit()`` callback -> ``PyMem_Free`` (the GIL isn't held
at this point anymore, and Python 3.12 seems to have become more strict
about this..). So we cannot use the Python memory allocator for
``nb_internals`` members anymore.
  • Loading branch information
wjakob committed May 10, 2023
1 parent 2cb5338 commit f8fc46b
Showing 1 changed file with 1 addition and 7 deletions.
8 changes: 1 addition & 7 deletions src/nb_internals.h
Original file line number Diff line number Diff line change
Expand Up @@ -126,15 +126,9 @@ template <typename T> class py_allocator {
void deallocate(T *p, size_type /*n*/) noexcept { PyMem_Free(p); }
};

template <class T1, class T2>
bool operator==(const py_allocator<T1> &, const py_allocator<T2> &) noexcept {
return true;
}

template <typename key, typename value, typename hash = std::hash<key>,
typename eq = std::equal_to<key>>
using py_map =
tsl::robin_map<key, value, hash, eq, py_allocator<std::pair<key, value>>>;
using py_map = tsl::robin_map<key, value, hash, eq>;

// Linked list of instances with the same pointer address. Usually just 1.
struct nb_inst_seq {
Expand Down

0 comments on commit f8fc46b

Please sign in to comment.