bpo-33204: IDLE: consistently color invalid string prefixes (GH-6344) · python/cpython@6130675 (original) (raw)

`@@ -21,7 +21,7 @@ def make_pat():

`

21

21

`# 1st 'file' colorized normal, 2nd as builtin, 3rd as string

`

22

22

`builtin = r"([^.'"\#]\b|^)" + any("BUILTIN", builtinlist) + r"\b"

`

23

23

`comment = any("COMMENT", [r"#[^\n]*"])

`

24

``

`-

stringprefix = r"(?i:\br|u|f|fr|rf|b|br|rb)?"

`

``

24

`+

stringprefix = r"(?i:r|u|f|fr|rf|b|br|rb)?"

`

25

25

`sqstring = stringprefix + r"'[^'\\n](\.[^'\\n])*'?"

`

26

26

`dqstring = stringprefix + r'"[^"\\n](\.[^"\\n])*"?'

`

27

27

`sq3string = stringprefix + r"'''[^'\]((\.|'(?!''))[^'\])*(''')?"

`

`@@ -265,11 +265,14 @@ def _color_delegator(parent): # htest #

`

265

265

`source = ("# Following has syntax errors\n"

`

266

266

`"if True: then int 1\nelif False: print 0\nelse: float(None)\n"

`

267

267

`"if iF + If + IF: 'keywork matching must respect case'\n"

`

268

``

`-

"# All valid prefixes for unicode and byte strings should be colored\n"

`

``

268

`+

"# All valid prefixes for unicode and byte strings should be colored.\n"

`

269

269

`"'x', '''x''', "x", """x"""\n"

`

270

``

`-

"r'x', u'x', R'x', U'x', f'x', F'x', ur'is invalid'\n"

`

``

270

`+

"r'x', u'x', R'x', U'x', f'x', F'x'\n"

`

271

271

`"fr'x', Fr'x', fR'x', FR'x', rf'x', rF'x', Rf'x', RF'x'\n"

`

272

``

`-

"b'x',B'x', br'x',Br'x',bR'x',BR'x', rb'x'.rB'x',Rb'x',RB'x'\n")

`

``

272

`+

"b'x',B'x', br'x',Br'x',bR'x',BR'x', rb'x'.rB'x',Rb'x',RB'x'\n"

`

``

273

`+

"# Invalid combinations of legal characters should be half colored.\n"

`

``

274

`+

"ur'x', ru'x', uf'x', fu'x', UR'x', ufr'x', rfu'x', xf'x', fx'x'"

`

``

275

`+

)

`

273

276

`text = Text(top, background="white")

`

274

277

`text.pack(expand=1, fill="both")

`

275

278

`text.insert("insert", source)

`