mahmoud / boltons

🔩 Like builtins, but boltons. 250+ constructs, recipes, and snippets which extend (and rely on nothing but) the Python standard library. Nothing like Michael Bolton.
https://boltons.readthedocs.org
Other
6.54k stars 353 forks source link

Update tbutils.py to parse tracebacks with anchor lines #332

Closed sestinj closed 1 year ago

sestinj commented 1 year ago

Anchors are sometimes added below the source line, (see https://github.com/python/cpython/blob/dcd6f226d6596b25b6f4004058a67acabe012120/Lib/traceback.py#L479-L510). This fix will allow parsing to continue as normal in their presence

mahmoud commented 1 year ago

Ohhh very very nice, yes I was just running into something related today. Any chance we could get a test over here? https://github.com/mahmoud/boltons/blob/master/tests/test_tbutils_parsed_exc.py

Thanks for getting the ball rolling in either case!

sestinj commented 1 year ago

Of course, here's a test! Added a note, but obviously without storing more information about columns in ParsedException (already noted here that some of this is missing), this will break the to_string(from_string(original_tb)) == original_tb property.

mahmoud commented 1 year ago

Good point. I'm not opposed to adding more attributes, of course. Any interest in pursuing that in this PR, or should we make a separate issue?

sestinj commented 1 year ago

It's unlikely I'll get to that soon, so wouldn't want to hold up this PR. I made a new issue here.

mahmoud commented 1 year ago

Sounds good, thanks again for this!