7
7
#
8
8
# To make the location information easier to understand, we generally put each
9
9
# regexp on its own line, even though this is not idiomatic Python.
10
- # Comments indicate cases we currently do not handle correctly .
10
+ # Comments indicate the found locations relative to the call to `compile` .
11
11
12
12
# plain string
13
- re .compile (
13
+ re .compile ( # $location=1:2
14
14
'[this] is a test'
15
15
)
16
16
17
17
# raw string
18
- re .compile (
18
+ re .compile ( # $ location=1:3
19
19
r'[this] is a test'
20
20
)
21
21
22
22
# byte string
23
- re .compile (
23
+ re .compile ( # $ location=1:3
24
24
b'[this] is a test'
25
25
)
26
26
27
27
# byte raw string
28
- re .compile (
28
+ re .compile ( # $ location=1:4
29
29
br'[this] is a test'
30
30
)
31
31
32
32
# multiline string
33
- re .compile (
33
+ re .compile ( # $ location=1:4
34
34
'''[this] is a test'''
35
35
)
36
36
37
37
# multiline raw string
38
- re .compile (
38
+ re .compile ( # $ location=1:5
39
39
r'''[this] is a test'''
40
40
)
41
41
42
42
# multiline byte string
43
- re .compile (
43
+ re .compile ( # $ location=1:5
44
44
b'''[this] is a test'''
45
45
)
46
46
47
47
# multiline byte raw string
48
- re .compile (
48
+ re .compile ( # $ location=1:6
49
49
br'''[this] is a test'''
50
50
)
51
51
52
- # plain string with multiple parts (second [this] gets wrong column: 23 instead of 26)
53
- re .compile (
52
+ # plain string with multiple parts
53
+ re .compile ( # $ location=1:2 SPURIOUS:location=1:23 MISSING:location=1:26
54
54
'[this] is a test' ' and [this] is another test'
55
55
)
56
56
57
- # plain string with multiple parts across lines (second [this] gets wrong location: 59:23 instead of 60:7)
58
- re .compile (
57
+ # plain string with multiple parts across lines
58
+ re .compile ( # $ location=1:2 SPURIOUS:location=1:23 MISSING:location=2:7
59
59
'[this] is a test'
60
60
' and [this] is another test'
61
61
)
62
62
63
- # plain string with multiple parts across lines and comments (second [this] gets wrong location: 65:23 instead of 67:7)
64
- re .compile (
63
+ # plain string with multiple parts across lines and comments
64
+ re .compile ( # $ location=1:2 SPURIOUS:location=1:23 MISSING:location=3:7
65
65
'[this] is a test'
66
66
# comment
67
67
' and [this] is another test'
68
68
)
69
69
70
- # actual multiline string (both [this]s get wrong location: 72:6 and 72:27 instead of 73:1 and 74:5)
71
- re .compile (
70
+ # actual multiline string
71
+ re .compile ( # $ SPURIOUS:location=1:6 location=1:27 MISSING:location=2:1 location=3:5
72
72
r'''
73
73
[this] is a test
74
74
and [this] is another test
75
75
'''
76
76
)
77
77
78
- # plain string with escape sequences ([this] gets wrong location: 80:3 instead of 80:4)
79
- re .compile (
78
+ # plain string with escape sequences
79
+ re .compile ( # $ SPURIOUS:location=1:3 MISSING:location=1:4
80
80
'\t [this] is a test'
81
81
)
82
82
83
83
# raw string with escape sequences
84
- re .compile (
84
+ re .compile ( # $ location=1:5
85
85
r'\A[this] is a test'
86
86
)
87
87
88
- # plain string with escaped newline (second [this] gets wrong location: 90:23 instead of 91:6)
89
- re .compile (
88
+ # plain string with escaped newline
89
+ re .compile ( # $ location=1:2 SPURIOUS:location=1:23 MISSING:location=2:6
90
90
'[this] is a test\
91
91
and [this] is another test'
92
92
)
0 commit comments