[ python-Bugs-994255 ] Py_RETURN_NONE causes too much warnings
SourceForge.net
noreply at sourceforge.net
Wed Jul 21 03:26:42 CEST 2004
Bugs item #994255, was opened at 2004-07-19 23:36
Message generated for change (Comment added) made by tim_one
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: Tim Peters (tim_one)
Date: 2004-07-20 21:26
Message:
Logged In: YES
user_id=31435
"do {...} while(0)" is the standard C idiom for writing a multi-
statement macro; the reason "{...}" doesn't work is
explained, e.g., here:
http://www.eskimo.com/~scs/C-faq/q10.4.html
thiagocorrea, we need more words from you. Python is built
every day using MSVC 6.0, and Visual Studio 7.1, with no
warnings of any kind. Indeed, "no warnings under MSVC" is a
groundrule for the Python project. Exactly how do you
compile it? Do you use the Visual Studio project files in the
PCBuild subdirectory?
Brett is correct that we cannot use "inline" either.
----------------------------------------------------------------------
Comment By: Brett Cannon (bcannon)
Date: 2004-07-20 20: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 11:27
Message:
Logged In: YES
user_id=111587
Visual C++ 7.0, Win32
----------------------------------------------------------------------
Comment By: Raymond Hettinger (rhettinger)
Date: 2004-07-20 07: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