-
Notifications
You must be signed in to change notification settings - Fork 1.7k
/
Copy pathstrings.py
88 lines (88 loc) · 1.8 KB
/
strings.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
if 1:
"double quotes"
if 2:
'single quotes'
if 3:
"""triple double quotes (sextuple quotes?)"""
if 4:
'''triple single quotes'''
if 5:
r"raw string"
if 6:
b"byte string"
if 7:
u"unicode string"
if 8:
br"raw byte string"
if 9:
"Let's put some control\tcharacters in here\n"
if 10:
"""
Multiline
string
time
"""
if 11:
"escaped \"quotes\" here"
if 12:
"""Unescaped "quotes" inside triple quotes"""
if 13:
"string" """concatenation""" 'here' '''oh yeah'''
if 14:
f"format string with no funny business"
if 15:
f"format string with {1} interpolation"
if 16:
f"{2}{3}{4}"
if 17:
f"and a format string with {'nested'} string"
if 18:
f"foo{x}bar" "regular string"
if 19:
pass
# This doesn't quite give the right result, but it's close enough.
#f"no interpolation" ' but still implicit concatenation'
if 20:
f"{9}" "blah" f'{10}'
if 21:
f"format{129}string" "not format"
if 21.1:
# regression from https://github.com/github/codeql/issues/9940
f"format{123}string" f"technically format string\n"
if 22:
"again not format" f"format again{foo}hello"
if 23:
f"""f-string with {"inner " 'implicit ' '''concatenation'''} how awful"""
if 24:
f'''oh no python { f'why do you {"allow"} such'} absolute horrors?'''
if 25:
b"""5""" b"byte format"
if 26:
r'X(\u0061|a)*Y'
if 27:
f"""triple-quoted {11}""f-st""" fr"""ri'''ng\\\\\""{12} with an inner quoted part"""
if 28:
f'{value:{width + padding!r}.{precision}}'
if 29:
f'{1,}'
if 30:
fr"""quotes before interpolation "{123}" are okay."""
if 31:
fr"""backslash before an interpolation \{456}\ are okay."""
if 32:
f''
if 33:
''
if 34:
b'\xc5\xe5'
if 35:
f"{x=}"
if 36:
r"a\"a"
if 37:
r'a\'a'
if 38:
r'a\\'
if 39:
r'a\
'