aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/Lib/difflib.py
diff options
context:
space:
mode:
authorPieter Eendebak <pieter.eendebak@gmail.com>2024-06-10 13:06:18 +0200
committerGitHub <noreply@github.com>2024-06-10 14:06:18 +0300
commitc3b6dbff2c8886de1edade737febe85dd47ff4d0 (patch)
tree17d7a14f7e1c9bf239f1a38ccf7eb24d303c6745 /Lib/difflib.py
parentb90bd3e5bbc136f53b24ee791824acd6b17e0d42 (diff)
downloadcpython-c3b6dbff2c8886de1edade737febe85dd47ff4d0.tar.gz
cpython-c3b6dbff2c8886de1edade737febe85dd47ff4d0.zip
gh-115801: Only allow sequence of strings as input for difflib.unified_diff (GH-118333)
Diffstat (limited to 'Lib/difflib.py')
-rw-r--r--Lib/difflib.py6
1 files changed, 6 insertions, 0 deletions
diff --git a/Lib/difflib.py b/Lib/difflib.py
index 0443963b4fd..7f595b6c72e 100644
--- a/Lib/difflib.py
+++ b/Lib/difflib.py
@@ -1264,6 +1264,12 @@ def _check_types(a, b, *args):
if b and not isinstance(b[0], str):
raise TypeError('lines to compare must be str, not %s (%r)' %
(type(b[0]).__name__, b[0]))
+ if isinstance(a, str):
+ raise TypeError('input must be a sequence of strings, not %s' %
+ type(a).__name__)
+ if isinstance(b, str):
+ raise TypeError('input must be a sequence of strings, not %s' %
+ type(b).__name__)
for arg in args:
if not isinstance(arg, str):
raise TypeError('all arguments must be str, not: %r' % (arg,))