mirror of
https://github.com/python/cpython.git
synced 2025-10-09 16:34:44 +00:00
Strip trailing spaces in _json.c
This commit is contained in:
parent
c4f281eba3
commit
d9c0631d77
1 changed files with 15 additions and 15 deletions
|
@ -218,7 +218,7 @@ ascii_escape_unicode(PyObject *pystr)
|
||||||
output_size++;
|
output_size++;
|
||||||
else {
|
else {
|
||||||
switch(c) {
|
switch(c) {
|
||||||
case '\\': case '"': case '\b': case '\f':
|
case '\\': case '"': case '\b': case '\f':
|
||||||
case '\n': case '\r': case '\t':
|
case '\n': case '\r': case '\t':
|
||||||
output_size += 2; break;
|
output_size += 2; break;
|
||||||
default:
|
default:
|
||||||
|
@ -434,7 +434,7 @@ scanstring_unicode(PyObject *pystr, Py_ssize_t end, int strict, Py_ssize_t *next
|
||||||
raise_errmsg("Unpaired high surrogate", pystr, end - 5);
|
raise_errmsg("Unpaired high surrogate", pystr, end - 5);
|
||||||
goto bail;
|
goto bail;
|
||||||
}
|
}
|
||||||
if (PyUnicode_READ(kind, buf, next++) != '\\' ||
|
if (PyUnicode_READ(kind, buf, next++) != '\\' ||
|
||||||
PyUnicode_READ(kind, buf, next++) != 'u') {
|
PyUnicode_READ(kind, buf, next++) != 'u') {
|
||||||
raise_errmsg("Unpaired high surrogate", pystr, end - 5);
|
raise_errmsg("Unpaired high surrogate", pystr, end - 5);
|
||||||
goto bail;
|
goto bail;
|
||||||
|
@ -1027,9 +1027,9 @@ scan_once_unicode(PyScannerObject *s, PyObject *pystr, Py_ssize_t idx, Py_ssize_
|
||||||
break;
|
break;
|
||||||
case 'f':
|
case 'f':
|
||||||
/* false */
|
/* false */
|
||||||
if ((idx + 4 < length) && PyUnicode_READ(kind, str, idx + 1) == 'a' &&
|
if ((idx + 4 < length) && PyUnicode_READ(kind, str, idx + 1) == 'a' &&
|
||||||
PyUnicode_READ(kind, str, idx + 2) == 'l' &&
|
PyUnicode_READ(kind, str, idx + 2) == 'l' &&
|
||||||
PyUnicode_READ(kind, str, idx + 3) == 's' &&
|
PyUnicode_READ(kind, str, idx + 3) == 's' &&
|
||||||
PyUnicode_READ(kind, str, idx + 4) == 'e') {
|
PyUnicode_READ(kind, str, idx + 4) == 'e') {
|
||||||
Py_INCREF(Py_False);
|
Py_INCREF(Py_False);
|
||||||
*next_idx_ptr = idx + 5;
|
*next_idx_ptr = idx + 5;
|
||||||
|
@ -1038,32 +1038,32 @@ scan_once_unicode(PyScannerObject *s, PyObject *pystr, Py_ssize_t idx, Py_ssize_
|
||||||
break;
|
break;
|
||||||
case 'N':
|
case 'N':
|
||||||
/* NaN */
|
/* NaN */
|
||||||
if ((idx + 2 < length) && PyUnicode_READ(kind, str, idx + 1) == 'a' &&
|
if ((idx + 2 < length) && PyUnicode_READ(kind, str, idx + 1) == 'a' &&
|
||||||
PyUnicode_READ(kind, str, idx + 2) == 'N') {
|
PyUnicode_READ(kind, str, idx + 2) == 'N') {
|
||||||
return _parse_constant(s, "NaN", idx, next_idx_ptr);
|
return _parse_constant(s, "NaN", idx, next_idx_ptr);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'I':
|
case 'I':
|
||||||
/* Infinity */
|
/* Infinity */
|
||||||
if ((idx + 7 < length) && PyUnicode_READ(kind, str, idx + 1) == 'n' &&
|
if ((idx + 7 < length) && PyUnicode_READ(kind, str, idx + 1) == 'n' &&
|
||||||
PyUnicode_READ(kind, str, idx + 2) == 'f' &&
|
PyUnicode_READ(kind, str, idx + 2) == 'f' &&
|
||||||
PyUnicode_READ(kind, str, idx + 3) == 'i' &&
|
PyUnicode_READ(kind, str, idx + 3) == 'i' &&
|
||||||
PyUnicode_READ(kind, str, idx + 4) == 'n' &&
|
PyUnicode_READ(kind, str, idx + 4) == 'n' &&
|
||||||
PyUnicode_READ(kind, str, idx + 5) == 'i' &&
|
PyUnicode_READ(kind, str, idx + 5) == 'i' &&
|
||||||
PyUnicode_READ(kind, str, idx + 6) == 't' &&
|
PyUnicode_READ(kind, str, idx + 6) == 't' &&
|
||||||
PyUnicode_READ(kind, str, idx + 7) == 'y') {
|
PyUnicode_READ(kind, str, idx + 7) == 'y') {
|
||||||
return _parse_constant(s, "Infinity", idx, next_idx_ptr);
|
return _parse_constant(s, "Infinity", idx, next_idx_ptr);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case '-':
|
case '-':
|
||||||
/* -Infinity */
|
/* -Infinity */
|
||||||
if ((idx + 8 < length) && PyUnicode_READ(kind, str, idx + 1) == 'I' &&
|
if ((idx + 8 < length) && PyUnicode_READ(kind, str, idx + 1) == 'I' &&
|
||||||
PyUnicode_READ(kind, str, idx + 2) == 'n' &&
|
PyUnicode_READ(kind, str, idx + 2) == 'n' &&
|
||||||
PyUnicode_READ(kind, str, idx + 3) == 'f' &&
|
PyUnicode_READ(kind, str, idx + 3) == 'f' &&
|
||||||
PyUnicode_READ(kind, str, idx + 4) == 'i' &&
|
PyUnicode_READ(kind, str, idx + 4) == 'i' &&
|
||||||
PyUnicode_READ(kind, str, idx + 5) == 'n' &&
|
PyUnicode_READ(kind, str, idx + 5) == 'n' &&
|
||||||
PyUnicode_READ(kind, str, idx + 6) == 'i' &&
|
PyUnicode_READ(kind, str, idx + 6) == 'i' &&
|
||||||
PyUnicode_READ(kind, str, idx + 7) == 't' &&
|
PyUnicode_READ(kind, str, idx + 7) == 't' &&
|
||||||
PyUnicode_READ(kind, str, idx + 8) == 'y') {
|
PyUnicode_READ(kind, str, idx + 8) == 'y') {
|
||||||
return _parse_constant(s, "-Infinity", idx, next_idx_ptr);
|
return _parse_constant(s, "-Infinity", idx, next_idx_ptr);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue