string prefixes: don't normalise capital R-strings (#1271)

Resolves #1244

Co-authored-by: Łukasz Langa <lukasz@langa.pl>
This commit is contained in:
Shantanu 2020-03-03 05:55:14 -08:00 committed by GitHub
parent bbe5ae70c1
commit 6d8b90167b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 2 deletions

View File

@ -2842,7 +2842,7 @@ def normalize_string_prefix(leaf: Leaf, remove_u_prefix: bool = False) -> None:
match = re.match(r"^([furbFURB]*)(.*)$", leaf.value, re.DOTALL) match = re.match(r"^([furbFURB]*)(.*)$", leaf.value, re.DOTALL)
assert match is not None, f"failed to match string {leaf.value!r}" assert match is not None, f"failed to match string {leaf.value!r}"
orig_prefix = match.group(1) orig_prefix = match.group(1)
new_prefix = orig_prefix.lower() new_prefix = orig_prefix.replace("F", "f").replace("B", "b").replace("U", "u")
if remove_u_prefix: if remove_u_prefix:
new_prefix = new_prefix.replace("u", "") new_prefix = new_prefix.replace("u", "")
leaf.value = f"{new_prefix}{match.group(2)}" leaf.value = f"{new_prefix}{match.group(2)}"

View File

@ -3,12 +3,16 @@
name = R"Łukasz" name = R"Łukasz"
F"hello {name}" F"hello {name}"
B"hello" B"hello"
r"hello"
fR"hello"
# output # output
#!/usr/bin/env python3.6 #!/usr/bin/env python3.6
name = r"Łukasz" name = R"Łukasz"
f"hello {name}" f"hello {name}"
b"hello" b"hello"
r"hello"
fR"hello"