gh-115801: Only allow sequence of strings as input for difflib.unified_diff (GH-118333)

This commit is contained in:
Pieter Eendebak 2024-06-10 13:06:18 +02:00 committed by GitHub
parent b90bd3e5bb
commit c3b6dbff2c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 31 additions and 6 deletions

View file

@ -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,))