mirror of
https://github.com/python/cpython.git
synced 2025-07-23 19:25:40 +00:00
Included assert.h in Python.h -- it's absurd that this basic tool of
good C practice hasn't been available to everything all along. Added Py_SAFE_DOWNCAST(VALUE, WIDE, NARROW) macro to pyport.h; this just casts VALUE from type WIDE to type NARROW, but assert-fails if Py_DEBUG is defined and info is lost due to casting. Replaced a line in Fredrik's fix to marshal.c to use the new macro.
This commit is contained in:
parent
e21107145a
commit
8315ea5790
3 changed files with 21 additions and 2 deletions
|
@ -69,7 +69,7 @@ w_more(int c, WFILE *p)
|
|||
p->ptr = PyString_AS_STRING((PyStringObject *)p->str) + size;
|
||||
p->end =
|
||||
PyString_AS_STRING((PyStringObject *)p->str) + newsize;
|
||||
*p->ptr++ = (char) c;
|
||||
*p->ptr++ = Py_SAFE_DOWNCAST(c, int, char);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue