Python Forum
SystemError: <method-wrapper '__getattribute__' of EnumMeta object
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
SystemError: <method-wrapper '__getattribute__' of EnumMeta object
#1
Hi,
first post here.

This is a thread about an python error I cannot resolve.
I'm primarily a c++ programmer (python beginner) and have to access python via pybind11.
Actually, all was fine until I changed my OS from Win10 to Win11 (this is the only change I am aware of in the last months).
The error occurs when I try to import other packages (numpy in this case). I made tests where I simply imported a module which imports another module. This worked fine.

For numpy, I get the following exception message:

Error:
'SystemError: <method-wrapper '__getattribute__' of EnumMeta object at 0x0000026950F06650> returned a result with an exception set At: C:\Users\rammn\AppData\Local\Programs\Python\Python310\Lib\enum.py(462): __repr__ C:\Users\rammn\AppData\Local\Programs\Python\Python310\Lib\enum.py(648): _find_new_ C:\Users\rammn\AppData\Local\Programs\Python\Python310\Lib\enum.py(192): __new__ C:\Users\rammn\AppData\Local\Programs\Python\Python310\Lib\enum.py(807): <module> <frozen importlib._bootstrap>(241): _call_with_frames_removed <frozen importlib._bootstrap_external>(883): exec_module <frozen importlib._bootstrap>(703): _load_unlocked <frozen importlib._bootstrap>(1006): _find_and_load_unlocked <frozen importlib._bootstrap>(1027): _find_and_load C:\Users\rammn\AppData\Local\Programs\Python\Python310\Lib\site-packages\numpy\_globals.py(21): <module> <frozen importlib._bootstrap>(241): _call_with_frames_removed <frozen importlib._bootstrap_external>(883): exec_module <frozen importlib._bootstrap>(703): _load_unlocked <frozen importlib._bootstrap>(1006): _find_and_load_unlocked <frozen importlib._bootstrap>(1027): _find_and_load C:\Users\rammn\AppData\Local\Programs\Python\Python310\Lib\site-packages\numpy\__init__.py(112): <module> <frozen importlib._bootstrap>(241): _call_with_frames_removed <frozen importlib._bootstrap_external>(883): exec_module <frozen importlib._bootstrap>(703): _load_unlocked <frozen importlib._bootstrap>(1006): _find_and_load_unlocked <frozen importlib._bootstrap>(1027): _find_and_load C:\Users\rammn\AppData\Local\Programs\Python\Python310\Lib\site-packages\myOwnPythonFileImportingNumpy.py(38): <module> <frozen importlib._bootstrap>(241): _call_with_frames_removed <frozen importlib._bootstrap_external>(883): exec_module <frozen importlib._bootstrap>(703): _load_unlocked <frozen importlib._bootstrap>(1006): _find_and_load_unlocked <frozen importlib._bootstrap>(1027): _find_and_load
The online docs tell me to contact the responsible developer (which would be somebody from CPython), but I have honestly no idea if and how I should do that.
Quote: exception SystemError
Raised when the interpreter finds an internal error, but the situation does not look so serious to cause it to abandon all hope. The associated value is a string indicating what went wrong (in low-level terms).
You should report this to the author or maintainer of your Python interpreter

I tried to find the source for the error in the cpython source code. But the nearest I got so far is the creation of the error message itself:
_PyErr_FormatFromCauseTstate( tstate, PyExc_SystemError, "%R returned a result with an exception set", callable);
in '_Py_CheckFunctionResult'
And I don't understand whats wrond with '__repr__'

May anyone point me to the right direction?
Many thanks!
Reply
#2
Post the code that is generating this error. Looks like you messed up defining an enum.
Reply
#3
I haven't changed the default python modules ('enum.py'/'bootstrap.py'/'etc')
What I do is I import my own python module (using c), which in turn imports, for example, numpy:
 c : PyObject* obj = PyImport_ImportModule("myPythonModule");
Even if 'myPythonModule' has in it only the 'import numpy', I get the errors I mentioned above.
Reply
#4
Do you have any problems running Python without trying to import your module? My guess is you messed up binding to your C code, but I would first verify that you don't have any problems with the Python setup on your computer.
Reply
#5
deanhystad,

I followed your suggestion to check whether I messed up python...
I have no idea why this happend, but placing the default function for printing out information of a PyObject
PyObject_Print(ob, stdout, Py_PRINT_RAW);
throughout my code somehow resulted in the 'enum' error.
However, without those print statements, I find myself back in the initial situation of cpython never returning.
(I checked numpy functionality using the interpreter (same python.exe) and all worked fine.)

Let me write down how far I came now when trying to import numpy.
These are the last steps before I could not get any further:

in the file 'call.c'' in
PyObject* _PyObject_MakeTpCall( PyThreadState *tstate, PyObject *callable, PyObject *const *args, Py_ssize_t nargs, PyObject *keywords)
'PyObject_Print' for 'callable' gives '<class 'numpy.longdouble'>'

Some lines further down a function pointer names 'call' is created:
ternaryfunc call = (((PyObject*)(callable))->ob_type)->tp_call;
When 'call' is then executed, the function 'type_call' is called (in 'typeobject.c')
static PyObject* type_call(PyTypeObject *type, PyObject *args, PyObject *kwds)
The 'PyTypeObject' paramater gives us:
Quote:PyTypeObject tp_name : 'numpy.longdouble'
PyTypeObject tp_doc : 'Extended-precision floating-point number type, compatible with C
long double but not necessarily with IEEE 754 quadruple-precision.

:Character code: 'g'
:Alias: numpy.longfloat'



Then, another function pointer, which already points to an unknown function is used:
obj = type->tp_new(type, args, kwds);
I tried to find every function to which 'tp_new' could point to and inserted printf-statements, but non of these functions got called...

...and from this function call, python never returns.

So, thats how far I came..and I still have no idea what I can do to solve the problem...
Do you have an idea?

thanks!
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Using C++/CLI wrapper functions by Python Ales1000 2 1,777 Jun-21-2022, 04:50 AM
Last Post: Ales1000
  SystemError: initialization of integer failed without raising an exception Anldra12 2 4,401 Apr-19-2022, 10:50 AM
Last Post: Anldra12
  Python executable Script (Wrapper) Hwang 2 1,898 Jan-12-2022, 06:53 PM
Last Post: Hwang
  Sqla wrapper Slojure 1 1,540 Nov-01-2021, 04:36 PM
Last Post: Larz60+
  Python C++ wrapper problem JESuh 1 2,173 Mar-30-2021, 04:37 PM
Last Post: nilamo
  SystemError: error return without exception set!!! faryad13 3 3,700 Oct-23-2020, 02:32 PM
Last Post: ATARI_LIVE
  Accessing method as function object ClassicalSoul 2 2,033 Feb-14-2020, 09:31 PM
Last Post: wavic
  C++ Wrapper for python yamifm0f 6 3,120 Nov-07-2019, 06:40 PM
Last Post: Gribouillis
  print all method and property of list object engmoh 4 2,868 Oct-26-2019, 05:33 PM
Last Post: engmoh
  generating ctypes wrapper for a c library? brighteningeyes 9 7,085 Nov-04-2018, 02:31 AM
Last Post: brighteningeyes

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020