Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Fix `repr_traceback` to work with unicode errors #1506
The tests are passing. I actually have mixed felling about the way I did it. The other possible way is to use something like:
After some thought I realized that we only need to check if the exception was a "maximum recursion depth" exception, we don't need to try to come up with a generic solution to convert a solution to string first.
With that in mind how about:
# code.py if sys.version_info[:2] >= (3, 5): # RecursionError introduced in 3.5 def is_recursion_error(exception): return isinstance(exception, RecursionError) else: def is_recursion_error(exception): if not isinstance(exception, RuntimeError): return False try: return "maximum recursion depth exceeded" in str(exception) except UnicodeDecodeError: return False class FormattedExcinfo(object): ... def repr_traceback(self, excinfo): traceback = excinfo.traceback if self.tbfilter: traceback = traceback.filter() recursionindex = None if is_recursion_error(excinfo.value): recursionindex = traceback.recursionindex() ...
What do you think?