Skip to content

Commit 5b172c2

Browse files
DinoVmiss-islington
authored andcommitted
bpo-38113: Update Python/ast.c to PEP-384 (GH-15975)
Removes statics for better subinterpreter support and moves to _PyType_Name https://bugs.python.org/issue38113 Automerge-Triggered-By: @tiran
1 parent 0cc2741 commit 5b172c2

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

Python/ast.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,7 @@ validate_expr(expr_ty exp, expr_context_ty ctx)
294294
if (!validate_constant(exp->v.Constant.value)) {
295295
PyErr_Format(PyExc_TypeError,
296296
"got an invalid type in Constant: %s",
297-
Py_TYPE(exp->v.Constant.value)->tp_name);
297+
_PyType_Name(Py_TYPE(exp->v.Constant.value)));
298298
return 0;
299299
}
300300
return 1;
@@ -618,12 +618,11 @@ new_identifier(const char *n, struct compiling *c)
618618
identifier; if so, normalize to NFKC. */
619619
if (!PyUnicode_IS_ASCII(id)) {
620620
PyObject *id2;
621-
_Py_IDENTIFIER(NFKC);
622621
if (!c->c_normalize && !init_normalization(c)) {
623622
Py_DECREF(id);
624623
return NULL;
625624
}
626-
PyObject *form = _PyUnicode_FromId(&PyId_NFKC);
625+
PyObject *form = PyUnicode_InternFromString("NFKC");
627626
if (form == NULL) {
628627
Py_DECREF(id);
629628
return NULL;
@@ -637,7 +636,7 @@ new_identifier(const char *n, struct compiling *c)
637636
PyErr_Format(PyExc_TypeError,
638637
"unicodedata.normalize() must return a string, not "
639638
"%.200s",
640-
Py_TYPE(id2)->tp_name);
639+
_PyType_Name(Py_TYPE(id2)));
641640
Py_DECREF(id2);
642641
return NULL;
643642
}

0 commit comments

Comments
 (0)