[Python-Dev] [Python-checkins] r41972 - python/branches/ssize_t/Objects/funcobject.c (original) (raw)
"Martin v. Löwis" martin at v.loewis.de
Sun Jan 8 18:52:39 CET 2006
- Previous message: [Python-Dev] [Python-checkins] r41972 - python/branches/ssize_t/Objects/funcobject.c
- Next message: [Python-Dev] [Python-checkins] r41972 - python/branches/ssize_t/Objects/funcobject.c
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
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 %" PySIZETWIDTH "d free vars," " not %" PySIZETWIDTH "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.
- Previous message: [Python-Dev] [Python-checkins] r41972 - python/branches/ssize_t/Objects/funcobject.c
- Next message: [Python-Dev] [Python-checkins] r41972 - python/branches/ssize_t/Objects/funcobject.c
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]