Skip to content

Commit

Permalink
Fix for stable ABI
Browse files Browse the repository at this point in the history
  • Loading branch information
Matthias Wittgen authored and Matthias Wittgen committed Jun 18, 2024
1 parent 3edd9f7 commit 08dd9ef
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/nb_enum.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#include <iostream>
#include "nb_internals.h"
NAMESPACE_BEGIN(NB_NAMESPACE)
NAMESPACE_BEGIN(detail)
Expand Down Expand Up @@ -152,9 +153,13 @@ bool enum_from_python(const std::type_info *tp, PyObject *o, int64_t *out, uint8
type_data *t = nb_type_c2p(internals, tp);
if (!t)
return false;

auto base = PyObject_GetAttrString((PyObject *)o->ob_type, "__base__");
auto basename = PyObject_GetAttrString(base, "__name__");
Py_ssize_t size;
const char* data = PyUnicode_AsUTF8AndSize(basename, &size);
std::string s(data, size);
if ((t->flags & (uint32_t) type_flags::is_flag_enum) !=0 &&
strcmp(o->ob_type->tp_base->tp_name, "Flag") == 0) {
s == "Flag") {
auto pValue = PyObject_GetAttrString(o, "value");
if(pValue == nullptr) {
PyErr_Clear();
Expand Down

0 comments on commit 08dd9ef

Please sign in to comment.