gh-117642: Fix PEP 737 implementation (GH-117643)

* Fix implementation of %#T and %#N (they were implemented as %T# and
  %N#).
* Restore tests removed in gh-116417.
This commit is contained in:
Serhiy Storchaka 2024-04-08 19:27:25 +03:00 committed by GitHub
parent 1a6594f661
commit 24a2bd0481
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 42 additions and 8 deletions

View file

@ -2468,6 +2468,7 @@ unicode_fromformat_arg(_PyUnicodeWriter *writer,
switch (*f++) {
case '-': flags |= F_LJUST; continue;
case '0': flags |= F_ZERO; continue;
case '#': flags |= F_ALT; continue;
}
f--;
break;
@ -2797,9 +2798,8 @@ unicode_fromformat_arg(_PyUnicodeWriter *writer,
PyTypeObject *type = (PyTypeObject *)Py_NewRef(Py_TYPE(obj));
PyObject *type_name;
if (f[1] == '#') {
if (flags & F_ALT) {
type_name = _PyType_GetFullyQualifiedName(type, ':');
f++;
}
else {
type_name = PyType_GetFullyQualifiedName(type);
@ -2830,9 +2830,8 @@ unicode_fromformat_arg(_PyUnicodeWriter *writer,
PyTypeObject *type = (PyTypeObject*)type_raw;
PyObject *type_name;
if (f[1] == '#') {
if (flags & F_ALT) {
type_name = _PyType_GetFullyQualifiedName(type, ':');
f++;
}
else {
type_name = PyType_GetFullyQualifiedName(type);