osdir.com


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

SystemError: error return without exception set


On Fri, Dec 8, 2017 at 5:28 AM, MRAB <python at mrabarnett.plus.com> wrote:
> On 2017-12-07 17:22, Chris Angelico wrote:
>>
>> On Fri, Dec 8, 2017 at 2:36 AM, Natalie Leung <natalieleung.29 at gmail.com>
>> wrote:
>>>
>>> I am trying to use Python to communicate and send commands in MSC Marc. A
>>> part of the code looks something like this:
>>>
>>> from py_mentat import*
>>>
>>> directory = '[specified the file path to my model]'
>>> marcModel = '[name of my model]'
>>>
>>> py_echo(0)
>>> openModel = '*new_model yes *open_model "'+ directory + marcModel +'"'
>>> py_send(openModel)
>>>
>>>
>>> The code stops at "py_send(openModel)" with an error message that reads:
>>> Traceback (most recent call last): File "[my file path]", line 11, in
>>> py_send(openModel)
>>> SystemError: error return without exception set
>>>
>>> I tried running the code on different platforms (e.g. Command Prompt,
>>> Wing 101, python.exe) and I get the same result. What could be the problem?
>>
>>
>> In its purest sense, that error is a bug inside a Python extension
>> module (as others have mentioned). Since the failure is basically
>> "hey, you said you raised an exception, but I can't find the exception
>> you thought you were raising", it's quite probable that there is a bug
>> in your Python code; go back to the tutorial for Marc, and see if you
>> can find an issue. Unfortunately you're flying blind here, but maybe
>> you can figure something out even without the usual help of the error
>> message.
>>
>> But regardless, the bug first and foremost is in the extension module.
>> The module's creator should be able to audit the py_send function to
>> figure out where it is returning NULL without calling one of the
>> "raise exception" functions.
>>
> It's probably that the code is assuming that call somewhere to the Python
> API is returning a reference, but sometimes it isn't.
>
> _All_ such return values should be checked for NULL.

Mmm.... true. Forgot about that part. So, yes, that's a different type
of failure that could be happening. Makes the audit a bit harder.

ChrisA