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
6ed5f30f
Kaydet (Commit)
6ed5f30f
authored
Haz 02, 2005
tarafından
Andrew M. Kuchling
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
[Bug #1177831] Fix (?(id)yes|no) for a group other than the first one, and add a test case
üst
270dfd86
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
1 deletion
+11
-1
sre_compile.py
Lib/sre_compile.py
+1
-1
test_re.py
Lib/test/test_re.py
+10
-0
No files found.
Lib/sre_compile.py
Dosyayı görüntüle @
6ed5f30f
...
...
@@ -156,7 +156,7 @@ def _compile(code, pattern, flags):
emit
(
av
-
1
)
elif
op
is
GROUPREF_EXISTS
:
emit
(
OPCODES
[
op
])
emit
(
(
av
[
0
]
-
1
)
*
2
)
emit
(
av
[
0
]
-
1
)
skipyes
=
_len
(
code
);
emit
(
0
)
_compile
(
code
,
av
[
1
],
flags
)
if
av
[
2
]:
...
...
Lib/test/test_re.py
Dosyayı görüntüle @
6ed5f30f
...
...
@@ -235,6 +235,16 @@ class ReTests(unittest.TestCase):
self
.
assertEqual
(
re
.
match
(
'^(?:(a)|c)((?(1)|d))$'
,
'a'
)
.
groups
(),
(
'a'
,
''
))
# Tests for bug #1177831: exercise groups other than the first group
p
=
re
.
compile
(
'(?P<g1>a)(?P<g2>b)?((?(g2)c|d))'
)
self
.
assertEqual
(
p
.
match
(
'abc'
)
.
groups
(),
(
'a'
,
'b'
,
'c'
))
self
.
assertEqual
(
p
.
match
(
'ad'
)
.
groups
(),
(
'a'
,
None
,
'd'
))
self
.
assertEqual
(
p
.
match
(
'abd'
),
None
)
self
.
assertEqual
(
p
.
match
(
'ac'
),
None
)
def
test_re_groupref
(
self
):
self
.
assertEqual
(
re
.
match
(
r'^(\|)?([^()]+)\1$'
,
'|a|'
)
.
groups
(),
(
'|'
,
'a'
))
...
...
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