Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
cpython
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
cpython
Commits
bf71f7d6
Kaydet (Commit)
bf71f7d6
authored
Nis 14, 2013
tarafından
R David Murray
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Sade Fark
Merge #17341: Include name in re error message about invalid group name.
Patch by Jason Michalski.
üst
255fb3e9
26dfaac9
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
18 additions
and
2 deletions
+18
-2
sre_parse.py
Lib/sre_parse.py
+3
-2
test_re.py
Lib/test/test_re.py
+11
-0
ACKS
Misc/ACKS
+1
-0
NEWS
Misc/NEWS
+3
-0
No files found.
Lib/sre_parse.py
Dosyayı görüntüle @
bf71f7d6
...
...
@@ -600,7 +600,7 @@ def _parse(source, state):
if
not
name
:
raise
error
(
"missing group name"
)
if
not
name
.
isidentifier
():
raise
error
(
"bad character in group name
"
)
raise
error
(
"bad character in group name
%
r"
%
name
)
elif
sourcematch
(
"="
):
# named backreference
name
=
""
...
...
@@ -614,7 +614,8 @@ def _parse(source, state):
if
not
name
:
raise
error
(
"missing group name"
)
if
not
name
.
isidentifier
():
raise
error
(
"bad character in group name"
)
raise
error
(
"bad character in backref group name "
"
%
r"
%
name
)
gid
=
state
.
groupdict
.
get
(
name
)
if
gid
is
None
:
raise
error
(
"unknown group name"
)
...
...
Lib/test/test_re.py
Dosyayı görüntüle @
bf71f7d6
...
...
@@ -3,6 +3,7 @@ from test.support import verbose, run_unittest, gc_collect, bigmemtest, _2G, \
import
io
import
re
from
re
import
Scanner
import
sre_constants
import
sys
import
string
import
traceback
...
...
@@ -1029,6 +1030,16 @@ class ReTests(unittest.TestCase):
self
.
assertRaises
(
OverflowError
,
re
.
compile
,
r".{,
%
d}"
%
MAXREPEAT
)
self
.
assertRaises
(
OverflowError
,
re
.
compile
,
r".{
%
d,}?"
%
MAXREPEAT
)
def
test_backref_group_name_in_exception
(
self
):
# Issue 17341: Poor error message when compiling invalid regex
with
self
.
assertRaisesRegex
(
sre_constants
.
error
,
'<foo>'
):
re
.
compile
(
'(?P=<foo>)'
)
def
test_group_name_in_exception
(
self
):
# Issue 17341: Poor error message when compiling invalid regex
with
self
.
assertRaisesRegex
(
sre_constants
.
error
,
'
\
?foo'
):
re
.
compile
(
'(?P<?foo>)'
)
def
run_re_tests
():
from
test.re_tests
import
tests
,
SUCCEED
,
FAIL
,
SYNTAX_ERROR
...
...
Misc/ACKS
Dosyayı görüntüle @
bf71f7d6
...
...
@@ -821,6 +821,7 @@ Piotr Meyer
Alexis Métaireau
Steven Miale
Trent Mick
Jason Michalski
Franck Michea
Tom Middleton
Stan Mihai
...
...
Misc/NEWS
Dosyayı görüntüle @
bf71f7d6
...
...
@@ -42,6 +42,9 @@ Core and Builtins
Library
-------
-
Issue
#
17341
:
Include
the
invalid
name
in
the
error
messages
from
re
about
invalid
group
names
.
-
Issue
#
17702
:
os
.
environ
now
raises
KeyError
with
the
original
environment
variable
name
(
str
on
UNIX
),
instead
of
using
the
encoded
name
(
bytes
on
UNIX
).
...
...
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