Skip to content

TypeError: get_interpreter() returned NULL #82

@fishpepper

Description

@fishpepper

Hi!

I am trying to build my own machinekit under a plain stretch based debian image.

I am struggling issues with getting the following error:

  File "/home/machinekit/src/machinekit/bin/axis", line 3215, in <module>
    o = MyOpengl(widgets.preview_frame, width=400, height=300, double=1, depth=1)
  File "/home/machinekit/src/machinekit/bin/axis", line 373, in __init__
    Opengl.__init__(self, *args, **kw)
  File "/home/machinekit/src/machinekit/lib/python/rs274/OpenGLTk.py", line 164, in __init__
    apply(RawOpengl.__init__, (self, master, cnf), kw)
  File "/home/machinekit/src/machinekit/lib/python/rs274/OpenGLTk.py", line 112, in __init__
    Togl.__init__(self, master, cnf, **kw)
  File "/home/machinekit/src/machinekit/lib/python/rs274/OpenGLTk.py", line 37, in __init__
    _togl.install(master.tk)
TypeError: get_interpreter() returned NULL
Exception AttributeError: "MyOpengl instance has no attribute '_dlists'" in <bound method MyOpengl.__del__ of <__main__.MyOpengl instance at 0xb4b11f08>> ignored
Shutting down and cleaning up Machinekit...

I traced it back to the file src/emc/usr_intf/axis/extensions/_toglmodule.c.
This diff adds some more debug info (might be good to have it in the master branch as well):

index 6c872b5fe..2a591566b 100644
--- a/src/emc/usr_intf/axis/extensions/_toglmodule.c
+++ b/src/emc/usr_intf/axis/extensions/_toglmodule.c
@@ -22,8 +22,12 @@ static Tcl_Interp *get_interpreter(PyObject *tkapp) {
     PyObject *interpaddrobj = PyObject_CallMethod(tkapp, "interpaddr", NULL);
     if(interpaddrobj == NULL) { return NULL; }
     interpaddr = PyInt_AsLong(interpaddrobj);
+    if (PyErr_Occurred()){ 
+        PyErr_PrintEx(0);
+       return NULL;
+    }
     Py_DECREF(interpaddrobj);
-    if(interpaddr == -1) { return NULL; }
+    if((interpaddr == -1) && PyErr_Occurred()) { return NULL; }
     return (Tcl_Interp*)interpaddr;
 }

The change with the checking of == -1 is necessary as the PyInt_AsLong documentation says just checking for -1 is not correct.
Anyway, that is not my issue.... Running this modified code gives me this error reason:
OverflowError: Python int too large to convert to C long

Really strange... I have no idea of the internals of PyInt_AsLong but as I was curious and I tried to replace it by:
interpaddr = PyInt_AsUnsignedLongLongMask(interpaddrobj);
With this fix axis starts up just fine and it looks like all is working as expected.
I am sure this is not the correct way of doing it.
Maybe a python guru can point me in the right direction?

Simon

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions