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
39bdad81
Kaydet (Commit)
39bdad81
authored
Kas 20, 2012
tarafından
Antoine Pitrou
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Issue #1160: Fix compiling large regular expressions on UCS2 builds.
Patch by Serhiy Storchaka.
üst
4a1fdcf0
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
17 additions
and
9 deletions
+17
-9
test_re.py
Lib/test/test_re.py
+6
-0
NEWS
Misc/NEWS
+3
-0
_sre.c
Modules/_sre.c
+7
-4
sre.h
Modules/sre.h
+1
-5
No files found.
Lib/test/test_re.py
Dosyayı görüntüle @
39bdad81
...
@@ -419,6 +419,12 @@ class ReTests(unittest.TestCase):
...
@@ -419,6 +419,12 @@ class ReTests(unittest.TestCase):
self
.
assertEqual
(
re
.
match
(
"([
\u2222\u2223
])"
,
self
.
assertEqual
(
re
.
match
(
"([
\u2222\u2223
])"
,
"
\u2222
"
,
re
.
UNICODE
)
.
group
(
1
),
"
\u2222
"
)
"
\u2222
"
,
re
.
UNICODE
)
.
group
(
1
),
"
\u2222
"
)
def
test_big_codesize
(
self
):
# Issue #1160
r
=
re
.
compile
(
'|'
.
join
((
'
%
d'
%
x
for
x
in
range
(
10000
))))
self
.
assertIsNotNone
(
r
.
match
(
'1000'
))
self
.
assertIsNotNone
(
r
.
match
(
'9999'
))
def
test_anyall
(
self
):
def
test_anyall
(
self
):
self
.
assertEqual
(
re
.
match
(
"a.b"
,
"a
\n
b"
,
re
.
DOTALL
)
.
group
(
0
),
self
.
assertEqual
(
re
.
match
(
"a.b"
,
"a
\n
b"
,
re
.
DOTALL
)
.
group
(
0
),
"a
\n
b"
)
"a
\n
b"
)
...
...
Misc/NEWS
Dosyayı görüntüle @
39bdad81
...
@@ -167,6 +167,9 @@ Core and Builtins
...
@@ -167,6 +167,9 @@ Core and Builtins
Library
Library
-------
-------
- Issue #1160: Fix compiling large regular expressions on UCS2 builds.
Patch by Serhiy Storchaka.
- Issue #14313: zipfile now raises NotImplementedError when the compression
- Issue #14313: zipfile now raises NotImplementedError when the compression
type is unknown.
type is unknown.
...
...
Modules/_sre.c
Dosyayı görüntüle @
39bdad81
...
@@ -2695,6 +2695,13 @@ _compile(PyObject* self_, PyObject* args)
...
@@ -2695,6 +2695,13 @@ _compile(PyObject* self_, PyObject* args)
for
(
i
=
0
;
i
<
n
;
i
++
)
{
for
(
i
=
0
;
i
<
n
;
i
++
)
{
PyObject
*
o
=
PyList_GET_ITEM
(
code
,
i
);
PyObject
*
o
=
PyList_GET_ITEM
(
code
,
i
);
unsigned
long
value
=
PyLong_AsUnsignedLong
(
o
);
unsigned
long
value
=
PyLong_AsUnsignedLong
(
o
);
if
(
value
==
(
unsigned
long
)
-
1
&&
PyErr_Occurred
())
{
if
(
PyErr_ExceptionMatches
(
PyExc_OverflowError
))
{
PyErr_SetString
(
PyExc_OverflowError
,
"regular expression code size limit exceeded"
);
}
break
;
}
self
->
code
[
i
]
=
(
SRE_CODE
)
value
;
self
->
code
[
i
]
=
(
SRE_CODE
)
value
;
if
((
unsigned
long
)
self
->
code
[
i
]
!=
value
)
{
if
((
unsigned
long
)
self
->
code
[
i
]
!=
value
)
{
PyErr_SetString
(
PyExc_OverflowError
,
PyErr_SetString
(
PyExc_OverflowError
,
...
@@ -3065,10 +3072,8 @@ _validate_inner(SRE_CODE *code, SRE_CODE *end, Py_ssize_t groups)
...
@@ -3065,10 +3072,8 @@ _validate_inner(SRE_CODE *code, SRE_CODE *end, Py_ssize_t groups)
GET_ARG
;
max
=
arg
;
GET_ARG
;
max
=
arg
;
if
(
min
>
max
)
if
(
min
>
max
)
FAIL
;
FAIL
;
#ifdef Py_UNICODE_WIDE
if
(
max
>
65535
)
if
(
max
>
65535
)
FAIL
;
FAIL
;
#endif
if
(
!
_validate_inner
(
code
,
code
+
skip
-
4
,
groups
))
if
(
!
_validate_inner
(
code
,
code
+
skip
-
4
,
groups
))
FAIL
;
FAIL
;
code
+=
skip
-
4
;
code
+=
skip
-
4
;
...
@@ -3086,10 +3091,8 @@ _validate_inner(SRE_CODE *code, SRE_CODE *end, Py_ssize_t groups)
...
@@ -3086,10 +3091,8 @@ _validate_inner(SRE_CODE *code, SRE_CODE *end, Py_ssize_t groups)
GET_ARG
;
max
=
arg
;
GET_ARG
;
max
=
arg
;
if
(
min
>
max
)
if
(
min
>
max
)
FAIL
;
FAIL
;
#ifdef Py_UNICODE_WIDE
if
(
max
>
65535
)
if
(
max
>
65535
)
FAIL
;
FAIL
;
#endif
if
(
!
_validate_inner
(
code
,
code
+
skip
-
3
,
groups
))
if
(
!
_validate_inner
(
code
,
code
+
skip
-
3
,
groups
))
FAIL
;
FAIL
;
code
+=
skip
-
3
;
code
+=
skip
-
3
;
...
...
Modules/sre.h
Dosyayı görüntüle @
39bdad81
...
@@ -14,12 +14,8 @@
...
@@ -14,12 +14,8 @@
#include "sre_constants.h"
#include "sre_constants.h"
/* size of a code word (must be unsigned short or larger, and
/* size of a code word (must be unsigned short or larger, and
large enough to hold a Py_UNICODE character) */
large enough to hold a UCS4 character) */
#ifdef Py_UNICODE_WIDE
#define SRE_CODE Py_UCS4
#define SRE_CODE Py_UCS4
#else
#define SRE_CODE unsigned short
#endif
typedef
struct
{
typedef
struct
{
PyObject_VAR_HEAD
PyObject_VAR_HEAD
...
...
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