[Python-bugs-list] [ python-Bugs-485153 ] Erroneous Fail of PyEval_CallObject

noreply@sourceforge.net noreply@sourceforge.net
Tue, 27 Nov 2001 13:18:40 -0800


Bugs item #485153, was opened at 2001-11-24 11:46
You can respond by visiting: 
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=485153&group_id=5470

>Category: Documentation
Group: Python 2.1.1
Status: Open
Resolution: None
Priority: 5
Submitted By: Cl. Schmidt (clemm)
>Assigned to: Fred L. Drake, Jr. (fdrake)
Summary: Erroneous Fail of PyEval_CallObject

Initial Comment:
If embedding python v2.1.1 in a Windows MFC project,
it shows the following behaviour:

When a call to e.g. PyArgParseTuple had failed,
a subsequent call to PyEval_CallObject fails. The 
parameters of the both calls are completely 
independent and have nothing to do with each other.
Trying to retrieve the error text of the failed 
PyEval_CallObject returns the error of the 
PyArgParseTuple, namely
"new style getargs format but argument list is not a 
tuple".
If the first (erroneous) call to PyArgParseTuple is 
commented, the PyEval_CallObject works without any 
problem.

The attached code snippet documents the error.

No attempts have been made to reproduce the behaviour 
in other environments.

----------------------------------------------------------------------

>Comment By: Tim Peters (tim_one)
Date: 2001-11-27 13:14

Message:
Logged In: YES 
user_id=31435

Changed to Documentation and reassigned to Fred:  Fred, I 
don't think we ever spell out that C API errors must be 
passed on or explicitly cleared (before calling another C 
API function).  The Exceptions section of the C API manual 
does not spell this out.  It's possible <wink> that 
the "Intermezzo: Errors and Exceptions" section of the 
Extending and Embedding manual is clear enough -- your call.

----------------------------------------------------------------------

Comment By: Tim Peters (tim_one)
Date: 2001-11-27 12:47

Message:
Logged In: YES 
user_id=31435

I don't understand what "the bug" is here:  if you get an 
error return from a Python C API function, and you intend 
to ignore the error, you must call PyErr_Clear() before 
calling another Python C API function.  You're not doing 
that.

The attachment isn't executable as-is, so I can't say 
whether that fixes your particular problem -- but it's 
never legitimate to ignore an error in C API coding (you 
must either pass it on to your caller or explicitly clear 
it).

----------------------------------------------------------------------

You can respond by visiting: 
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=485153&group_id=5470