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
07360df4
Kaydet (Commit)
07360df4
authored
Mar 29, 2015
tarafından
Serhiy Storchaka
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Issue #14260: The groupindex attribute of regular expression pattern object
now is non-modifiable mapping.
üst
1813c170
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
31 additions
and
5 deletions
+31
-5
csv.py
Lib/csv.py
+4
-3
sre_parse.py
Lib/sre_parse.py
+2
-1
test_re.py
Lib/test/test_re.py
+8
-0
NEWS
Misc/NEWS
+3
-0
_sre.c
Modules/_sre.c
+14
-1
No files found.
Lib/csv.py
Dosyayı görüntüle @
07360df4
...
...
@@ -231,20 +231,21 @@ class Sniffer:
quotes
=
{}
delims
=
{}
spaces
=
0
groupindex
=
regexp
.
groupindex
for
m
in
matches
:
n
=
regexp
.
groupindex
[
'quote'
]
-
1
n
=
groupindex
[
'quote'
]
-
1
key
=
m
[
n
]
if
key
:
quotes
[
key
]
=
quotes
.
get
(
key
,
0
)
+
1
try
:
n
=
regexp
.
groupindex
[
'delim'
]
-
1
n
=
groupindex
[
'delim'
]
-
1
key
=
m
[
n
]
except
KeyError
:
continue
if
key
and
(
delimiters
is
None
or
key
in
delimiters
):
delims
[
key
]
=
delims
.
get
(
key
,
0
)
+
1
try
:
n
=
regexp
.
groupindex
[
'space'
]
-
1
n
=
groupindex
[
'space'
]
-
1
except
KeyError
:
continue
if
m
[
n
]:
...
...
Lib/sre_parse.py
Dosyayı görüntüle @
07360df4
...
...
@@ -855,6 +855,7 @@ def parse_template(source, pattern):
del
literal
[:]
groups
.
append
((
len
(
literals
),
index
))
literals
.
append
(
None
)
groupindex
=
pattern
.
groupindex
while
True
:
this
=
sget
()
if
this
is
None
:
...
...
@@ -869,7 +870,7 @@ def parse_template(source, pattern):
name
=
s
.
getuntil
(
">"
)
if
name
.
isidentifier
():
try
:
index
=
pattern
.
groupindex
[
name
]
index
=
groupindex
[
name
]
except
KeyError
:
raise
IndexError
(
"unknown group name
%
r"
%
name
)
else
:
...
...
Lib/test/test_re.py
Dosyayı görüntüle @
07360df4
...
...
@@ -577,6 +577,14 @@ class ReTests(unittest.TestCase):
self
.
assertEqual
(
re
.
match
(
"(a)"
,
"a"
)
.
regs
,
((
0
,
1
),
(
0
,
1
)))
self
.
assertTrue
(
re
.
match
(
"(a)"
,
"a"
)
.
re
)
# Issue 14260. groupindex should be non-modifiable mapping.
p
=
re
.
compile
(
r'(?i)(?P<first>a)(?P<other>b)'
)
self
.
assertEqual
(
sorted
(
p
.
groupindex
),
[
'first'
,
'other'
])
self
.
assertEqual
(
p
.
groupindex
[
'other'
],
2
)
with
self
.
assertRaises
(
TypeError
):
p
.
groupindex
[
'other'
]
=
0
self
.
assertEqual
(
p
.
groupindex
[
'other'
],
2
)
def
test_special_escapes
(
self
):
self
.
assertEqual
(
re
.
search
(
r"\b(b.)\b"
,
"abcd abc bcd bx"
)
.
group
(
1
),
"bx"
)
...
...
Misc/NEWS
Dosyayı görüntüle @
07360df4
...
...
@@ -30,6 +30,9 @@ Core and Builtins
Library
-------
-
Issue
#
14260
:
The
groupindex
attribute
of
regular
expression
pattern
object
now
is
non
-
modifiable
mapping
.
-
Issue
#
23792
:
Ignore
KeyboardInterrupt
when
the
pydoc
pager
is
active
.
This
mimics
the
behavior
of
the
standard
unix
pagers
,
and
prevents
pipepager
from
shutting
down
while
the
pager
itself
is
still
running
.
...
...
Modules/_sre.c
Dosyayı görüntüle @
07360df4
...
...
@@ -1384,12 +1384,24 @@ static PyMethodDef pattern_methods[] = {
{
NULL
,
NULL
}
};
/* PatternObject's 'groupindex' method. */
static
PyObject
*
pattern_groupindex
(
PatternObject
*
self
)
{
return
PyDictProxy_New
(
self
->
groupindex
);
}
static
PyGetSetDef
pattern_getset
[]
=
{
{
"groupindex"
,
(
getter
)
pattern_groupindex
,
(
setter
)
NULL
,
"A dictionary mapping group names to group numbers."
},
{
NULL
}
/* Sentinel */
};
#define PAT_OFF(x) offsetof(PatternObject, x)
static
PyMemberDef
pattern_members
[]
=
{
{
"pattern"
,
T_OBJECT
,
PAT_OFF
(
pattern
),
READONLY
},
{
"flags"
,
T_INT
,
PAT_OFF
(
flags
),
READONLY
},
{
"groups"
,
T_PYSSIZET
,
PAT_OFF
(
groups
),
READONLY
},
{
"groupindex"
,
T_OBJECT
,
PAT_OFF
(
groupindex
),
READONLY
},
{
NULL
}
/* Sentinel */
};
...
...
@@ -1422,6 +1434,7 @@ static PyTypeObject Pattern_Type = {
0
,
/* tp_iternext */
pattern_methods
,
/* tp_methods */
pattern_members
,
/* tp_members */
pattern_getset
,
/* tp_getset */
};
static
int
_validate
(
PatternObject
*
self
);
/* Forward */
...
...
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