diff options
author | John Belmonte <john@neggie.net> | 2023-05-01 19:47:14 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-05-01 19:47:14 (GMT) |
commit | 3ed8c882902a6982fd67e898a5b8a2d619fb5ddf (patch) | |
tree | 1ff3877549a81494f84a6ca36b0f47dd52768c75 /Lib | |
parent | 5078eedc5b18f0d208af6e30f60b33419132d1b6 (diff) | |
download | cpython-3ed8c882902a6982fd67e898a5b8a2d619fb5ddf.zip cpython-3ed8c882902a6982fd67e898a5b8a2d619fb5ddf.tar.gz cpython-3ed8c882902a6982fd67e898a5b8a2d619fb5ddf.tar.bz2 |
gh-104018: disallow "z" format specifier in %-format of byte strings (GH-104033)
PEP-0682 specified that %-formatting would not support the "z" specifier,
but it was unintentionally allowed for bytes. This PR makes use of the "z"
flag an error for %-formatting in a bytestring.
Issue: #104018
---------
Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/test/test_format.py | 2 |
1 files changed, 2 insertions, 0 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__": |