Jurjen N.E. Bos added the comment:
I am not as good in making nice patches, but that code can be improved upon a
bit as follows:
<insert patch intro blurb here, same as original>
+ if isinstance(obj, str) and source_lines is not None:
+ # This will find __test__ string doctests if and only if the string
+ # contains any unique line.
+ for offset,line in enumerate(obj.splitlines(keepends=True):
+ if source_lines.count(line)==1:
+ lineno = source_lines.index(line)-offset
+ break
# We couldn't find the line number.
return None
I thing this will improve legibility and probably also speed under most
circumstances.
----------
nosy: +jneb
_______________________________________
Python tracker <[email protected]>
<http://bugs.python.org/issue24925>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com