[issue17445] Return the type you accept

Greg Ward report at bugs.python.org
Mon Mar 18 19:43:01 CET 2013


Greg Ward added the comment:

The original reproduction I posted was incorrect -- it makes difflib look worse than it should. (I passed strings rather than lists of strings.) Here is a more accurate version:

>>> import difflib
>>> a = [b'hello']
>>> b = [b'hello!']
>>> '\n'.join(line for line in difflib.unified_diff(a, b))
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "<stdin>", line 1, in <genexpr>
  File "/home/greg/src/cpython/3.3/Lib/difflib.py", line 1223, in unified_diff
    yield '-' + line
TypeError: Can't convert 'bytes' object to str implicitly

So it still crashes, but the exception makes it pretty clear what the problem is.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue17445>
_______________________________________


More information about the Python-bugs-list mailing list