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

Complicated regex somehow breaks shed --refactor #92

Closed
DRMacIver opened this issue Apr 28, 2023 · 1 comment
Closed

Complicated regex somehow breaks shed --refactor #92

DRMacIver opened this issue Apr 28, 2023 · 1 comment

Comments

@DRMacIver
Copy link
Contributor

Haven't looked into what's going on beyond to minimize the bug, but the following code:

import re

def tokenize_csv(csv_string: str, delimiter: str = ",", quote_char: str = '"') -> list:
    token_strings = re.split(fr"\{delimiter}(?=(?:(?:\{quote_char})*[^\\{quote_char}]))?", csv_string)
    tokens = [re.sub(fr"{quote_char}(?=(?:(?:\{quote_char})*[^\\{quote_char}]))|\\", "", token) for token in token_strings]
    return tokens

Results in the following error:

Internal error formatting 'shedbug.py': ParserSyntaxError: Syntax Error @ 1:1.
tokenizer error: unterminated string literal

import re
^
    Please report this to https://github.com/Zac-HD/shed/issues
@Zac-HD
Copy link
Owner

Zac-HD commented Apr 28, 2023

Reproduced with libcst andrf"\\", so moved upstream to Instagram/LibCST#917.

For local mitigation let's handle this as suggested in #93; we can have shed explicitly check if it's a libcst bug and report that if so.

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

No branches or pull requests

2 participants