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
3b77d01d
Kaydet (Commit)
3b77d01d
authored
Tem 24, 2015
tarafından
Serhiy Storchaka
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Issue #24620: Random.setstate() now validates the value of state last element.
üst
affac006
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
11 additions
and
0 deletions
+11
-0
test_random.py
Lib/test/test_random.py
+5
-0
NEWS
Misc/NEWS
+2
-0
_randommodule.c
Modules/_randommodule.c
+4
-0
No files found.
Lib/test/test_random.py
Dosyayı görüntüle @
3b77d01d
...
@@ -319,6 +319,11 @@ class MersenneTwister_TestBasicOps(TestBasicOps):
...
@@ -319,6 +319,11 @@ class MersenneTwister_TestBasicOps(TestBasicOps):
self
.
assertRaises
(
TypeError
,
self
.
gen
.
setstate
,
(
2
,
(
'a'
,)
*
625
,
None
))
self
.
assertRaises
(
TypeError
,
self
.
gen
.
setstate
,
(
2
,
(
'a'
,)
*
625
,
None
))
# Last element s/b an int also
# Last element s/b an int also
self
.
assertRaises
(
TypeError
,
self
.
gen
.
setstate
,
(
2
,
(
0
,)
*
624
+
(
'a'
,),
None
))
self
.
assertRaises
(
TypeError
,
self
.
gen
.
setstate
,
(
2
,
(
0
,)
*
624
+
(
'a'
,),
None
))
# Last element s/b between 0 and 624
with
self
.
assertRaises
((
ValueError
,
OverflowError
)):
self
.
gen
.
setstate
((
2
,
(
1
,)
*
624
+
(
625
,),
None
))
with
self
.
assertRaises
((
ValueError
,
OverflowError
)):
self
.
gen
.
setstate
((
2
,
(
1
,)
*
624
+
(
-
1
,),
None
))
def
test_referenceImplementation
(
self
):
def
test_referenceImplementation
(
self
):
# Compare the python implementation with results from the original
# Compare the python implementation with results from the original
...
...
Misc/NEWS
Dosyayı görüntüle @
3b77d01d
...
@@ -34,6 +34,8 @@ Core and Builtins
...
@@ -34,6 +34,8 @@ Core and Builtins
Library
Library
-------
-------
- Issue #24620: Random.setstate() now validates the value of state last element.
- Issue #13938: 2to3 converts StringTypes to a tuple. Patch from Mark Hammond.
- Issue #13938: 2to3 converts StringTypes to a tuple. Patch from Mark Hammond.
- Issue #24611: Fixed compiling the posix module on non-Windows platforms
- Issue #24611: Fixed compiling the posix module on non-Windows platforms
...
...
Modules/_randommodule.c
Dosyayı görüntüle @
3b77d01d
...
@@ -363,6 +363,10 @@ random_setstate(RandomObject *self, PyObject *state)
...
@@ -363,6 +363,10 @@ random_setstate(RandomObject *self, PyObject *state)
index
=
PyLong_AsLong
(
PyTuple_GET_ITEM
(
state
,
i
));
index
=
PyLong_AsLong
(
PyTuple_GET_ITEM
(
state
,
i
));
if
(
index
==
-
1
&&
PyErr_Occurred
())
if
(
index
==
-
1
&&
PyErr_Occurred
())
return
NULL
;
return
NULL
;
if
(
index
<
0
||
index
>
N
)
{
PyErr_SetString
(
PyExc_ValueError
,
"invalid state"
);
return
NULL
;
}
self
->
index
=
(
int
)
index
;
self
->
index
=
(
int
)
index
;
Py_INCREF
(
Py_None
);
Py_INCREF
(
Py_None
);
...
...
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