mirror of
https://github.com/python/cpython.git
synced 2025-08-30 21:48:47 +00:00
It doesn't work to use #define XXX defined(YYY)" and then "#ifdef XXX" to check YYY.
This commit is contained in:
parent
6174474bea
commit
5ebae87628
2 changed files with 46 additions and 12 deletions
|
@ -4605,9 +4605,9 @@ utime_fd(utime_t *ut, int fd)
|
||||||
#define PATH_UTIME_HAVE_FD 0
|
#define PATH_UTIME_HAVE_FD 0
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(HAVE_UTIMENSAT) || defined(HAVE_LUTIMES)
|
||||||
#define UTIME_HAVE_NOFOLLOW_SYMLINKS \
|
# define UTIME_HAVE_NOFOLLOW_SYMLINKS
|
||||||
(defined(HAVE_UTIMENSAT) || defined(HAVE_LUTIMES))
|
#endif
|
||||||
|
|
||||||
#ifdef UTIME_HAVE_NOFOLLOW_SYMLINKS
|
#ifdef UTIME_HAVE_NOFOLLOW_SYMLINKS
|
||||||
|
|
||||||
|
|
|
@ -4709,8 +4709,9 @@ PyUnicode_DecodeUTF8Stateful(const char *s,
|
||||||
Py_ssize_t startinpos;
|
Py_ssize_t startinpos;
|
||||||
Py_ssize_t endinpos;
|
Py_ssize_t endinpos;
|
||||||
const char *errmsg = "";
|
const char *errmsg = "";
|
||||||
PyObject *errorHandler = NULL;
|
PyObject *error_handler_obj = NULL;
|
||||||
PyObject *exc = NULL;
|
PyObject *exc = NULL;
|
||||||
|
_Py_error_handler error_handler = _Py_ERROR_UNKNOWN;
|
||||||
|
|
||||||
if (size == 0) {
|
if (size == 0) {
|
||||||
if (consumed)
|
if (consumed)
|
||||||
|
@ -4773,24 +4774,57 @@ PyUnicode_DecodeUTF8Stateful(const char *s,
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (unicode_decode_call_errorhandler_writer(
|
/* undecodable byte: call the error handler */
|
||||||
errors, &errorHandler,
|
|
||||||
"utf-8", errmsg,
|
if (error_handler == _Py_ERROR_UNKNOWN)
|
||||||
&starts, &end, &startinpos, &endinpos, &exc, &s,
|
error_handler = get_error_handler(errors);
|
||||||
&writer))
|
|
||||||
goto onError;
|
switch (error_handler)
|
||||||
|
{
|
||||||
|
case _Py_ERROR_REPLACE:
|
||||||
|
case _Py_ERROR_SURROGATEESCAPE:
|
||||||
|
{
|
||||||
|
unsigned char ch = (unsigned char)*s;
|
||||||
|
|
||||||
|
/* Fast-path: the error handler only writes one character,
|
||||||
|
but we may switch to UCS2 at the first write */
|
||||||
|
if (_PyUnicodeWriter_PrepareKind(&writer, PyUnicode_2BYTE_KIND) < 0)
|
||||||
|
goto onError;
|
||||||
|
kind = writer.kind;
|
||||||
|
|
||||||
|
if (error_handler == _Py_ERROR_REPLACE)
|
||||||
|
PyUnicode_WRITE(kind, writer.data, writer.pos, 0xfffd);
|
||||||
|
else
|
||||||
|
PyUnicode_WRITE(kind, writer.data, writer.pos, ch + 0xdc00);
|
||||||
|
writer.pos++;
|
||||||
|
++s;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case _Py_ERROR_IGNORE:
|
||||||
|
s++;
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
if (unicode_decode_call_errorhandler_writer(
|
||||||
|
errors, &error_handler_obj,
|
||||||
|
"utf-8", errmsg,
|
||||||
|
&starts, &end, &startinpos, &endinpos, &exc, &s,
|
||||||
|
&writer))
|
||||||
|
goto onError;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
End:
|
End:
|
||||||
if (consumed)
|
if (consumed)
|
||||||
*consumed = s - starts;
|
*consumed = s - starts;
|
||||||
|
|
||||||
Py_XDECREF(errorHandler);
|
Py_XDECREF(error_handler_obj);
|
||||||
Py_XDECREF(exc);
|
Py_XDECREF(exc);
|
||||||
return _PyUnicodeWriter_Finish(&writer);
|
return _PyUnicodeWriter_Finish(&writer);
|
||||||
|
|
||||||
onError:
|
onError:
|
||||||
Py_XDECREF(errorHandler);
|
Py_XDECREF(error_handler_obj);
|
||||||
Py_XDECREF(exc);
|
Py_XDECREF(exc);
|
||||||
_PyUnicodeWriter_Dealloc(&writer);
|
_PyUnicodeWriter_Dealloc(&writer);
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue