Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
7d16cb4d
Commit
7d16cb4d
authored
Jul 11, 1997
by
Guido van Rossum
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Jeffrey's latest.
parent
dbf139fc
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
153 additions
and
172 deletions
+153
-172
Lib/re.py
Lib/re.py
+71
-50
Lib/test/output/test_re
Lib/test/output/test_re
+82
-122
No files found.
Lib/re.py
View file @
7d16cb4d
...
@@ -51,13 +51,13 @@ def search(pattern, string, flags=0):
...
@@ -51,13 +51,13 @@ def search(pattern, string, flags=0):
return
compile
(
pattern
,
flags
).
search
(
string
)
return
compile
(
pattern
,
flags
).
search
(
string
)
def
sub
(
pattern
,
repl
,
string
,
count
=
0
):
def
sub
(
pattern
,
repl
,
string
,
count
=
0
):
pass
return
compile
(
pattern
).
sub
(
repl
,
string
,
count
)
def
subn
(
pattern
,
repl
,
string
,
count
=
0
):
def
subn
(
pattern
,
repl
,
string
,
count
=
0
):
pass
return
compile
(
pattern
).
subn
(
repl
,
string
,
count
)
def
split
(
string
,
pattern
,
maxsplit
=
0
):
def
split
(
pattern
,
string
,
maxsplit
=
0
):
pass
return
compile
(
pattern
).
subn
(
string
,
maxsplit
)
#
#
#
#
...
@@ -79,21 +79,6 @@ class RegexObject:
...
@@ -79,21 +79,6 @@ class RegexObject:
else
:
else
:
self
.
anchor
=
0
self
.
anchor
=
0
self
.
buffer
=
assemble
(
code
)
self
.
buffer
=
assemble
(
code
)
def
match
(
self
,
string
,
pos
=
0
):
regs
=
reop
.
match
(
self
.
buffer
,
self
.
num_regs
,
self
.
flags
,
self
.
fastmap
.
can_be_null
,
self
.
fastmap
.
fastmap
(),
self
.
anchor
,
string
,
pos
)
if
regs
is
None
:
return
None
return
MatchObject
(
self
,
string
,
pos
,
regs
)
def
search
(
self
,
string
,
pos
=
0
):
def
search
(
self
,
string
,
pos
=
0
):
regs
=
reop
.
search
(
self
.
buffer
,
regs
=
reop
.
search
(
self
.
buffer
,
self
.
num_regs
,
self
.
num_regs
,
...
@@ -109,6 +94,27 @@ class RegexObject:
...
@@ -109,6 +94,27 @@ class RegexObject:
string
,
string
,
pos
,
pos
,
regs
)
regs
)
def
match
(
self
,
string
,
pos
=
0
):
regs
=
reop
.
match
(
self
.
buffer
,
self
.
num_regs
,
self
.
flags
,
self
.
fastmap
.
can_be_null
,
self
.
fastmap
.
fastmap
(),
self
.
anchor
,
string
,
pos
)
if
regs
is
None
:
return
None
return
MatchObject
(
self
,
string
,
pos
,
regs
)
def
sub
(
self
,
repl
,
string
,
count
=
0
):
pass
def
subn
(
self
,
repl
,
string
,
count
=
0
):
pass
def
split
(
self
,
string
,
maxsplit
=
0
):
pass
class
MatchObject
:
class
MatchObject
:
def
__init__
(
self
,
re
,
string
,
pos
,
regs
):
def
__init__
(
self
,
re
,
string
,
pos
,
regs
):
...
@@ -116,34 +122,49 @@ class MatchObject:
...
@@ -116,34 +122,49 @@ class MatchObject:
self
.
string
=
string
self
.
string
=
string
self
.
pos
=
pos
self
.
pos
=
pos
self
.
regs
=
regs
self
.
regs
=
regs
def
start
(
self
,
i
):
def
start
(
self
,
g
):
if
type
(
i
)
==
type
(
''
):
if
type
(
g
)
==
type
(
''
):
try
:
try
:
i
=
self
.
re
.
groupindex
[
i
]
g
=
self
.
re
.
groupindex
[
g
]
except
(
KeyError
,
TypeError
):
except
(
KeyError
,
TypeError
):
raise
IndexError
raise
IndexError
,
(
'group "'
+
g
+
'" is undefined'
)
return
self
.
regs
[
i
][
0
]
return
self
.
regs
[
g
][
0
]
def
end
(
self
,
i
):
def
end
(
self
,
g
):
if
type
(
i
)
==
type
(
''
):
if
type
(
g
)
==
type
(
''
):
try
:
try
:
i
=
self
.
re
.
groupindex
[
i
]
g
=
self
.
re
.
groupindex
[
g
]
except
(
KeyError
,
TypeError
):
except
(
KeyError
,
TypeError
):
raise
IndexError
raise
IndexError
,
(
'group "'
+
g
+
'" is undefined'
)
return
self
.
regs
[
i
][
1
]
return
self
.
regs
[
g
][
1
]
def
span
(
self
,
i
):
def
span
(
self
,
g
):
if
type
(
i
)
==
type
(
''
):
if
type
(
g
)
==
type
(
''
):
try
:
try
:
i
=
self
.
re
.
groupindex
[
i
]
g
=
self
.
re
.
groupindex
[
g
]
except
(
KeyError
,
TypeError
):
except
(
KeyError
,
TypeError
):
raise
IndexError
raise
IndexError
,
(
'group "'
+
g
+
'" is undefined'
)
return
self
.
regs
[
i
]
return
self
.
regs
[
g
]
def
group
(
self
,
i
):
def
group
(
self
,
*
groups
):
if
type
(
i
)
==
type
(
''
):
if
len
(
groups
)
==
0
:
try
:
groups
=
range
(
1
,
self
.
re
.
num_regs
)
i
=
self
.
re
.
groupindex
[
i
]
result
=
[]
except
(
KeyError
,
TypeError
):
for
g
in
groups
:
raise
IndexError
if
type
(
g
)
==
type
(
''
):
return
self
.
string
[
self
.
regs
[
i
][
0
]:
self
.
regs
[
i
][
1
]]
try
:
g
=
self
.
re
.
groupindex
[
g
]
except
(
KeyError
,
TypeError
):
raise
IndexError
,
(
'group "'
+
g
+
'" is undefined'
)
if
g
>=
len
(
self
.
regs
):
result
.
append
(
None
)
elif
(
self
.
regs
[
g
][
0
]
==
-
1
)
or
(
self
.
regs
[
g
][
1
]
==
-
1
):
result
.
append
(
None
)
else
:
result
.
append
(
self
.
string
[
self
.
regs
[
g
][
0
]:
self
.
regs
[
g
][
1
]])
if
len
(
result
)
>
1
:
return
tuple
(
result
)
elif
len
(
result
)
==
1
:
return
result
[
0
]
else
:
return
()
#
#
# A set of classes to make assembly a bit easier, if a bit verbose.
# A set of classes to make assembly a bit easier, if a bit verbose.
...
@@ -331,7 +352,7 @@ class SyntaxSpec(Instruction):
...
@@ -331,7 +352,7 @@ class SyntaxSpec(Instruction):
def
assemble
(
self
,
postition
,
labels
):
def
assemble
(
self
,
postition
,
labels
):
return
self
.
opcode
+
chr
(
self
.
syntax
)
return
self
.
opcode
+
chr
(
self
.
syntax
)
class
SyntaxSpec
(
Instruction
):
class
Not
SyntaxSpec
(
Instruction
):
name
=
'notsyntaxspec'
name
=
'notsyntaxspec'
def
__init__
(
self
,
syntax
):
def
__init__
(
self
,
syntax
):
self
.
syntax
=
syntax
self
.
syntax
=
syntax
...
@@ -382,13 +403,12 @@ def assemble(instructions):
...
@@ -382,13 +403,12 @@ def assemble(instructions):
#
#
def
escape
(
pattern
):
def
escape
(
pattern
):
result
=
''
result
=
[]
for
char
in
pattern
:
for
char
in
pattern
:
if
'word'
not
in
syntax_table
[
char
]:
if
'word'
not
in
syntax_table
[
char
]:
result
=
result
+
'
\
\
'
+
char
result
.
append
(
'
\
\
'
)
else
:
result
.
append
(
char
)
result
=
result
+
char
return
string
.
join
(
result
,
''
)
return
result
#
#
#
#
...
@@ -631,7 +651,7 @@ def compile(pattern, flags=0):
...
@@ -631,7 +651,7 @@ def compile(pattern, flags=0):
expr
+
\
expr
+
\
[
Jump
(
-
1
),
[
Jump
(
-
1
),
Label
(
label
)])
Label
(
label
)])
stack
.
append
([
(
'|'
,
)])
stack
.
append
([
Alternation
(
)])
label
=
label
+
1
label
=
label
+
1
elif
char
==
'('
:
elif
char
==
'('
:
...
@@ -693,12 +713,13 @@ def compile(pattern, flags=0):
...
@@ -693,12 +713,13 @@ def compile(pattern, flags=0):
stack
.
append
([
FunctionCallout
(
name
)])
stack
.
append
([
FunctionCallout
(
name
)])
else
:
else
:
raise
error
,
'unknown Python extension'
raise
error
,
(
'unknown Python extension: '
+
\
pattern
[
index
])
elif
pattern
[
index
]
==
':'
:
elif
pattern
[
index
]
==
':'
:
# grouping, but no registers
# grouping, but no registers
index
=
index
+
1
index
=
index
+
1
stack
.
append
([
(
'('
,
-
1
)])
stack
.
append
([
OpenParen
(
-
1
)])
elif
pattern
[
index
]
==
'#'
:
elif
pattern
[
index
]
==
'#'
:
# comment
# comment
...
...
Lib/test/output/test_re
View file @
7d16cb4d
...
@@ -40,7 +40,7 @@ test_re
...
@@ -40,7 +40,7 @@ test_re
Traceback (innermost last):
Traceback (innermost last):
File "../Lib/test/test_re.py", line 19, in ?
File "../Lib/test/test_re.py", line 19, in ?
obj=re.compile(pattern)
obj=re.compile(pattern)
File "../Lib/re.py", line 10
78
, in compile
File "../Lib/re.py", line 10
99
, in compile
if pattern[index] != ']':
if pattern[index] != ']':
IndexError: string index out of range
IndexError: string index out of range
('a[', '-', 2)
('a[', '-', 2)
...
@@ -65,21 +65,7 @@ IndexError: string index out of range
...
@@ -65,21 +65,7 @@ IndexError: string index out of range
('\\by\\b', 'yz', 1)
('\\by\\b', 'yz', 1)
('\\by\\b', 'xyz', 1)
('\\by\\b', 'xyz', 1)
('ab|cd', 'abc', 0, 'found', 'ab')
('ab|cd', 'abc', 0, 'found', 'ab')
*** Unexpected error ***
Traceback (innermost last):
File "../Lib/test/test_re.py", line 19, in ?
obj=re.compile(pattern)
File "../Lib/re.py", line 1097, in compile
if stack[-1][0].name == '(':
AttributeError: attribute-less object
('ab|cd', 'abcd', 0, 'found', 'ab')
('ab|cd', 'abcd', 0, 'found', 'ab')
*** Unexpected error ***
Traceback (innermost last):
File "../Lib/test/test_re.py", line 19, in ?
obj=re.compile(pattern)
File "../Lib/re.py", line 1097, in compile
if stack[-1][0].name == '(':
AttributeError: attribute-less object
('()ef', 'def', 0, 'found+"-"+g1', 'ef-')
('()ef', 'def', 0, 'found+"-"+g1', 'ef-')
=== Syntax error: ('()ef', 'def', 0, 'found+"-"+g1', 'ef-')
=== Syntax error: ('()ef', 'def', 0, 'found+"-"+g1', 'ef-')
('$b', 'b', 1)
('$b', 'b', 1)
...
@@ -91,54 +77,47 @@ AttributeError: attribute-less object
...
@@ -91,54 +77,47 @@ AttributeError: attribute-less object
('a\\\\b', 'a\\b', 0, 'found', 'a\\b')
('a\\\\b', 'a\\b', 0, 'found', 'a\\b')
=== Failed incorrectly ('a\\\\b', 'a\\b', 0, 'found', 'a\\b')
=== Failed incorrectly ('a\\\\b', 'a\\b', 0, 'found', 'a\\b')
('((a))', 'abc', 0, 'found+"-"+g1+"-"+g2', 'a-a-a')
('((a))', 'abc', 0, 'found+"-"+g1+"-"+g2', 'a-a-a')
=== grouping error ('((a))', 'abc', 0, 'found+"-"+g1+"-"+g2', 'a-a-a') 'a-
-
' should be 'a-a-a'
=== grouping error ('((a))', 'abc', 0, 'found+"-"+g1+"-"+g2', 'a-a-a') 'a-
None-None
' should be 'a-a-a'
('(a)b(c)', 'abc', 0, 'found+"-"+g1+"-"+g2', 'abc-a-c')
('(a)b(c)', 'abc', 0, 'found+"-"+g1+"-"+g2', 'abc-a-c')
=== grouping error ('(a)b(c)', 'abc', 0, 'found+"-"+g1+"-"+g2', 'abc-a-c') 'abc-
-
' should be 'abc-a-c'
=== grouping error ('(a)b(c)', 'abc', 0, 'found+"-"+g1+"-"+g2', 'abc-a-c') 'abc-
None-None
' should be 'abc-a-c'
('a+b+c', 'aabbabc', 0, 'found', 'abc')
('a+b+c', 'aabbabc', 0, 'found', 'abc')
('(a+|b)*', 'ab', 0, 'found+"-"+g1', 'ab-b')
('(a+|b)*', 'ab', 0, 'found+"-"+g1', 'ab-b')
*** Unexpected error ***
*** Unexpected error ***
Traceback (innermost last):
Traceback (innermost last):
File "../Lib/test/test_re.py", line 19, in ?
File "../Lib/test/test_re.py", line 19, in ?
obj=re.compile(pattern)
obj=re.compile(pattern)
File "../Lib/re.py", line 7
45
, in compile
File "../Lib/re.py", line 7
86
, in compile
while (len(stack) > 0) and (stack[-1][0].name != '('):
expr[i] = JumpOpcode(label)
AttributeError: attribute-less object
NameError: JumpOpcode
('(a+|b)+', 'ab', 0, 'found+"-"+g1', 'ab-b')
('(a+|b)+', 'ab', 0, 'found+"-"+g1', 'ab-b')
*** Unexpected error ***
*** Unexpected error ***
Traceback (innermost last):
Traceback (innermost last):
File "../Lib/test/test_re.py", line 19, in ?
File "../Lib/test/test_re.py", line 19, in ?
obj=re.compile(pattern)
obj=re.compile(pattern)
File "../Lib/re.py", line 7
45
, in compile
File "../Lib/re.py", line 7
86
, in compile
while (len(stack) > 0) and (stack[-1][0].name != '('):
expr[i] = JumpOpcode(label)
AttributeError: attribute-less object
NameError: JumpOpcode
('(a+|b)?', 'ab', 0, 'found+"-"+g1', 'a-a')
('(a+|b)?', 'ab', 0, 'found+"-"+g1', 'a-a')
*** Unexpected error ***
*** Unexpected error ***
Traceback (innermost last):
Traceback (innermost last):
File "../Lib/test/test_re.py", line 19, in ?
File "../Lib/test/test_re.py", line 19, in ?
obj=re.compile(pattern)
obj=re.compile(pattern)
File "../Lib/re.py", line 7
45
, in compile
File "../Lib/re.py", line 7
86
, in compile
while (len(stack) > 0) and (stack[-1][0].name != '('):
expr[i] = JumpOpcode(label)
AttributeError: attribute-less object
NameError: JumpOpcode
(')(', '-', 2)
(')(', '-', 2)
('[^ab]*', 'cde', 0, 'found', 'cde')
('[^ab]*', 'cde', 0, 'found', 'cde')
('abc', '', 1)
('abc', '', 1)
('a*', '', 0, 'found', '')
('a*', '', 0, 'found', '')
('a|b|c|d|e', 'e', 0, 'found', 'e')
('a|b|c|d|e', 'e', 0, 'found', 'e')
*** Unexpected error ***
Traceback (innermost last):
File "../Lib/test/test_re.py", line 19, in ?
obj=re.compile(pattern)
File "../Lib/re.py", line 625, in compile
while (len(stack) != 0) and \
AttributeError: attribute-less object
('(a|b|c|d|e)f', 'ef', 0, 'found+"-"+g1', 'ef-e')
('(a|b|c|d|e)f', 'ef', 0, 'found+"-"+g1', 'ef-e')
*** Unexpected error ***
*** Unexpected error ***
Traceback (innermost last):
Traceback (innermost last):
File "../Lib/test/test_re.py", line 19, in ?
File "../Lib/test/test_re.py", line 19, in ?
obj=re.compile(pattern)
obj=re.compile(pattern)
File "../Lib/re.py", line
625
, in compile
File "../Lib/re.py", line
786
, in compile
while (len(stack) != 0) and \
expr[i] = JumpOpcode(label)
AttributeError: attribute-less object
NameError: JumpOpcode
('abcd*efg', 'abcdefg', 0, 'found', 'abcdefg')
('abcd*efg', 'abcdefg', 0, 'found', 'abcdefg')
('ab*', 'xabyabbbz', 0, 'found', 'ab')
('ab*', 'xabyabbbz', 0, 'found', 'ab')
('ab*', 'xayabbbz', 0, 'found', 'a')
('ab*', 'xayabbbz', 0, 'found', 'a')
...
@@ -147,50 +126,44 @@ AttributeError: attribute-less object
...
@@ -147,50 +126,44 @@ AttributeError: attribute-less object
Traceback (innermost last):
Traceback (innermost last):
File "../Lib/test/test_re.py", line 19, in ?
File "../Lib/test/test_re.py", line 19, in ?
obj=re.compile(pattern)
obj=re.compile(pattern)
File "../Lib/re.py", line 7
45
, in compile
File "../Lib/re.py", line 7
86
, in compile
while (len(stack) > 0) and (stack[-1][0].name != '('):
expr[i] = JumpOpcode(label)
AttributeError: attribute-less object
NameError: JumpOpcode
('[abhgefdc]ij', 'hij', 0, 'found', 'hij')
('[abhgefdc]ij', 'hij', 0, 'found', 'hij')
('^(ab|cd)e', 'abcde', 1, 'xg1y', 'xy')
('^(ab|cd)e', 'abcde', 1, 'xg1y', 'xy')
*** Unexpected error ***
*** Unexpected error ***
Traceback (innermost last):
Traceback (innermost last):
File "../Lib/test/test_re.py", line 19, in ?
File "../Lib/test/test_re.py", line 19, in ?
obj=re.compile(pattern)
obj=re.compile(pattern)
File "../Lib/re.py", line 7
45
, in compile
File "../Lib/re.py", line 7
86
, in compile
while (len(stack) > 0) and (stack[-1][0].name != '('):
expr[i] = JumpOpcode(label)
AttributeError: attribute-less object
NameError: JumpOpcode
('(abc|)ef', 'abcdef', 0, 'found+"-"+g1', 'ef-')
('(abc|)ef', 'abcdef', 0, 'found+"-"+g1', 'ef-')
*** Unexpected error ***
=== Syntax error: ('(abc|)ef', 'abcdef', 0, 'found+"-"+g1', 'ef-')
Traceback (innermost last):
File "../Lib/test/test_re.py", line 19, in ?
obj=re.compile(pattern)
File "../Lib/re.py", line 745, in compile
while (len(stack) > 0) and (stack[-1][0].name != '('):
AttributeError: attribute-less object
('(a|b)c*d', 'abcd', 0, 'found+"-"+g1', 'bcd-b')
('(a|b)c*d', 'abcd', 0, 'found+"-"+g1', 'bcd-b')
*** Unexpected error ***
*** Unexpected error ***
Traceback (innermost last):
Traceback (innermost last):
File "../Lib/test/test_re.py", line 19, in ?
File "../Lib/test/test_re.py", line 19, in ?
obj=re.compile(pattern)
obj=re.compile(pattern)
File "../Lib/re.py", line 7
45
, in compile
File "../Lib/re.py", line 7
86
, in compile
while (len(stack) > 0) and (stack[-1][0].name != '('):
expr[i] = JumpOpcode(label)
AttributeError: attribute-less object
NameError: JumpOpcode
('(ab|ab*)bc', 'abc', 0, 'found+"-"+g1', 'abc-a')
('(ab|ab*)bc', 'abc', 0, 'found+"-"+g1', 'abc-a')
*** Unexpected error ***
*** Unexpected error ***
Traceback (innermost last):
Traceback (innermost last):
File "../Lib/test/test_re.py", line 19, in ?
File "../Lib/test/test_re.py", line 19, in ?
obj=re.compile(pattern)
obj=re.compile(pattern)
File "../Lib/re.py", line 7
45
, in compile
File "../Lib/re.py", line 7
86
, in compile
while (len(stack) > 0) and (stack[-1][0].name != '('):
expr[i] = JumpOpcode(label)
AttributeError: attribute-less object
NameError: JumpOpcode
('a([bc]*)c*', 'abc', 0, 'found+"-"+g1', 'abc-bc')
('a([bc]*)c*', 'abc', 0, 'found+"-"+g1', 'abc-bc')
=== grouping error ('a([bc]*)c*', 'abc', 0, 'found+"-"+g1', 'abc-bc') 'abc-' should be 'abc-bc'
=== grouping error ('a([bc]*)c*', 'abc', 0, 'found+"-"+g1', 'abc-bc') 'abc-
None
' should be 'abc-bc'
('a([bc]*)(c*d)', 'abcd', 0, 'found+"-"+g1+"-"+g2', 'abcd-bc-d')
('a([bc]*)(c*d)', 'abcd', 0, 'found+"-"+g1+"-"+g2', 'abcd-bc-d')
=== grouping error ('a([bc]*)(c*d)', 'abcd', 0, 'found+"-"+g1+"-"+g2', 'abcd-bc-d') 'abcd-
-
' should be 'abcd-bc-d'
=== grouping error ('a([bc]*)(c*d)', 'abcd', 0, 'found+"-"+g1+"-"+g2', 'abcd-bc-d') 'abcd-
None-None
' should be 'abcd-bc-d'
('a([bc]+)(c*d)', 'abcd', 0, 'found+"-"+g1+"-"+g2', 'abcd-bc-d')
('a([bc]+)(c*d)', 'abcd', 0, 'found+"-"+g1+"-"+g2', 'abcd-bc-d')
=== grouping error ('a([bc]+)(c*d)', 'abcd', 0, 'found+"-"+g1+"-"+g2', 'abcd-bc-d') 'abcd-
-
' should be 'abcd-bc-d'
=== grouping error ('a([bc]+)(c*d)', 'abcd', 0, 'found+"-"+g1+"-"+g2', 'abcd-bc-d') 'abcd-
None-None
' should be 'abcd-bc-d'
('a([bc]*)(c+d)', 'abcd', 0, 'found+"-"+g1+"-"+g2', 'abcd-b-cd')
('a([bc]*)(c+d)', 'abcd', 0, 'found+"-"+g1+"-"+g2', 'abcd-b-cd')
=== grouping error ('a([bc]*)(c+d)', 'abcd', 0, 'found+"-"+g1+"-"+g2', 'abcd-b-cd') 'abcd-
-
' should be 'abcd-b-cd'
=== grouping error ('a([bc]*)(c+d)', 'abcd', 0, 'found+"-"+g1+"-"+g2', 'abcd-b-cd') 'abcd-
None-None
' should be 'abcd-b-cd'
('a[bcd]*dcdcde', 'adcdcde', 0, 'found', 'adcdcde')
('a[bcd]*dcdcde', 'adcdcde', 0, 'found', 'adcdcde')
('a[bcd]+dcdcde', 'adcdcde', 1)
('a[bcd]+dcdcde', 'adcdcde', 1)
('(ab|a)b*c', 'abc', 0, 'found+"-"+g1', 'abc-ab')
('(ab|a)b*c', 'abc', 0, 'found+"-"+g1', 'abc-ab')
...
@@ -198,142 +171,129 @@ AttributeError: attribute-less object
...
@@ -198,142 +171,129 @@ AttributeError: attribute-less object
Traceback (innermost last):
Traceback (innermost last):
File "../Lib/test/test_re.py", line 19, in ?
File "../Lib/test/test_re.py", line 19, in ?
obj=re.compile(pattern)
obj=re.compile(pattern)
File "../Lib/re.py", line 7
45
, in compile
File "../Lib/re.py", line 7
86
, in compile
while (len(stack) > 0) and (stack[-1][0].name != '('):
expr[i] = JumpOpcode(label)
AttributeError: attribute-less object
NameError: JumpOpcode
('((a)(b)c)(d)', 'abcd', 0, 'g1+"-"+g2+"-"+g3+"-"+g4', 'abc-a-b-d')
('((a)(b)c)(d)', 'abcd', 0, 'g1+"-"+g2+"-"+g3+"-"+g4', 'abc-a-b-d')
=== grouping error ('((a)(b)c)(d)', 'abcd', 0, 'g1+"-"+g2+"-"+g3+"-"+g4', 'abc-a-b-d') '
---
' should be 'abc-a-b-d'
=== grouping error ('((a)(b)c)(d)', 'abcd', 0, 'g1+"-"+g2+"-"+g3+"-"+g4', 'abc-a-b-d') '
None-None-None-None
' should be 'abc-a-b-d'
('[a-zA-Z_][a-zA-Z0-9_]*', 'alpha', 0, 'found', 'alpha')
('[a-zA-Z_][a-zA-Z0-9_]*', 'alpha', 0, 'found', 'alpha')
('^a(bc+|b[eh])g|.h$', 'abh', 0, 'found+"-"+g1', 'bh-None')
('^a(bc+|b[eh])g|.h$', 'abh', 0, 'found+"-"+g1', 'bh-None')
*** Unexpected error ***
*** Unexpected error ***
Traceback (innermost last):
Traceback (innermost last):
File "../Lib/test/test_re.py", line 19, in ?
File "../Lib/test/test_re.py", line 19, in ?
obj=re.compile(pattern)
obj=re.compile(pattern)
File "../Lib/re.py", line 7
45
, in compile
File "../Lib/re.py", line 7
86
, in compile
while (len(stack) > 0) and (stack[-1][0].name != '('):
expr[i] = JumpOpcode(label)
AttributeError: attribute-less object
NameError: JumpOpcode
('(bc+d$|ef*g.|h?i(j|k))', 'effgz', 0, 'found+"-"+g1+"-"+g2', 'effgz-effgz-None')
('(bc+d$|ef*g.|h?i(j|k))', 'effgz', 0, 'found+"-"+g1+"-"+g2', 'effgz-effgz-None')
*** Unexpected error ***
*** Unexpected error ***
Traceback (innermost last):
Traceback (innermost last):
File "../Lib/test/test_re.py", line 19, in ?
File "../Lib/test/test_re.py", line 19, in ?
obj=re.compile(pattern)
obj=re.compile(pattern)
File "../Lib/re.py", line
625
, in compile
File "../Lib/re.py", line
786
, in compile
while (len(stack) != 0) and \
expr[i] = JumpOpcode(label)
AttributeError: attribute-less object
NameError: JumpOpcode
('(bc+d$|ef*g.|h?i(j|k))', 'ij', 0, 'found+"-"+g1+"-"+g2', 'ij-ij-j')
('(bc+d$|ef*g.|h?i(j|k))', 'ij', 0, 'found+"-"+g1+"-"+g2', 'ij-ij-j')
*** Unexpected error ***
*** Unexpected error ***
Traceback (innermost last):
Traceback (innermost last):
File "../Lib/test/test_re.py", line 19, in ?
File "../Lib/test/test_re.py", line 19, in ?
obj=re.compile(pattern)
obj=re.compile(pattern)
File "../Lib/re.py", line
625
, in compile
File "../Lib/re.py", line
786
, in compile
while (len(stack) != 0) and \
expr[i] = JumpOpcode(label)
AttributeError: attribute-less object
NameError: JumpOpcode
('(bc+d$|ef*g.|h?i(j|k))', 'effg', 1)
('(bc+d$|ef*g.|h?i(j|k))', 'effg', 1)
*** Unexpected error ***
*** Unexpected error ***
Traceback (innermost last):
Traceback (innermost last):
File "../Lib/test/test_re.py", line 19, in ?
File "../Lib/test/test_re.py", line 19, in ?
obj=re.compile(pattern)
obj=re.compile(pattern)
File "../Lib/re.py", line
625
, in compile
File "../Lib/re.py", line
786
, in compile
while (len(stack) != 0) and \
expr[i] = JumpOpcode(label)
AttributeError: attribute-less object
NameError: JumpOpcode
('(bc+d$|ef*g.|h?i(j|k))', 'bcdd', 1)
('(bc+d$|ef*g.|h?i(j|k))', 'bcdd', 1)
*** Unexpected error ***
*** Unexpected error ***
Traceback (innermost last):
Traceback (innermost last):
File "../Lib/test/test_re.py", line 19, in ?
File "../Lib/test/test_re.py", line 19, in ?
obj=re.compile(pattern)
obj=re.compile(pattern)
File "../Lib/re.py", line
625
, in compile
File "../Lib/re.py", line
786
, in compile
while (len(stack) != 0) and \
expr[i] = JumpOpcode(label)
AttributeError: attribute-less object
NameError: JumpOpcode
('(bc+d$|ef*g.|h?i(j|k))', 'reffgz', 0, 'found+"-"+g1+"-"+g2', 'effgz-effgz-None')
('(bc+d$|ef*g.|h?i(j|k))', 'reffgz', 0, 'found+"-"+g1+"-"+g2', 'effgz-effgz-None')
*** Unexpected error ***
*** Unexpected error ***
Traceback (innermost last):
Traceback (innermost last):
File "../Lib/test/test_re.py", line 19, in ?
File "../Lib/test/test_re.py", line 19, in ?
obj=re.compile(pattern)
obj=re.compile(pattern)
File "../Lib/re.py", line
625
, in compile
File "../Lib/re.py", line
786
, in compile
while (len(stack) != 0) and \
expr[i] = JumpOpcode(label)
AttributeError: attribute-less object
NameError: JumpOpcode
('(((((((((a)))))))))', 'a', 0, 'found', 'a')
('(((((((((a)))))))))', 'a', 0, 'found', 'a')
('multiple words of text', 'uh-uh', 1)
('multiple words of text', 'uh-uh', 1)
('multiple words', 'multiple words, yeah', 0, 'found', 'multiple words')
('multiple words', 'multiple words, yeah', 0, 'found', 'multiple words')
=== Failed incorrectly ('multiple words', 'multiple words, yeah', 0, 'found', 'multiple words')
=== Failed incorrectly ('multiple words', 'multiple words, yeah', 0, 'found', 'multiple words')
('(.*)c(.*)', 'abcde', 0, 'found+"-"+g1+"-"+g2', 'abcde-ab-de')
('(.*)c(.*)', 'abcde', 0, 'found+"-"+g1+"-"+g2', 'abcde-ab-de')
=== grouping error ('(.*)c(.*)', 'abcde', 0, 'found+"-"+g1+"-"+g2', 'abcde-ab-de') 'abcde-
-
' should be 'abcde-ab-de'
=== grouping error ('(.*)c(.*)', 'abcde', 0, 'found+"-"+g1+"-"+g2', 'abcde-ab-de') 'abcde-
None-None
' should be 'abcde-ab-de'
('((.*), (.*))', '(a, b)', 0, 'g2+"-"+g1', 'b-a')
('((.*), (.*))', '(a, b)', 0, 'g2+"-"+g1', 'b-a')
=== grouping error ('((.*), (.*))', '(a, b)', 0, 'g2+"-"+g1', 'b-a') '
-
' should be 'b-a'
=== grouping error ('((.*), (.*))', '(a, b)', 0, 'g2+"-"+g1', 'b-a') '
None-None
' should be 'b-a'
('[k]', 'ab', 1)
('[k]', 'ab', 1)
('a[-]?c', 'ac', 0, 'found', 'ac')
('a[-]?c', 'ac', 0, 'found', 'ac')
('(abc)\\1', 'abcabc', 0, 'g1', 'abc')
('(abc)\\1', 'abcabc', 0, 'g1', 'abc')
=== grouping error ('(abc)\\1', 'abcabc', 0, 'g1', 'abc') '' should be 'abc'
=== grouping error ('(abc)\\1', 'abcabc', 0, 'g1', 'abc') '
None
' should be 'abc'
('([a-c]*)\\1', 'abcabc', 0, 'g1', 'abc')
('([a-c]*)\\1', 'abcabc', 0, 'g1', 'abc')
=== grouping error ('([a-c]*)\\1', 'abcabc', 0, 'g1', 'abc') '' should be 'abc'
=== grouping error ('([a-c]*)\\1', 'abcabc', 0, 'g1', 'abc') '
None
' should be 'abc'
('^(.+)?B', 'AB', 0, 'g1', 'A')
('^(.+)?B', 'AB', 0, 'g1', 'A')
=== grouping error ('^(.+)?B', 'AB', 0, 'g1', 'A') '' should be 'A'
=== grouping error ('^(.+)?B', 'AB', 0, 'g1', 'A') '
None
' should be 'A'
('(a+).\\1$', 'aaaaa', 0, 'found+"-"+g1', 'aaaaa-aa')
('(a+).\\1$', 'aaaaa', 0, 'found+"-"+g1', 'aaaaa-aa')
=== grouping error ('(a+).\\1$', 'aaaaa', 0, 'found+"-"+g1', 'aaaaa-aa') 'aaaaa-' should be 'aaaaa-aa'
=== grouping error ('(a+).\\1$', 'aaaaa', 0, 'found+"-"+g1', 'aaaaa-aa') 'aaaaa-
None
' should be 'aaaaa-aa'
('^(a+).\\1$', 'aaaa', 1)
('^(a+).\\1$', 'aaaa', 1)
('(abc)\\1', 'abcabc', 0, 'found+"-"+g1', 'abcabc-abc')
('(abc)\\1', 'abcabc', 0, 'found+"-"+g1', 'abcabc-abc')
=== grouping error ('(abc)\\1', 'abcabc', 0, 'found+"-"+g1', 'abcabc-abc') 'abcabc-' should be 'abcabc-abc'
=== grouping error ('(abc)\\1', 'abcabc', 0, 'found+"-"+g1', 'abcabc-abc') 'abcabc-
None
' should be 'abcabc-abc'
('([a-c]+)\\1', 'abcabc', 0, 'found+"-"+g1', 'abcabc-abc')
('([a-c]+)\\1', 'abcabc', 0, 'found+"-"+g1', 'abcabc-abc')
=== grouping error ('([a-c]+)\\1', 'abcabc', 0, 'found+"-"+g1', 'abcabc-abc') 'abcabc-' should be 'abcabc-abc'
=== grouping error ('([a-c]+)\\1', 'abcabc', 0, 'found+"-"+g1', 'abcabc-abc') 'abcabc-
None
' should be 'abcabc-abc'
('(a)\\1', 'aa', 0, 'found+"-"+g1', 'aa-a')
('(a)\\1', 'aa', 0, 'found+"-"+g1', 'aa-a')
=== grouping error ('(a)\\1', 'aa', 0, 'found+"-"+g1', 'aa-a') 'aa-' should be 'aa-a'
=== grouping error ('(a)\\1', 'aa', 0, 'found+"-"+g1', 'aa-a') 'aa-
None
' should be 'aa-a'
('(a+)\\1', 'aa', 0, 'found+"-"+g1', 'aa-a')
('(a+)\\1', 'aa', 0, 'found+"-"+g1', 'aa-a')
=== grouping error ('(a+)\\1', 'aa', 0, 'found+"-"+g1', 'aa-a') 'aa-' should be 'aa-a'
=== grouping error ('(a+)\\1', 'aa', 0, 'found+"-"+g1', 'aa-a') 'aa-
None
' should be 'aa-a'
('(a+)+\\1', 'aa', 0, 'found+"-"+g1', 'aa-a')
('(a+)+\\1', 'aa', 0, 'found+"-"+g1', 'aa-a')
=== grouping error ('(a+)+\\1', 'aa', 0, 'found+"-"+g1', 'aa-a') 'aa-' should be 'aa-a'
=== grouping error ('(a+)+\\1', 'aa', 0, 'found+"-"+g1', 'aa-a') 'aa-
None
' should be 'aa-a'
('(a).+\\1', 'aba', 0, 'found+"-"+g1', 'aba-a')
('(a).+\\1', 'aba', 0, 'found+"-"+g1', 'aba-a')
=== grouping error ('(a).+\\1', 'aba', 0, 'found+"-"+g1', 'aba-a') 'aba-' should be 'aba-a'
=== grouping error ('(a).+\\1', 'aba', 0, 'found+"-"+g1', 'aba-a') 'aba-
None
' should be 'aba-a'
('(a)ba*\\1', 'aba', 0, 'found+"-"+g1', 'aba-a')
('(a)ba*\\1', 'aba', 0, 'found+"-"+g1', 'aba-a')
=== grouping error ('(a)ba*\\1', 'aba', 0, 'found+"-"+g1', 'aba-a') 'aba-' should be 'aba-a'
=== grouping error ('(a)ba*\\1', 'aba', 0, 'found+"-"+g1', 'aba-a') 'aba-
None
' should be 'aba-a'
('(aa|a)a\\1$', 'aaa', 0, 'found+"-"+g1', 'aaa-a')
('(aa|a)a\\1$', 'aaa', 0, 'found+"-"+g1', 'aaa-a')
*** Unexpected error ***
*** Unexpected error ***
Traceback (innermost last):
Traceback (innermost last):
File "../Lib/test/test_re.py", line 19, in ?
File "../Lib/test/test_re.py", line 19, in ?
obj=re.compile(pattern)
obj=re.compile(pattern)
File "../Lib/re.py", line 7
45
, in compile
File "../Lib/re.py", line 7
86
, in compile
while (len(stack) > 0) and (stack[-1][0].name != '('):
expr[i] = JumpOpcode(label)
AttributeError: attribute-less object
NameError: JumpOpcode
('(a|aa)a\\1$', 'aaa', 0, 'found+"-"+g1', 'aaa-a')
('(a|aa)a\\1$', 'aaa', 0, 'found+"-"+g1', 'aaa-a')
*** Unexpected error ***
*** Unexpected error ***
Traceback (innermost last):
Traceback (innermost last):
File "../Lib/test/test_re.py", line 19, in ?
File "../Lib/test/test_re.py", line 19, in ?
obj=re.compile(pattern)
obj=re.compile(pattern)
File "../Lib/re.py", line 7
45
, in compile
File "../Lib/re.py", line 7
86
, in compile
while (len(stack) > 0) and (stack[-1][0].name != '('):
expr[i] = JumpOpcode(label)
AttributeError: attribute-less object
NameError: JumpOpcode
('(a+)a\\1$', 'aaa', 0, 'found+"-"+g1', 'aaa-a')
('(a+)a\\1$', 'aaa', 0, 'found+"-"+g1', 'aaa-a')
=== grouping error ('(a+)a\\1$', 'aaa', 0, 'found+"-"+g1', 'aaa-a') 'aaa-' should be 'aaa-a'
=== grouping error ('(a+)a\\1$', 'aaa', 0, 'found+"-"+g1', 'aaa-a') 'aaa-
None
' should be 'aaa-a'
('([abc]*)\\1', 'abcabc', 0, 'found+"-"+g1', 'abcabc-abc')
('([abc]*)\\1', 'abcabc', 0, 'found+"-"+g1', 'abcabc-abc')
=== grouping error ('([abc]*)\\1', 'abcabc', 0, 'found+"-"+g1', 'abcabc-abc') 'abcabc-' should be 'abcabc-abc'
=== grouping error ('([abc]*)\\1', 'abcabc', 0, 'found+"-"+g1', 'abcabc-abc') 'abcabc-
None
' should be 'abcabc-abc'
('(a)(b)c|ab', 'ab', 0, 'found+"-"+g1+"-"+g2', 'ab-None-None')
('(a)(b)c|ab', 'ab', 0, 'found+"-"+g1+"-"+g2', 'ab-None-None')
*** Unexpected error ***
Traceback (innermost last):
File "../Lib/test/test_re.py", line 19, in ?
obj=re.compile(pattern)
File "../Lib/re.py", line 1097, in compile
if stack[-1][0].name == '(':
AttributeError: attribute-less object
('(a)+x', 'aaax', 0, 'found+"-"+g1', 'aaax-a')
('(a)+x', 'aaax', 0, 'found+"-"+g1', 'aaax-a')
=== grouping error ('(a)+x', 'aaax', 0, 'found+"-"+g1', 'aaax-a') 'aaax-' should be 'aaax-a'
=== grouping error ('(a)+x', 'aaax', 0, 'found+"-"+g1', 'aaax-a') 'aaax-
None
' should be 'aaax-a'
('([ac])+x', 'aacx', 0, 'found+"-"+g1', 'aacx-c')
('([ac])+x', 'aacx', 0, 'found+"-"+g1', 'aacx-c')
=== grouping error ('([ac])+x', 'aacx', 0, 'found+"-"+g1', 'aacx-c') 'aacx-' should be 'aacx-c'
=== grouping error ('([ac])+x', 'aacx', 0, 'found+"-"+g1', 'aacx-c') 'aacx-
None
' should be 'aacx-c'
('([^/]*/)*sub1/', 'd:msgs/tdir/sub1/trial/away.cpp', 0, 'found+"-"+g1', 'd:msgs/tdir/sub1/-tdir/')
('([^/]*/)*sub1/', 'd:msgs/tdir/sub1/trial/away.cpp', 0, 'found+"-"+g1', 'd:msgs/tdir/sub1/-tdir/')
=== grouping error ('([^/]*/)*sub1/', 'd:msgs/tdir/sub1/trial/away.cpp', 0, 'found+"-"+g1', 'd:msgs/tdir/sub1/-tdir/') 'd:msgs/tdir/sub1/-' should be 'd:msgs/tdir/sub1/-tdir/'
=== grouping error ('([^/]*/)*sub1/', 'd:msgs/tdir/sub1/trial/away.cpp', 0, 'found+"-"+g1', 'd:msgs/tdir/sub1/-tdir/') 'd:msgs/tdir/sub1/-
None
' should be 'd:msgs/tdir/sub1/-tdir/'
('([^.]*)\\.([^:]*):[T ]+(.*)', 'track1.title:TBlah blah blah', 0, 'found+"-"+g1+"-"+g2+"-"+g3', 'track1.title:TBlah blah blah-track1-title-Blah blah blah')
('([^.]*)\\.([^:]*):[T ]+(.*)', 'track1.title:TBlah blah blah', 0, 'found+"-"+g1+"-"+g2+"-"+g3', 'track1.title:TBlah blah blah-track1-title-Blah blah blah')
=== Failed incorrectly ('([^.]*)\\.([^:]*):[T ]+(.*)', 'track1.title:TBlah blah blah', 0, 'found+"-"+g1+"-"+g2+"-"+g3', 'track1.title:TBlah blah blah-track1-title-Blah blah blah')
=== Failed incorrectly ('([^.]*)\\.([^:]*):[T ]+(.*)', 'track1.title:TBlah blah blah', 0, 'found+"-"+g1+"-"+g2+"-"+g3', 'track1.title:TBlah blah blah-track1-title-Blah blah blah')
('([^N]*N)+', 'abNNxyzN', 0, 'found+"-"+g1', 'abNNxyzN-xyzN')
('([^N]*N)+', 'abNNxyzN', 0, 'found+"-"+g1', 'abNNxyzN-xyzN')
=== grouping error ('([^N]*N)+', 'abNNxyzN', 0, 'found+"-"+g1', 'abNNxyzN-xyzN') 'abNNxyzN-' should be 'abNNxyzN-xyzN'
=== grouping error ('([^N]*N)+', 'abNNxyzN', 0, 'found+"-"+g1', 'abNNxyzN-xyzN') 'abNNxyzN-
None
' should be 'abNNxyzN-xyzN'
('([^N]*N)+', 'abNNxyz', 0, 'found+"-"+g1', 'abNN-N')
('([^N]*N)+', 'abNNxyz', 0, 'found+"-"+g1', 'abNN-N')
=== grouping error ('([^N]*N)+', 'abNNxyz', 0, 'found+"-"+g1', 'abNN-N') 'abNN-' should be 'abNN-N'
=== grouping error ('([^N]*N)+', 'abNNxyz', 0, 'found+"-"+g1', 'abNN-N') 'abNN-
None
' should be 'abNN-N'
('([abc]*)x', 'abcx', 0, 'found+"-"+g1', 'abcx-abc')
('([abc]*)x', 'abcx', 0, 'found+"-"+g1', 'abcx-abc')
=== grouping error ('([abc]*)x', 'abcx', 0, 'found+"-"+g1', 'abcx-abc') 'abcx-' should be 'abcx-abc'
=== grouping error ('([abc]*)x', 'abcx', 0, 'found+"-"+g1', 'abcx-abc') 'abcx-
None
' should be 'abcx-abc'
('([abc]*)x', 'abc', 1)
('([abc]*)x', 'abc', 1)
('([xyz]*)x', 'abcx', 0, 'found+"-"+g1', 'x-')
('([xyz]*)x', 'abcx', 0, 'found+"-"+g1', 'x-')
=== grouping error ('([xyz]*)x', 'abcx', 0, 'found+"-"+g1', 'x-') 'x-None' should be 'x-'
('(a)+b|aac', 'aac', 0, 'found+"-"+g1', 'aac-None')
('(a)+b|aac', 'aac', 0, 'found+"-"+g1', 'aac-None')
*** Unexpected error ***
Traceback (innermost last):
File "../Lib/test/test_re.py", line 19, in ?
obj=re.compile(pattern)
File "../Lib/re.py", line 1097, in compile
if stack[-1][0].name == '(':
AttributeError: attribute-less object
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment