mirror of
https://github.com/python/cpython.git
synced 2025-08-29 05:05:03 +00:00
gh-115801: Only allow sequence of strings as input for difflib.unified_diff (GH-118333)
This commit is contained in:
parent
b90bd3e5bb
commit
c3b6dbff2c
3 changed files with 31 additions and 6 deletions
|
@ -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,))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue