Bug 440412

Summary: Broken python file syntax after the r'\\' expression
Product: [Frameworks and Libraries] frameworks-syntax-highlighting Reporter: Martin Ottmar <mirovski36>
Component: syntaxAssignee: KWrite Developers <kwrite-bugs-null>
Status: RESOLVED FIXED    
Severity: normal CC: walter.von.entferndt
Priority: NOR    
Version: 5.84.0   
Target Milestone: ---   
Platform: Arch Linux   
OS: Linux   
Latest Commit: Version Fixed In:

Description Martin Ottmar 2021-07-30 09:55:53 UTC
SUMMARY
Python file syntax highlighting (in KDevelop) is definitely broken after the line containing the r'\\' expression. It was probably broken in the last framework release.

STEPS TO REPRODUCE
1. Open KDevelop
2. Create a new file containing:
class Any:
    def AnyMethod(self):
        pat = r'\\text'
        print ('still correct here')
        pat = r'\\'
        print ('broken here')

2. Select Python syntax for this file
3. Observe the result

OBSERVED RESULT
File syntax highlight is broken after the pattern r'\\' until the end of the python file

EXPECTED RESULT
Pattern r'\\' (or possibly r"\\") shall not break the syntax highlighting

SOFTWARE/OS VERSIONS
Linux/KDE Plasma: 
KDE Plasma Version: 5.22.4
KDE Frameworks Version: 5.84.0
Qt Version: 5.15.2

ADDITIONAL INFORMATION
Comment 1 Bug Janitor Service 2021-07-30 13:26:57 UTC
A possibly relevant merge request was started @ https://invent.kde.org/frameworks/syntax-highlighting/-/merge_requests/231
Comment 2 Jan Paul Batrina 2021-07-30 20:18:34 UTC
Git commit e1c88423391c62448bea0009177228f90e20affa by Jan Paul Batrina.
Committed on 30/07/2021 at 13:25.
Pushed by cullmann into branch 'master'.

Python: Fix r"\\" and derivatives

In such cases, the last \ should not be interpreted
as a line continuation escape.

This regression was introduced by 14c8f9765843217b31c969670ebcf61b6bad446b
and made more obvious by  90f5623611491ba665f1adeebff02916a73f37d6.

New regression tests are added for most variants, e.g. rb"""\\"""

M  +4    -0    autotests/folding/test.py.fold
M  +4    -0    autotests/html/test.py.dark.html
M  +4    -0    autotests/html/test.py.html
M  +4    -0    autotests/input/test.py
M  +4    -0    autotests/reference/test.py.ref
M  +10   -1    data/syntax/python.xml

https://invent.kde.org/frameworks/syntax-highlighting/commit/e1c88423391c62448bea0009177228f90e20affa