| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -13,6 +13,9 @@ Core and Builtins | |||
| 13 | 13 | - Tweak the exception message when the magic number or size value in a bytecode | |
| 14 | 14 | file is truncated. | |
| 15 | 15 | ||
| 16 | + - Issue #17932: Fix an integer overflow issue on Windows 64-bit in iterators: | ||
| 17 | + change the C type of seqiterobject.it_index from long to Py_ssize_t. | ||
| 18 | + | ||
| 16 | 19 | - Issue #18065: Don't set __path__ to the package name for frozen packages. | |
| 17 | 20 | ||
| 18 | 21 | - Issue #18088: When reloading a module, unconditionally reset all relevant | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -36,8 +36,6 @@ | |||
| 36 | 36 | #define RELEASE_LOCK(obj) | |
| 37 | 37 | #endif | |
| 38 | 38 | ||
| 39 | - #define MIN(X, Y) (((X) < (Y)) ? (X) : (Y)) | ||
| 40 | - | ||
| 41 | 39 | ||
| 42 | 40 | typedef struct { | |
| 43 | 41 | PyObject_HEAD | |
@@ -157,7 +155,7 @@ compress(BZ2Compressor *c, char *data, size_t len, int action) | |||
| 157 | 155 | /* On a 64-bit system, len might not fit in avail_in (an unsigned int). | |
| 158 | 156 | Do compression in chunks of no more than UINT_MAX bytes each. */ | |
| 159 | 157 | if (c->bzs.avail_in == 0 && len > 0) { | |
| 160 | - c->bzs.avail_in = MIN(len, UINT_MAX); | ||
| 158 | + c->bzs.avail_in = Py_MIN(len, UINT_MAX); | ||
| 161 | 159 | len -= c->bzs.avail_in; | |
| 162 | 160 | } | |
| 163 | 161 | ||
@@ -173,7 +171,7 @@ compress(BZ2Compressor *c, char *data, size_t len, int action) | |||
| 173 | 171 | c->bzs.next_out = PyBytes_AS_STRING(result) + data_size; | |
| 174 | 172 | buffer_left = PyBytes_GET_SIZE(result) - data_size; | |
| 175 | 173 | } | |
| 176 | - c->bzs.avail_out = MIN(buffer_left, UINT_MAX); | ||
| 174 | + c->bzs.avail_out = Py_MIN(buffer_left, UINT_MAX); | ||
| 177 | 175 | } | |
| 178 | 176 | ||
| 179 | 177 | Py_BEGIN_ALLOW_THREADS | |
@@ -370,7 +368,7 @@ decompress(BZ2Decompressor *d, char *data, size_t len) | |||
| 370 | 368 | d->bzs.next_in = data; | |
| 371 | 369 | /* On a 64-bit system, len might not fit in avail_in (an unsigned int). | |
| 372 | 370 | Do decompression in chunks of no more than UINT_MAX bytes each. */ | |
| 373 | - d->bzs.avail_in = MIN(len, UINT_MAX); | ||
| 371 | + d->bzs.avail_in = Py_MIN(len, UINT_MAX); | ||
| 374 | 372 | len -= d->bzs.avail_in; | |
| 375 | 373 | d->bzs.next_out = PyBytes_AS_STRING(result); | |
| 376 | 374 | d->bzs.avail_out = PyBytes_GET_SIZE(result); | |
@@ -399,7 +397,7 @@ decompress(BZ2Decompressor *d, char *data, size_t len) | |||
| 399 | 397 | if (d->bzs.avail_in == 0) { | |
| 400 | 398 | if (len == 0) | |
| 401 | 399 | break; | |
| 402 | - d->bzs.avail_in = MIN(len, UINT_MAX); | ||
| 400 | + d->bzs.avail_in = Py_MIN(len, UINT_MAX); | ||
| 403 | 401 | len -= d->bzs.avail_in; | |
| 404 | 402 | } | |
| 405 | 403 | if (d->bzs.avail_out == 0) { | |
@@ -410,7 +408,7 @@ decompress(BZ2Decompressor *d, char *data, size_t len) | |||
| 410 | 408 | d->bzs.next_out = PyBytes_AS_STRING(result) + data_size; | |
| 411 | 409 | buffer_left = PyBytes_GET_SIZE(result) - data_size; | |
| 412 | 410 | } | |
| 413 | - d->bzs.avail_out = MIN(buffer_left, UINT_MAX); | ||
| 411 | + d->bzs.avail_out = Py_MIN(buffer_left, UINT_MAX); | ||
| 414 | 412 | } | |
| 415 | 413 | } | |
| 416 | 414 | if (data_size != PyBytes_GET_SIZE(result)) | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -168,10 +168,6 @@ static char *screen_encoding = NULL; | |||
| 168 | 168 | "must call start_color() first"); \ | |
| 169 | 169 | return 0; } | |
| 170 | 170 | ||
| 171 | - #ifndef MIN | ||
| 172 | - #define MIN(x,y) ((x) < (y) ? (x) : (y)) | ||
| 173 | - #endif | ||
| 174 | - | ||
| 175 | 171 | /* Utility Functions */ | |
| 176 | 172 | ||
| 177 | 173 | /* | |
@@ -1212,7 +1208,7 @@ PyCursesWindow_GetStr(PyCursesWindowObject *self, PyObject *args) | |||
| 1212 | 1208 | if (!PyArg_ParseTuple(args,"i;n", &n)) | |
| 1213 | 1209 | return NULL; | |
| 1214 | 1210 | Py_BEGIN_ALLOW_THREADS | |
| 1215 | - rtn2 = wgetnstr(self->win,rtn,MIN(n, 1023)); | ||
| 1211 | + rtn2 = wgetnstr(self->win, rtn, Py_MIN(n, 1023)); | ||
| 1216 | 1212 | Py_END_ALLOW_THREADS | |
| 1217 | 1213 | break; | |
| 1218 | 1214 | case 2: | |
@@ -1232,11 +1228,11 @@ PyCursesWindow_GetStr(PyCursesWindowObject *self, PyObject *args) | |||
| 1232 | 1228 | #ifdef STRICT_SYSV_CURSES | |
| 1233 | 1229 | Py_BEGIN_ALLOW_THREADS | |
| 1234 | 1230 | rtn2 = wmove(self->win,y,x)==ERR ? ERR : | |
| 1235 | - wgetnstr(self->win, rtn, MIN(n, 1023)); | ||
| 1231 | + wgetnstr(self->win, rtn, Py_MIN(n, 1023)); | ||
| 1236 | 1232 | Py_END_ALLOW_THREADS | |
| 1237 | 1233 | #else | |
| 1238 | 1234 | Py_BEGIN_ALLOW_THREADS | |
| 1239 | - rtn2 = mvwgetnstr(self->win, y, x, rtn, MIN(n, 1023)); | ||
| 1235 | + rtn2 = mvwgetnstr(self->win, y, x, rtn, Py_MIN(n, 1023)); | ||
| 1240 | 1236 | Py_END_ALLOW_THREADS | |
| 1241 | 1237 | #endif | |
| 1242 | 1238 | break; | |
@@ -1374,7 +1370,7 @@ PyCursesWindow_InStr(PyCursesWindowObject *self, PyObject *args) | |||
| 1374 | 1370 | case 1: | |
| 1375 | 1371 | if (!PyArg_ParseTuple(args,"i;n", &n)) | |
| 1376 | 1372 | return NULL; | |
| 1377 | - rtn2 = winnstr(self->win,rtn,MIN(n,1023)); | ||
| 1373 | + rtn2 = winnstr(self->win, rtn, Py_MIN(n, 1023)); | ||
| 1378 | 1374 | break; | |
| 1379 | 1375 | case 2: | |
| 1380 | 1376 | if (!PyArg_ParseTuple(args,"ii;y,x",&y,&x)) | |
@@ -1384,7 +1380,7 @@ PyCursesWindow_InStr(PyCursesWindowObject *self, PyObject *args) | |||
| 1384 | 1380 | case 3: | |
| 1385 | 1381 | if (!PyArg_ParseTuple(args, "iii;y,x,n", &y, &x, &n)) | |
| 1386 | 1382 | return NULL; | |
| 1387 | - rtn2 = mvwinnstr(self->win, y, x, rtn, MIN(n,1023)); | ||
| 1383 | + rtn2 = mvwinnstr(self->win, y, x, rtn, Py_MIN(n,1023)); | ||
| 1388 | 1384 | break; | |
| 1389 | 1385 | default: | |
| 1390 | 1386 | PyErr_SetString(PyExc_TypeError, "instr requires 0 or 3 arguments"); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -99,13 +99,4 @@ PyObject *_PyMp_SetError(PyObject *Type, int num); | |||
| 99 | 99 | ||
| 100 | 100 | extern PyTypeObject _PyMp_SemLockType; | |
| 101 | 101 | ||
| 102 | - /* | ||
| 103 | - * Miscellaneous | ||
| 104 | - */ | ||
| 105 | - | ||
| 106 | - #ifndef MIN | ||
| 107 | - # define MIN(x, y) ((x) < (y) ? x : y) | ||
| 108 | - # define MAX(x, y) ((x) > (y) ? x : y) | ||
| 109 | - #endif | ||
| 110 | - | ||
| 111 | 102 | #endif /* MULTIPROCESSING_H */ | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -91,10 +91,6 @@ typedef struct { | |||
| 91 | 91 | (y)[3] = (unsigned char)(((x)>>24)&255); (y)[2] = (unsigned char)(((x)>>16)&255); \ | |
| 92 | 92 | (y)[1] = (unsigned char)(((x)>>8)&255); (y)[0] = (unsigned char)((x)&255); } | |
| 93 | 93 | ||
| 94 | - #ifndef MIN | ||
| 95 | - #define MIN(x, y) ( ((x)<(y))?(x):(y) ) | ||
| 96 | - #endif | ||
| 97 | - | ||
| 98 | 94 | ||
| 99 | 95 | /* MD5 macros */ | |
| 100 | 96 | ||
@@ -244,7 +240,7 @@ md5_process(struct md5_state *md5, const unsigned char *in, Py_ssize_t inlen) | |||
| 244 | 240 | in += MD5_BLOCKSIZE; | |
| 245 | 241 | inlen -= MD5_BLOCKSIZE; | |
| 246 | 242 | } else { | |
| 247 | - n = MIN(inlen, (Py_ssize_t)(MD5_BLOCKSIZE - md5->curlen)); | ||
| 243 | + n = Py_MIN(inlen, (Py_ssize_t)(MD5_BLOCKSIZE - md5->curlen)); | ||
| 248 | 244 | memcpy(md5->buf + md5->curlen, in, (size_t)n); | |
| 249 | 245 | md5->curlen += (MD5_INT32)n; | |
| 250 | 246 | in += n; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -92,10 +92,6 @@ typedef struct { | |||
| 92 | 92 | (y)[4] = (unsigned char)(((x)>>24)&255); (y)[5] = (unsigned char)(((x)>>16)&255); \ | |
| 93 | 93 | (y)[6] = (unsigned char)(((x)>>8)&255); (y)[7] = (unsigned char)((x)&255); } | |
| 94 | 94 | ||
| 95 | - #ifndef MIN | ||
| 96 | - #define MIN(x, y) ( ((x)<(y))?(x):(y) ) | ||
| 97 | - #endif | ||
| 98 | - | ||
| 99 | 95 | ||
| 100 | 96 | /* SHA1 macros */ | |
| 101 | 97 | ||
@@ -220,7 +216,7 @@ sha1_process(struct sha1_state *sha1, | |||
| 220 | 216 | in += SHA1_BLOCKSIZE; | |
| 221 | 217 | inlen -= SHA1_BLOCKSIZE; | |
| 222 | 218 | } else { | |
| 223 | - n = MIN(inlen, (Py_ssize_t)(SHA1_BLOCKSIZE - sha1->curlen)); | ||
| 219 | + n = Py_MIN(inlen, (Py_ssize_t)(SHA1_BLOCKSIZE - sha1->curlen)); | ||
| 224 | 220 | memcpy(sha1->buf + sha1->curlen, in, (size_t)n); | |
| 225 | 221 | sha1->curlen += (SHA1_INT32)n; | |
| 226 | 222 | in += n; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -95,9 +95,6 @@ Local naming conventions: | |||
| 95 | 95 | #include "Python.h" | |
| 96 | 96 | #include "structmember.h" | |
| 97 | 97 | ||
| 98 | - #undef MAX | ||
| 99 | - #define MAX(x, y) ((x) < (y) ? (y) : (x)) | ||
| 100 | - | ||
| 101 | 98 | /* Socket object documentation */ | |
| 102 | 99 | PyDoc_STRVAR(sock_doc, | |
| 103 | 100 | "socket([family[, type[, proto]]]) -> socket object\n\ | |
@@ -4819,7 +4816,7 @@ socket_inet_pton(PyObject *self, PyObject *args) | |||
| 4819 | 4816 | char* ip; | |
| 4820 | 4817 | int retval; | |
| 4821 | 4818 | #ifdef ENABLE_IPV6 | |
| 4822 | - char packed[MAX(sizeof(struct in_addr), sizeof(struct in6_addr))]; | ||
| 4819 | + char packed[Py_MAX(sizeof(struct in_addr), sizeof(struct in6_addr))]; | ||
| 4823 | 4820 | #else | |
| 4824 | 4821 | char packed[sizeof(struct in_addr)]; | |
| 4825 | 4822 | #endif | |
@@ -4870,7 +4867,7 @@ socket_inet_ntop(PyObject *self, PyObject *args) | |||
| 4870 | 4867 | int len; | |
| 4871 | 4868 | const char* retval; | |
| 4872 | 4869 | #ifdef ENABLE_IPV6 | |
| 4873 | - char ip[MAX(INET_ADDRSTRLEN, INET6_ADDRSTRLEN) + 1]; | ||
| 4870 | + char ip[Py_MAX(INET_ADDRSTRLEN, INET6_ADDRSTRLEN) + 1]; | ||
| 4874 | 4871 | #else | |
| 4875 | 4872 | char ip[INET_ADDRSTRLEN + 1]; | |
| 4876 | 4873 | #endif | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -9,11 +9,6 @@ | |||
| 9 | 9 | #include <ctype.h> | |
| 10 | 10 | #include <float.h> | |
| 11 | 11 | ||
| 12 | - #undef MAX | ||
| 13 | - #undef MIN | ||
| 14 | - #define MAX(x, y) ((x) < (y) ? (y) : (x)) | ||
| 15 | - #define MIN(x, y) ((x) < (y) ? (x) : (y)) | ||
| 16 | - | ||
| 17 | 12 | ||
| 18 | 13 | /* Special free list | |
| 19 | 14 | free_list is a singly-linked list of available PyFloatObjects, linked | |
@@ -1131,7 +1126,7 @@ float_hex(PyObject *v) | |||
| 1131 | 1126 | } | |
| 1132 | 1127 | ||
| 1133 | 1128 | m = frexp(fabs(x), &e); | |
| 1134 | - shift = 1 - MAX(DBL_MIN_EXP - e, 0); | ||
| 1129 | + shift = 1 - Py_MAX(DBL_MIN_EXP - e, 0); | ||
| 1135 | 1130 | m = ldexp(m, shift); | |
| 1136 | 1131 | e -= shift; | |
| 1137 | 1132 | ||
@@ -1285,8 +1280,8 @@ float_fromhex(PyObject *cls, PyObject *arg) | |||
| 1285 | 1280 | fdigits = coeff_end - s_store; | |
| 1286 | 1281 | if (ndigits == 0) | |
| 1287 | 1282 | goto parse_error; | |
| 1288 | - if (ndigits > MIN(DBL_MIN_EXP - DBL_MANT_DIG - LONG_MIN/2, | ||
| 1289 | - LONG_MAX/2 + 1 - DBL_MAX_EXP)/4) | ||
| 1283 | + if (ndigits > Py_MIN(DBL_MIN_EXP - DBL_MANT_DIG - LONG_MIN/2, | ||
| 1284 | + LONG_MAX/2 + 1 - DBL_MAX_EXP)/4) | ||
| 1290 | 1285 | goto insane_length_error; | |
| 1291 | 1286 | ||
| 1292 | 1287 | /* [p <exponent>] */ | |
@@ -1342,7 +1337,7 @@ float_fromhex(PyObject *cls, PyObject *arg) | |||
| 1342 | 1337 | ||
| 1343 | 1338 | /* lsb = exponent of least significant bit of the *rounded* value. | |
| 1344 | 1339 | This is top_exp - DBL_MANT_DIG unless result is subnormal. */ | |
| 1345 | - lsb = MAX(top_exp, (long)DBL_MIN_EXP) - DBL_MANT_DIG; | ||
| 1340 | + lsb = Py_MAX(top_exp, (long)DBL_MIN_EXP) - DBL_MANT_DIG; | ||
| 1346 | 1341 | ||
| 1347 | 1342 | x = 0.0; | |
| 1348 | 1343 | if (exp >= lsb) { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -7,11 +7,6 @@ | |||
| 7 | 7 | #include "opcode.h" | |
| 8 | 8 | #include "structmember.h" | |
| 9 | 9 | ||
| 10 | - #undef MIN | ||
| 11 | - #undef MAX | ||
| 12 | - #define MIN(a, b) ((a) < (b) ? (a) : (b)) | ||
| 13 | - #define MAX(a, b) ((a) > (b) ? (a) : (b)) | ||
| 14 | - | ||
| 15 | 10 | #define OFF(x) offsetof(PyFrameObject, x) | |
| 16 | 11 | ||
| 17 | 12 | static PyMemberDef frame_memberlist[] = { | |
@@ -160,8 +155,8 @@ frame_setlineno(PyFrameObject *f, PyObject* p_new_lineno) | |||
| 160 | 155 | ||
| 161 | 156 | /* We're now ready to look at the bytecode. */ | |
| 162 | 157 | PyBytes_AsStringAndSize(f->f_code->co_code, (char **)&code, &code_len); | |
| 163 | - min_addr = MIN(new_lasti, f->f_lasti); | ||
| 164 | - max_addr = MAX(new_lasti, f->f_lasti); | ||
| 158 | + min_addr = Py_MIN(new_lasti, f->f_lasti); | ||
| 159 | + max_addr = Py_MAX(new_lasti, f->f_lasti); | ||
| 165 | 160 | ||
| 166 | 161 | /* You can't jump onto a line with an 'except' statement on it - | |
| 167 | 162 | * they expect to have an exception on the top of the stack, which | |
@@ -293,7 +288,7 @@ frame_setlineno(PyFrameObject *f, PyObject* p_new_lineno) | |||
| 293 | 288 | break; | |
| 294 | 289 | } | |
| 295 | 290 | ||
| 296 | - min_delta_iblock = MIN(min_delta_iblock, delta_iblock); | ||
| 291 | + min_delta_iblock = Py_MIN(min_delta_iblock, delta_iblock); | ||
| 297 | 292 | ||
| 298 | 293 | if (op >= HAVE_ARGUMENT) { | |
| 299 | 294 | addr += 2; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -4,7 +4,7 @@ | |||
| 4 | 4 | ||
| 5 | 5 | typedef struct { | |
| 6 | 6 | PyObject_HEAD | |
| 7 | - long it_index; | ||
| 7 | + Py_ssize_t it_index; | ||
| 8 | 8 | PyObject *it_seq; /* Set to NULL when iterator is exhausted */ | |
| 9 | 9 | } seqiterobject; | |
| 10 | 10 | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments