[ python-Bugs-994255 ] Py_RETURN_NONE causes too much warnings

SourceForge.net noreply at sourceforge.net
Wed Jul 21 02:40:24 CEST 2004


Bugs item #994255, was opened at 2004-07-19 20:36
Message generated for change (Comment added) made by bcannon
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=994255&group_id=5470

Category: Python Interpreter Core
Group: Python 2.4
Status: Open
Resolution: None
Priority: 5
Submitted By: Correa (thiagocorrea)
Assigned to: Nobody/Anonymous (nobody)
Summary: Py_RETURN_NONE causes too much warnings

Initial Comment:
It will make the compiler complain on each instance
about the conditional being constant ( while (0) )

why not use something like this instead?

The compiler will be able to optimize out the function
call.

#if !defined(Py_RETURN_NONE) // New in Python 2.4
inline PyObject* doPy_RETURN_NONE()
{	Py_INCREF(Py_None); return Py_None; }
#define Py_RETURN_NONE return doPy_RETURN_NONE()
#endif

#if !defined(Py_RETURN_TRUE) // New in Python 2.4
inline PyObject* doPy_RETURN_TRUE()
{Py_INCREF(Py_True); return Py_True;}
#	define Py_RETURN_TRUE return doPy_RETURN_TRUE()
#endif

#if !defined(Py_RETURN_FALSE) // New in Python 2.4
inline PyObject* doPy_RETURN_FALSE()
{Py_INCREF(Py_False); return Py_False;}
#define Py_RETURN_FALSE return doPy_RETURN_FALSE()
#endif


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

>Comment By: Brett Cannon (bcannon)
Date: 2004-07-20 17:40

Message:
Logged In: YES 
user_id=357491

You can't use inline; that is not supported in C89 but only C99 which we 
do not support.

As for why we can't just make the macro ``{Py_INCREF(Py_None); 
return Py_None;}``, I don't know.  K&R seems to suggest that the syntax 
is at least legal.

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

Comment By: Correa (thiagocorrea)
Date: 2004-07-20 08:27

Message:
Logged In: YES 
user_id=111587

Visual C++ 7.0, Win32



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

Comment By: Raymond Hettinger (rhettinger)
Date: 2004-07-20 04:27

Message:
Logged In: YES 
user_id=80475

Which compiler and operating system are you using?

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

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


More information about the Python-bugs-list mailing list