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
00b61270
Kaydet (Commit)
00b61270
authored
Ara 12, 2002
tarafından
Martin v. Löwis
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Patch #650653: Raise always value error if the table is not 256 bytes long.
üst
63b4dd33
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
8 additions
and
6 deletions
+8
-6
string_tests.py
Lib/test/string_tests.py
+2
-0
stringobject.c
Objects/stringobject.c
+6
-6
No files found.
Lib/test/string_tests.py
Dosyayı görüntüle @
00b61270
...
...
@@ -192,6 +192,8 @@ def run_method_tests(test):
table
=
string
.
maketrans
(
'a'
,
'A'
)
test
(
'translate'
,
'abc'
,
'Abc'
,
table
)
test
(
'translate'
,
'xyz'
,
'xyz'
,
table
)
test
(
'translate'
,
'xyz'
,
ValueError
,
'too short'
,
'strip'
)
test
(
'translate'
,
'xyz'
,
ValueError
,
'too short'
)
test
(
'replace'
,
'one!two!three!'
,
'one@two!three!'
,
'!'
,
'@'
,
1
)
test
(
'replace'
,
'one!two!three!'
,
'onetwothree'
,
'!'
,
''
)
...
...
Objects/stringobject.c
Dosyayı görüntüle @
00b61270
...
...
@@ -2070,6 +2070,12 @@ string_translate(PyStringObject *self, PyObject *args)
else
if
(
PyObject_AsCharBuffer
(
tableobj
,
&
table1
,
&
tablen
))
return
NULL
;
if
(
tablen
!=
256
)
{
PyErr_SetString
(
PyExc_ValueError
,
"translation table must be 256 characters long"
);
return
NULL
;
}
if
(
delobj
!=
NULL
)
{
if
(
PyString_Check
(
delobj
))
{
del_table
=
PyString_AS_STRING
(
delobj
);
...
...
@@ -2084,12 +2090,6 @@ string_translate(PyStringObject *self, PyObject *args)
#endif
else
if
(
PyObject_AsCharBuffer
(
delobj
,
&
del_table
,
&
dellen
))
return
NULL
;
if
(
tablen
!=
256
)
{
PyErr_SetString
(
PyExc_ValueError
,
"translation table must be 256 characters long"
);
return
NULL
;
}
}
else
{
del_table
=
NULL
;
...
...
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