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
df02d0b3
Kaydet (Commit)
df02d0b3
authored
Haz 30, 2000
tarafından
Fredrik Lundh
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
- fixed default value handling in group/groupdict
- added test suite
üst
47c60ec9
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
38 additions
and
19 deletions
+38
-19
sre.py
Lib/sre.py
+1
-1
test_sre
Lib/test/output/test_sre
+14
-0
test_sre.py
Lib/test/test_sre.py
+0
-0
_sre.c
Modules/_sre.c
+23
-18
No files found.
Lib/sre.py
Dosyayı görüntüle @
df02d0b3
...
...
@@ -20,7 +20,7 @@ M = MULTILINE = sre_compile.SRE_FLAG_MULTILINE
S
=
DOTALL
=
sre_compile
.
SRE_FLAG_DOTALL
X
=
VERBOSE
=
sre_compile
.
SRE_FLAG_VERBOSE
# sre extensions (may or may not be in
1.6
final)
# sre extensions (may or may not be in
2.0
final)
T
=
TEMPLATE
=
sre_compile
.
SRE_FLAG_TEMPLATE
U
=
UNICODE
=
sre_compile
.
SRE_FLAG_UNICODE
...
...
Lib/test/output/test_sre
0 → 100644
Dosyayı görüntüle @
df02d0b3
test_sre
test_support -- test failed re module pickle
test_support -- test failed re module cPickle
=== Syntax error: ('(?P<foo_123>a)(?P=foo_123)', 'aa', 0, 'g1', 'a')
=== Failed incorrectly ('^(.+)?B', 'AB', 0, 'g1', 'A')
=== Failed incorrectly ('(a+)+\\1', 'aa', 0, 'found+"-"+g1', 'aa-a')
=== grouping error ('([^/]*/)*sub1/', 'd:msgs/tdir/sub1/trial/away.cpp', 0, 'found+"-"+g1', 'd:msgs/tdir/sub1/-tdir/') 'd:msgs/tdir/sub1/-trial/' should be 'd:msgs/tdir/sub1/-tdir/'
=== Syntax error: ('(?P<id>aa)(?P=id)', 'aaaa', 0, 'found+"-"+id', 'aaaa-aa')
=== grouping error ('([abc])*bcd', 'abcd', 0, 'found+"-"+g1', 'abcd-a') 'abcd-c' should be 'abcd-a'
=== grouping error ('(?i)([abc])*bcd', 'ABCD', 0, 'found+"-"+g1', 'ABCD-A') 'ABCD-C' should be 'ABCD-A'
=== Syntax error: ('a(?!b).', 'abad', 0, 'found', 'ad')
=== Syntax error: ('a(?=d).', 'abad', 0, 'found', 'ad')
=== Syntax error: ('a(?=c|d).', 'abad', 0, 'found', 'ad')
=== Failed incorrectly ('^(.+)?B', 'AB', 0, 'g1', 'A')
Lib/test/test_sre.py
0 → 100644
Dosyayı görüntüle @
df02d0b3
This diff is collapsed.
Click to expand it.
Modules/_sre.c
Dosyayı görüntüle @
df02d0b3
...
...
@@ -1566,7 +1566,7 @@ match_dealloc(MatchObject* self)
}
static
PyObject
*
match_getslice_by_index
(
MatchObject
*
self
,
int
index
)
match_getslice_by_index
(
MatchObject
*
self
,
int
index
,
PyObject
*
def
)
{
if
(
index
<
0
||
index
>=
self
->
groups
)
{
/* raise IndexError if we were given a bad group number */
...
...
@@ -1578,9 +1578,9 @@ match_getslice_by_index(MatchObject* self, int index)
}
if
(
self
->
string
==
Py_None
||
self
->
mark
[
index
+
index
]
<
0
)
{
/* return
Non
e if the string or group is undefined */
Py_INCREF
(
Py_None
);
return
Py_None
;
/* return
default valu
e if the string or group is undefined */
Py_INCREF
(
def
);
return
def
;
}
return
PySequence_GetSlice
(
...
...
@@ -1605,9 +1605,9 @@ match_getindex(MatchObject* self, PyObject* index)
}
static
PyObject
*
match_getslice
(
MatchObject
*
self
,
PyObject
*
index
)
match_getslice
(
MatchObject
*
self
,
PyObject
*
index
,
PyObject
*
def
)
{
return
match_getslice_by_index
(
self
,
match_getindex
(
self
,
index
));
return
match_getslice_by_index
(
self
,
match_getindex
(
self
,
index
)
,
def
);
}
static
PyObject
*
...
...
@@ -1620,10 +1620,10 @@ match_group(MatchObject* self, PyObject* args)
switch
(
size
)
{
case
0
:
result
=
match_getslice
(
self
,
Py_False
);
result
=
match_getslice
(
self
,
Py_False
,
Py_None
);
break
;
case
1
:
result
=
match_getslice
(
self
,
PyTuple_GET_ITEM
(
args
,
0
));
result
=
match_getslice
(
self
,
PyTuple_GET_ITEM
(
args
,
0
)
,
Py_None
);
break
;
default:
/* fetch multiple items */
...
...
@@ -1631,7 +1631,9 @@ match_group(MatchObject* self, PyObject* args)
if
(
!
result
)
return
NULL
;
for
(
i
=
0
;
i
<
size
;
i
++
)
{
PyObject
*
item
=
match_getslice
(
self
,
PyTuple_GET_ITEM
(
args
,
i
));
PyObject
*
item
=
match_getslice
(
self
,
PyTuple_GET_ITEM
(
args
,
i
),
Py_None
);
if
(
!
item
)
{
Py_DECREF
(
result
);
return
NULL
;
...
...
@@ -1649,7 +1651,9 @@ match_groups(MatchObject* self, PyObject* args)
PyObject
*
result
;
int
index
;
/* FIXME: <fl> handle default value! */
PyObject
*
def
=
Py_None
;
if
(
!
PyArg_ParseTuple
(
args
,
"|O"
,
&
def
))
return
NULL
;
result
=
PyTuple_New
(
self
->
groups
-
1
);
if
(
!
result
)
...
...
@@ -1657,8 +1661,7 @@ match_groups(MatchObject* self, PyObject* args)
for
(
index
=
1
;
index
<
self
->
groups
;
index
++
)
{
PyObject
*
item
;
/* FIXME: <fl> handle default! */
item
=
match_getslice_by_index
(
self
,
index
);
item
=
match_getslice_by_index
(
self
,
index
,
def
);
if
(
!
item
)
{
Py_DECREF
(
result
);
return
NULL
;
...
...
@@ -1676,17 +1679,19 @@ match_groupdict(MatchObject* self, PyObject* args)
PyObject
*
keys
;
int
index
;
/* FIXME: <fl> handle default value! */
PyObject
*
def
=
Py_None
;
if
(
!
PyArg_ParseTuple
(
args
,
"|O"
,
&
def
))
return
NULL
;
result
=
PyDict_New
();
if
(
!
result
)
return
NULL
;
if
(
!
self
->
pattern
->
groupindex
)
if
(
!
result
||
!
self
->
pattern
->
groupindex
)
return
result
;
keys
=
PyMapping_Keys
(
self
->
pattern
->
groupindex
);
if
(
!
keys
)
if
(
!
keys
)
{
Py_DECREF
(
result
);
return
NULL
;
}
for
(
index
=
0
;
index
<
PyList_GET_SIZE
(
keys
);
index
++
)
{
PyObject
*
key
;
...
...
@@ -1697,7 +1702,7 @@ match_groupdict(MatchObject* self, PyObject* args)
Py_DECREF
(
result
);
return
NULL
;
}
item
=
match_getslice
(
self
,
key
);
item
=
match_getslice
(
self
,
key
,
def
);
if
(
!
item
)
{
Py_DECREF
(
key
);
Py_DECREF
(
keys
);
...
...
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