cpython: 45a404d33c2d (original) (raw)

Mercurial > cpython

changeset 99000:45a404d33c2d

Issue #25558: Use compile-time asserts. [#25558]

Serhiy Storchaka storchaka@gmail.com
date Sat, 07 Nov 2015 15:42:38 +0200
parents 2c81a883d8ca
children b1c5949a3af4
files Include/pymacro.h Modules/_ctypes/_ctypes.c Modules/_datetimemodule.c Modules/_pickle.c Modules/pyexpat.c Python/pytime.c Python/random.c
diffstat 7 files changed, 24 insertions(+), 20 deletions(-)[+] [-] Include/pymacro.h 4 Modules/_ctypes/_ctypes.c 2 Modules/_datetimemodule.c 6 Modules/_pickle.c 2 Modules/pyexpat.c 3 Python/pytime.c 25 Python/random.c 2

line wrap: on

line diff

--- a/Include/pymacro.h +++ b/Include/pymacro.h @@ -36,6 +36,10 @@ #define Py_BUILD_ASSERT_EXPR(cond) [](#l1.4) (sizeof(char [1 - 2*!(cond)]) - 1) +#define Py_BUILD_ASSERT(cond) do { [](#l1.7)

+ /* Get the number of elements in a visible array This does not work on pointers, or arrays declared as [], or function

--- a/Modules/_ctypes/_ctypes.c +++ b/Modules/_ctypes/_ctypes.c @@ -2386,7 +2386,7 @@ unique_key(CDataObject *target, Py_ssize char *cp = string; size_t bytes_left;

--- a/Modules/_datetimemodule.c +++ b/Modules/_datetimemodule.c @@ -5329,19 +5329,19 @@ PyInit__datetime(void) /* A 4-year cycle has an extra leap day over what we'd get from * pasting together 4 single years. */

--- a/Modules/_pickle.c +++ b/Modules/_pickle.c @@ -874,7 +874,7 @@ static void { size_t i;

for (i = 0; i < sizeof(size_t); i++) { out[i] = (unsigned char)((value >> (8 * i)) & 0xff);

--- a/Modules/pyexpat.c +++ b/Modules/pyexpat.c @@ -747,7 +747,8 @@ pyexpat_xmlparser_Parse_impl(xmlparseobj s += MAX_CHUNK_SIZE; slen -= MAX_CHUNK_SIZE; }

--- a/Python/pytime.c +++ b/Python/pytime.c @@ -43,7 +43,7 @@ time_t val = PyLong_AsLongLong(obj); #else long val;

#endif if (val == -1 && PyErr_Occurred()) { @@ -60,7 +60,7 @@ PyObject * #if defined(HAVE_LONG_LONG) && SIZEOF_TIME_T == SIZEOF_LONG_LONG return PyLong_FromLongLong((PY_LONG_LONG)t); #else

#endif } @@ -209,6 +209,8 @@ static void /* ensure that integer overflow cannot happen, int type should have 32 bits, whereas _PyTime_t type has at least 64 bits (SEC_TO_MS takes 30 bits). */

@@ -231,7 +233,7 @@ static int _PyTime_t t; int res = 0;

#ifdef HAVE_LONG_LONG PY_LONG_LONG sec;

sec = PyLong_AsLongLong(obj); #else long sec;

sec = PyLong_AsLong(obj); #endif @@ -364,10 +366,10 @@ PyObject * _PyTime_AsNanosecondsObject(_PyTime_t t) { #ifdef HAVE_LONG_LONG

#else

#endif } @@ -650,7 +652,7 @@ pymonotonic(_PyTime_t *tp, _Py_clock_inf assert(info == NULL || raise); ticks = GetTickCount64();

--- a/Python/random.c +++ b/Python/random.c @@ -379,7 +379,7 @@ void char *env; unsigned char *secret = (unsigned char *)&_Py_HashSecret.uc; Py_ssize_t secret_size = sizeof(_Py_HashSecret_t);

if (_Py_HashSecret_Initialized) return;