Qix- / better-exceptions

Pretty and useful exceptions in Python, automatically.
MIT License
4.59k stars 203 forks source link

fix COMMENT_REGXP #89

Closed ShineyDev closed 5 years ago

ShineyDev commented 5 years ago

i noticed a couple of bugs in the regular expression while testing.

the first bug is found when a line doesn't have a comment but has # in a string. the matcher seems to forcefully fetch the # from inside of the string. proof. to fix this i have made the comment optional.

the second bug was introduced because a " was put where a ' should have been. this causes a ' delimited string containing a " to be matched incorrectly. proof. to fix this i have replaced the " with \'

Qix- commented 5 years ago

The " -> \' is a very good catch, thank you.

I question the ? added to the end of the regex - the point of the regex is only to match comments. This will now match all lines. Is this intended?

ShineyDev commented 5 years ago

as far as i'm aware this regex is the only thing that determines whether a line contains a comment. if this is correct, and a # is found in the line as anything other than a comment, then this will still be matched as a comment.

if this is intended behavior then i can edit the patch to exclude the optional comment.

Qix- commented 5 years ago

@ShineyDev No it's used to color the comment when doing the syntax highlighting, so it should only match if the comment exists.

ShineyDev commented 5 years ago

alright, i've removed the optional comment, is there anything else you'd like me to change?

Qix- commented 5 years ago

Nope, this is a great catch :) Thanks for the PR!