Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix extracting references from regex match #37

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

ikey8k
Copy link

@ikey8k ikey8k commented Nov 3, 2022

The regex uses separate capture groups for alternative expressions that match a single-quoted or a double-quoted string. This is more robust with strings that may contain quotes.

However the code using the match objects doesn't currently take the two capture groups into account and always expects the results in group 1, which only matches double-quoted strings.

This change introduces a check so that if group 1 is None, the function will use the matched substring in group 2.

Closes #36

The regex uses separate capture groups for alternative expressions that
match a single-quoted or a double-quoted string. This is more robust
with strings that may contain quotes.

However the code using the match objects doesn't currently take the two
capture groups into account and always expects the results in group 1,
which only matches double-quoted strings.

This change introduces a check so that if group 1 is None, the function
will use the matched substring in group 2.

Closes arthepsy#36
@jcrowthe
Copy link

I ran across #36 while updating as well, and this PR fixes it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

TypeError: cannot convert <class 'NoneType'> to bytes
2 participants