Qix-/better-exceptions
View on GitHubList of small errors to fix and possible improvements to implement
Open
#47 opened on Sep 13, 2017
bugenhancementhelp wanted
Description
I prefer to gather everything here rather than opening a ticket for each of them, as some bugs are really minimal. Some points are just ideas I have had.
- Nested issues are not displayed (see)
- Surround
repr(value)withtry / exceptjust in case something goes wrong (seetracebacksource code) -
PrintTraceback (most recent call last):right before formatting the issue, so user have a clue about what is going wrong if formatting hangs (see #37) -
\ninside a string should be escaped, no newline should be displayed (see) -
SyntaxErrorare wrongly truncated (see and see #35) - Multilines expressions like
a = 1 + [2, \n 3]are not enhanced - Encoding issues:
-
"天" / 1is wrongly displayed as"天" / 11because of utf-8 string slicing (see) - Do not force char decoding, stay close to the default behavior displaying
"\u5929"instead of"天"ifLANG = en_US.ascii(see) - Keep the quotation marks and
ustring prefixes used in the source code, do not replace them with'marks (see) - Encoding long strings may raise an error (see #34)
-
- Possible readability improvement:
- Syntax highlighting could (optionally) include operators (
*,+,-,/, ...), functions, methods -
intandstringvalues could be highlighted with two different colors - Traceback frames could be optionally spaced between each others (see)
- Is it possible for shadowed built-in (
len = lambda x: 5) to not be higlighted as a built-in? - Location (
File "test.py", line 13 in func) could be colored (see #38) - Other messages (like
Exception: XXX,Traceback (most recent call last):, ...) could be optionally colored too - Traceback relevant to the user could be bold / not relevant could be dimmed (see #38)
- Advanced user could have more control over formatting to suit its need with colors which works best on its terminal, or by customizing style (see #39). For example:
import better_exceptions; better_exceptions.THEME['location_message'] = 'File "{filepath} +{lineno}", in {source}'. Maybe useansimarkupto easily colorize / strip (ifSUPPORTS_COLORSisFalse) messages. -
c = self.a + self.b: is it possible to give information aboutaandb? It seems very complicated. What aboutdct['key'],lst[3],obj.val,a.b.c,x.get('key', default), etc.
- Syntax highlighting could (optionally) include operators (