summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Lib/test/test_format.py2
-rw-r--r--Misc/NEWS.d/next/Core and Builtins/2023-05-01-12-03-52.gh-issue-104018.PFxGS4.rst1
-rw-r--r--Objects/bytesobject.c1
3 files changed, 3 insertions, 1 deletions
diff --git a/Lib/test/test_format.py b/Lib/test/test_format.py
index 69b0d5f..6fa49db 100644
--- a/Lib/test/test_format.py
+++ b/Lib/test/test_format.py
@@ -619,6 +619,8 @@ class FormatTest(unittest.TestCase):
error_msg = re.escape("unsupported format character 'z'")
with self.assertRaisesRegex(ValueError, error_msg):
"%z.1f" % 0 # not allowed in old style string interpolation
+ with self.assertRaisesRegex(ValueError, error_msg):
+ b"%z.1f" % 0
if __name__ == "__main__":
diff --git a/Misc/NEWS.d/next/Core and Builtins/2023-05-01-12-03-52.gh-issue-104018.PFxGS4.rst b/Misc/NEWS.d/next/Core and Builtins/2023-05-01-12-03-52.gh-issue-104018.PFxGS4.rst
new file mode 100644
index 0000000..f3cadae
--- /dev/null
+++ b/Misc/NEWS.d/next/Core and Builtins/2023-05-01-12-03-52.gh-issue-104018.PFxGS4.rst
@@ -0,0 +1 @@
+Disallow the "z" format specifier in %-format of bytes objects.
diff --git a/Objects/bytesobject.c b/Objects/bytesobject.c
index 8dd1a2d..61cde0e 100644
--- a/Objects/bytesobject.c
+++ b/Objects/bytesobject.c
@@ -714,7 +714,6 @@ _PyBytes_FormatEx(const char *format, Py_ssize_t format_len,
case ' ': flags |= F_BLANK; continue;
case '#': flags |= F_ALT; continue;
case '0': flags |= F_ZERO; continue;
- case 'z': flags |= F_NO_NEG_0; continue;
}
break;
}