From 7849c66e8adbaaddc6f4c9806d409981277feb88 Mon Sep 17 00:00:00 2001 From: Sergey B Kirpichev Date: Thu, 30 May 2024 15:23:47 +0300 Subject: [PATCH 1/5] gh-119780: Adjust exception messages in Lib/test/test_format.py --- Lib/test/test_format.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Lib/test/test_format.py b/Lib/test/test_format.py index 8cef621bd716ac..d2026152d8e747 100644 --- a/Lib/test/test_format.py +++ b/Lib/test/test_format.py @@ -304,9 +304,9 @@ def test_str_format(self): test_exc('%c', sys.maxunicode+1, OverflowError, "%c arg not in range(0x110000)") #test_exc('%c', 2**128, OverflowError, "%c arg not in range(0x110000)") - test_exc('%c', 3.14, TypeError, "%c requires int or char") - test_exc('%c', 'ab', TypeError, "%c requires int or char") - test_exc('%c', b'x', TypeError, "%c requires int or char") + test_exc('%c', 3.14, TypeError, "%c requires an int or a unicode character, not float") + test_exc('%c', 'ab', TypeError, "%c requires an int or a unicode character, not a string of length 2") + test_exc('%c', b'x', TypeError, "%c requires an int or a unicode character, not bytes") if maxsize == 2**31-1: # crashes 2.2.1 and earlier: @@ -370,11 +370,11 @@ def __bytes__(self): test_exc(b"%c", 2**128, OverflowError, "%c arg not in range(256)") test_exc(b"%c", b"Za", TypeError, - "%c requires an integer in range(256) or a single byte") + "%c requires an integer in range(256) or a single byte, not a bytes object of length 2") test_exc(b"%c", "Y", TypeError, - "%c requires an integer in range(256) or a single byte") + "%c requires an integer in range(256) or a single byte, not str") test_exc(b"%c", 3.14, TypeError, - "%c requires an integer in range(256) or a single byte") + "%c requires an integer in range(256) or a single byte, not float") test_exc(b"%b", "Xc", TypeError, "%b requires a bytes-like object, " "or an object that implements __bytes__, not 'str'") From 7f9b4d0c1cdaabfa9aec01ef9856793f328c0359 Mon Sep 17 00:00:00 2001 From: Sergey B Kirpichev Date: Thu, 30 May 2024 16:27:09 +0300 Subject: [PATCH 2/5] + add missing (?) raise --- Lib/test/test_format.py | 1 + 1 file changed, 1 insertion(+) diff --git a/Lib/test/test_format.py b/Lib/test/test_format.py index d2026152d8e747..2b1538614adb01 100644 --- a/Lib/test/test_format.py +++ b/Lib/test/test_format.py @@ -82,6 +82,7 @@ def test_exc(formatstr, args, exception, excmsg): else: if verbose: print('no') print('Unexpected ', exception, ':', repr(str(exc))) + raise except: if verbose: print('no') print('Unexpected exception') From ef2ab1a99c8d3e06c0cb7fc6ecee05bcf4e87534 Mon Sep 17 00:00:00 2001 From: Sergey B Kirpichev Date: Fri, 31 May 2024 06:45:15 +0300 Subject: [PATCH 3/5] Revert "gh-119780: Adjust exception messages in Lib/test/test_format.py" This reverts commit 7849c66e8adbaaddc6f4c9806d409981277feb88. --- Lib/test/test_format.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Lib/test/test_format.py b/Lib/test/test_format.py index 2b1538614adb01..2f24df95bb132e 100644 --- a/Lib/test/test_format.py +++ b/Lib/test/test_format.py @@ -305,9 +305,9 @@ def test_str_format(self): test_exc('%c', sys.maxunicode+1, OverflowError, "%c arg not in range(0x110000)") #test_exc('%c', 2**128, OverflowError, "%c arg not in range(0x110000)") - test_exc('%c', 3.14, TypeError, "%c requires an int or a unicode character, not float") - test_exc('%c', 'ab', TypeError, "%c requires an int or a unicode character, not a string of length 2") - test_exc('%c', b'x', TypeError, "%c requires an int or a unicode character, not bytes") + test_exc('%c', 3.14, TypeError, "%c requires int or char") + test_exc('%c', 'ab', TypeError, "%c requires int or char") + test_exc('%c', b'x', TypeError, "%c requires int or char") if maxsize == 2**31-1: # crashes 2.2.1 and earlier: @@ -371,11 +371,11 @@ def __bytes__(self): test_exc(b"%c", 2**128, OverflowError, "%c arg not in range(256)") test_exc(b"%c", b"Za", TypeError, - "%c requires an integer in range(256) or a single byte, not a bytes object of length 2") + "%c requires an integer in range(256) or a single byte") test_exc(b"%c", "Y", TypeError, - "%c requires an integer in range(256) or a single byte, not str") + "%c requires an integer in range(256) or a single byte") test_exc(b"%c", 3.14, TypeError, - "%c requires an integer in range(256) or a single byte, not float") + "%c requires an integer in range(256) or a single byte") test_exc(b"%b", "Xc", TypeError, "%b requires a bytes-like object, " "or an object that implements __bytes__, not 'str'") From 31fb41320ba820a30c5d469bdc049a48e695284f Mon Sep 17 00:00:00 2001 From: Sergey B Kirpichev Date: Fri, 31 May 2024 07:43:03 +0300 Subject: [PATCH 4/5] Revert "Revert "gh-119780: Adjust exception messages in Lib/test/test_format.py"" This reverts commit ef2ab1a99c8d3e06c0cb7fc6ecee05bcf4e87534. --- Lib/test/test_format.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Lib/test/test_format.py b/Lib/test/test_format.py index 2f24df95bb132e..2b1538614adb01 100644 --- a/Lib/test/test_format.py +++ b/Lib/test/test_format.py @@ -305,9 +305,9 @@ def test_str_format(self): test_exc('%c', sys.maxunicode+1, OverflowError, "%c arg not in range(0x110000)") #test_exc('%c', 2**128, OverflowError, "%c arg not in range(0x110000)") - test_exc('%c', 3.14, TypeError, "%c requires int or char") - test_exc('%c', 'ab', TypeError, "%c requires int or char") - test_exc('%c', b'x', TypeError, "%c requires int or char") + test_exc('%c', 3.14, TypeError, "%c requires an int or a unicode character, not float") + test_exc('%c', 'ab', TypeError, "%c requires an int or a unicode character, not a string of length 2") + test_exc('%c', b'x', TypeError, "%c requires an int or a unicode character, not bytes") if maxsize == 2**31-1: # crashes 2.2.1 and earlier: @@ -371,11 +371,11 @@ def __bytes__(self): test_exc(b"%c", 2**128, OverflowError, "%c arg not in range(256)") test_exc(b"%c", b"Za", TypeError, - "%c requires an integer in range(256) or a single byte") + "%c requires an integer in range(256) or a single byte, not a bytes object of length 2") test_exc(b"%c", "Y", TypeError, - "%c requires an integer in range(256) or a single byte") + "%c requires an integer in range(256) or a single byte, not str") test_exc(b"%c", 3.14, TypeError, - "%c requires an integer in range(256) or a single byte") + "%c requires an integer in range(256) or a single byte, not float") test_exc(b"%b", "Xc", TypeError, "%b requires a bytes-like object, " "or an object that implements __bytes__, not 'str'") From 0ce90943d25732a6523b515e651ff5a136e36c6e Mon Sep 17 00:00:00 2001 From: Sergey B Kirpichev Date: Fri, 31 May 2024 07:43:14 +0300 Subject: [PATCH 5/5] Revert "+ add missing (?) raise" This reverts commit 7f9b4d0c1cdaabfa9aec01ef9856793f328c0359. --- Lib/test/test_format.py | 1 - 1 file changed, 1 deletion(-) diff --git a/Lib/test/test_format.py b/Lib/test/test_format.py index 2b1538614adb01..d2026152d8e747 100644 --- a/Lib/test/test_format.py +++ b/Lib/test/test_format.py @@ -82,7 +82,6 @@ def test_exc(formatstr, args, exception, excmsg): else: if verbose: print('no') print('Unexpected ', exception, ':', repr(str(exc))) - raise except: if verbose: print('no') print('Unexpected exception')