Skip to content
This repository has been archived by the owner on Jul 5, 2023. It is now read-only.

Use PyUnicode_DecodeUnicodeEscape directly #172

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
22 changes: 1 addition & 21 deletions ast3/Python/ast.c
Expand Up @@ -58,16 +58,6 @@ _PyBytes_DecodeEscape(const char *s,

#endif

PyObject *
_PyUnicode_DecodeUnicodeEscape(const char *s,
Py_ssize_t size,
const char *errors,
const char **first_invalid_escape)
{
*first_invalid_escape = NULL;
return PyUnicode_DecodeUnicodeEscape(s, size, errors);
}

static int validate_stmts(asdl_seq *);
static int validate_exprs(asdl_seq *, expr_context_ty, int);
static int validate_nonempty_seq(asdl_seq *, const char *, const char *);
Expand Down Expand Up @@ -4461,7 +4451,6 @@ decode_unicode_with_escapes(struct compiling *c, const node *n, const char *s,
char *buf;
char *p;
const char *end;
const char *first_invalid_escape;

/* check for integer overflow */
if (len > SIZE_MAX / 6)
Expand Down Expand Up @@ -4511,17 +4500,8 @@ decode_unicode_with_escapes(struct compiling *c, const node *n, const char *s,
len = p - buf;
s = buf;

v = _PyUnicode_DecodeUnicodeEscape(s, len, NULL, &first_invalid_escape);
v = PyUnicode_DecodeUnicodeEscape(s, len, NULL);

if (v != NULL && first_invalid_escape != NULL) {
if (warn_invalid_escape_sequence(c, n, *first_invalid_escape) < 0) {
/* We have not decref u before because first_invalid_escape points
inside u. */
Py_XDECREF(u);
Py_DECREF(v);
return NULL;
}
}
Py_XDECREF(u);
return v;
}
Expand Down