diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2020-03-09 20:49:52 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-03-09 20:49:52 +0200 |
commit | eebaa9bfc593d5a46b293c1abd929fbfbfd28199 (patch) | |
tree | 9ba0bbaba8116eb71d0b80f11b586fe063aadbe5 /Python | |
parent | 6d0ee60740f2862a878f009671b1aaa75aeb0c2a (diff) | |
download | cpython-git-eebaa9bfc593d5a46b293c1abd929fbfbfd28199.tar.gz |
bpo-38249: Expand Py_UNREACHABLE() to __builtin_unreachable() in the release mode. (GH-16329)
Co-authored-by: Victor Stinner <vstinner@python.org>
Diffstat (limited to 'Python')
-rw-r--r-- | Python/formatter_unicode.c | 2 | ||||
-rw-r--r-- | Python/peephole.c | 6 | ||||
-rw-r--r-- | Python/pytime.c | 8 |
3 files changed, 10 insertions, 6 deletions
diff --git a/Python/formatter_unicode.c b/Python/formatter_unicode.c index 55ed59d368..841b25a43f 100644 --- a/Python/formatter_unicode.c +++ b/Python/formatter_unicode.c @@ -574,7 +574,7 @@ calc_number_widths(NumberFieldWidths *spec, Py_ssize_t n_prefix, spec->n_lpadding = n_padding; break; default: - /* Shouldn't get here, but treat it as '>' */ + /* Shouldn't get here */ Py_UNREACHABLE(); } } diff --git a/Python/peephole.c b/Python/peephole.c index baa217ad02..84de1abc17 100644 --- a/Python/peephole.c +++ b/Python/peephole.c @@ -511,8 +511,12 @@ PyCode_Optimize(PyObject *code, PyObject* consts, PyObject *names, if (instrsize(j) > ilen) { goto exitUnchanged; } - assert(ilen <= INT_MAX); /* If instrsize(j) < ilen, we'll emit EXTENDED_ARG 0 */ + if (ilen > 4) { + /* Can only happen when PyCode_Optimize() is called with + malformed bytecode. */ + goto exitUnchanged; + } write_op_arg(codestr + h, opcode, j, (int)ilen); h += ilen; } diff --git a/Python/pytime.c b/Python/pytime.c index 9b2b74af5c..6affccbeff 100644 --- a/Python/pytime.c +++ b/Python/pytime.c @@ -746,7 +746,7 @@ _PyTime_GetSystemClock(void) _PyTime_t t; if (pygettimeofday(&t, NULL, 0) < 0) { /* should not happen, _PyTime_Init() checked the clock at startup */ - Py_UNREACHABLE(); + Py_FatalError("pygettimeofday() failed"); } return t; } @@ -776,7 +776,7 @@ pymonotonic(_PyTime_t *tp, _Py_clock_info_t *info, int raise) return -1; } /* Hello, time traveler! */ - Py_UNREACHABLE(); + Py_FatalError("pymonotonic: integer overflow"); } *tp = t * MS_TO_NS; @@ -918,7 +918,7 @@ _PyTime_GetMonotonicClock(void) if (pymonotonic(&t, NULL, 0) < 0) { /* should not happen, _PyTime_Init() checked that monotonic clock at startup */ - Py_UNREACHABLE(); + Py_FatalError("pymonotonic() failed"); } return t; } @@ -1019,7 +1019,7 @@ _PyTime_GetPerfCounter(void) { _PyTime_t t; if (_PyTime_GetPerfCounterWithInfo(&t, NULL)) { - Py_UNREACHABLE(); + Py_FatalError("_PyTime_GetPerfCounterWithInfo() failed"); } return t; } |