summaryrefslogtreecommitdiffstats
path: root/Objects/unicodeobject.c
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2024-04-08 16:27:25 (GMT)
committerGitHub <noreply@github.com>2024-04-08 16:27:25 (GMT)
commit24a2bd048115efae799b0a9c5dd9fbb7a0806978 (patch)
tree38bf066ab930bebc5bbe661478d0ded22e5bafb5 /Objects/unicodeobject.c
parent1a6594f66166206b08f24c3ba633c85f86f99a56 (diff)
downloadcpython-24a2bd048115efae799b0a9c5dd9fbb7a0806978.zip
cpython-24a2bd048115efae799b0a9c5dd9fbb7a0806978.tar.gz
cpython-24a2bd048115efae799b0a9c5dd9fbb7a0806978.tar.bz2
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.
Diffstat (limited to 'Objects/unicodeobject.c')
-rw-r--r--Objects/unicodeobject.c7
1 files changed, 3 insertions, 4 deletions
diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c
index 59b350f..5f15071 100644
--- a/Objects/unicodeobject.c
+++ b/Objects/unicodeobject.c
@@ -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);