A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2006-January/059524.html below:

[Python-Dev] [Python-checkins] r41972 - python/branches/ssize_t/Objects/funcobject.c

[Python-Dev] [Python-checkins] r41972 - python/branches/ssize_t/Objects/funcobject.c"Martin v. Löwis" martin at v.loewis.de
Sun Jan 8 18:52:39 CET 2006
Tim Peters wrote:
> That handles C99-ish platforms by defalt.  Other platforms (like
> Windows) would need to supply their own expansion in their pyconfig.h.
>  Neal's format would become the god-awful
> but platform-neutral:
> 
>           "%s() requires a code object with %" Py_SIZE_T_WIDTH "d free vars,"
>           " not %" Py_SIZE_T_WIDTH "d"

That's too ugly, IMO. So I could accept to write

        "%s() requires a code object with %ld free vars,"
        " not %ld", PyString_AsString(op->func_name),
 	(long)nclosure, (long)nfree);

instead. Alternatively, if there is a real chance that it overflows
LONG_MAX (which there isn't, AFAIK - we don't support that many free
vars), we could also write

        "%s() requires a code object with %ld free vars,"
        " not %ld", PyString_AsString(op->func_name),
 	Py_long_ceil(nclosure), Py_long_ceil(nfree));

with

#define Py_long_ceil(n) ((n) > LONG_MAX ? LONG_MAX : \
    (n) < LONG_MIN ? LONG_MIN : (n))

On most platforms, the compiler should notice that the conditions
are both known false, and collaps this to (n).

If this ever overflows, somebody will have to remember that
this is really +/- infinity.

Regards,
Martin

P.S. Proposals for a different macro name are thankfully accepted.
More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4