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
40a088dc
Kaydet (Commit)
40a088dc
authored
Mar 18, 2008
tarafından
Thomas Wouters
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Fix 're' to work on bytes. It could do with a few more tests, though.
üst
e8c3d266
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
22 additions
and
34 deletions
+22
-34
sre_compile.py
Lib/sre_compile.py
+1
-1
sre_parse.py
Lib/sre_parse.py
+2
-2
test_re.py
Lib/test/test_re.py
+19
-31
No files found.
Lib/sre_compile.py
Dosyayı görüntüle @
40a088dc
...
...
@@ -472,7 +472,7 @@ def _compile_info(code, pattern, flags):
code
[
skip
]
=
len
(
code
)
-
skip
def
isstring
(
obj
):
return
isinstance
(
obj
,
str
)
return
isinstance
(
obj
,
(
str
,
bytes
)
)
def
_code
(
p
,
flags
):
...
...
Lib/sre_parse.py
Dosyayı görüntüle @
40a088dc
...
...
@@ -192,8 +192,8 @@ class Tokenizer:
char
=
self
.
string
[
self
.
index
:
self
.
index
+
1
]
# Special case for the str8, since indexing returns a integer
# XXX This is only needed for test_bug_926075 in test_re.py
if
isinstance
(
self
.
string
,
bytes
):
char
=
chr
(
char
)
if
char
and
isinstance
(
char
,
bytes
):
char
=
chr
(
char
[
0
]
)
if
char
==
"
\\
"
:
try
:
c
=
self
.
string
[
self
.
index
+
1
]
...
...
Lib/test/test_re.py
Dosyayı görüntüle @
40a088dc
...
...
@@ -83,33 +83,22 @@ class ReTests(unittest.TestCase):
self
.
assertEqual
(
re
.
sub
(
'
\r\n
'
,
'
\n
'
,
'abc
\r\n
def
\r\n
'
),
'abc
\n
def
\n
'
)
# This test makes no sense until re supports bytes, and should then probably
# test for the *in*ability to mix bytes and str this way :)
#
# def test_bug_1140(self):
# # re.sub(x, y, b'') should return b'', not '', and
# # re.sub(x, y, '') should return '', not b''.
# # Also:
# # re.sub(x, y, str(x)) should return str(y), and
# # re.sub(x, y, bytes(x)) should return
# # str(y) if isinstance(y, str) else unicode(y).
# for x in 'x', u'x':
# for y in 'y', u'y':
# z = re.sub(x, y, u'')
# self.assertEqual(z, u'')
# self.assertEqual(type(z), unicode)
# #
# z = re.sub(x, y, '')
# self.assertEqual(z, '')
# self.assertEqual(type(z), str)
# #
# z = re.sub(x, y, unicode(x))
# self.assertEqual(z, y)
# self.assertEqual(type(z), unicode)
# #
# z = re.sub(x, y, str(x))
# self.assertEqual(z, y)
# self.assertEqual(type(z), type(y))
def
test_bug_1140
(
self
):
# re.sub(x, y, b'') should return b'', not '', and
# re.sub(x, y, '') should return '', not b''.
# Also:
# re.sub(x, y, str(x)) should return str(y), and
# re.sub(x, y, bytes(x)) should return
# str(y) if isinstance(y, str) else unicode(y).
for
x
in
'x'
,
b
'x'
:
for
y
in
'y'
,
b
'y'
:
z
=
re
.
sub
(
x
,
y
,
b
''
)
self
.
assertEqual
(
z
,
b
''
)
self
.
assertEqual
(
type
(
z
),
bytes
)
#
z
=
re
.
sub
(
x
,
y
,
''
)
self
.
assertEqual
(
z
,
''
)
self
.
assertEqual
(
type
(
z
),
str
)
def
test_bug_1661
(
self
):
# Verify that flags do not get silently ignored with compiled patterns
...
...
@@ -599,10 +588,9 @@ class ReTests(unittest.TestCase):
self
.
assertEqual
([
item
.
group
(
0
)
for
item
in
iter
],
[
":"
,
"::"
,
":::"
])
# XXX This needs to be restored for str vs. bytes.
## def test_bug_926075(self):
## self.assert_(re.compile('bug_926075') is not
## re.compile(str8('bug_926075')))
def
test_bug_926075
(
self
):
self
.
assert_
(
re
.
compile
(
'bug_926075'
)
is
not
re
.
compile
(
b
'bug_926075'
))
def
test_bug_931848
(
self
):
pattern
=
eval
(
'"[
\u002E\u3002\uFF0E\uFF61
]"'
)
...
...
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