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
00e28431
Kaydet (Commit)
00e28431
authored
Ara 28, 2012
tarafından
Serhiy Storchaka
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Sade Fark
Issue #16761: Raise TypeError when int() called with base argument only.
üst
28441e35
0b386d52
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
13 additions
and
12 deletions
+13
-12
test_int.py
Lib/test/test_int.py
+2
-10
NEWS
Misc/NEWS
+3
-0
longobject.c
Objects/longobject.c
+8
-2
No files found.
Lib/test/test_int.py
Dosyayı görüntüle @
00e28431
...
@@ -233,16 +233,8 @@ class IntTestCases(unittest.TestCase):
...
@@ -233,16 +233,8 @@ class IntTestCases(unittest.TestCase):
self
.
assertEqual
(
int
(
x
=
1.2
),
1
)
self
.
assertEqual
(
int
(
x
=
1.2
),
1
)
self
.
assertEqual
(
int
(
'100'
,
base
=
2
),
4
)
self
.
assertEqual
(
int
(
'100'
,
base
=
2
),
4
)
self
.
assertEqual
(
int
(
x
=
'100'
,
base
=
2
),
4
)
self
.
assertEqual
(
int
(
x
=
'100'
,
base
=
2
),
4
)
self
.
assertRaises
(
TypeError
,
int
,
base
=
10
)
# For example, PyPy 1.9.0 raised TypeError for these cases because it
self
.
assertRaises
(
TypeError
,
int
,
base
=
0
)
# expects x to be a string if base is given.
@support.cpython_only
def
test_base_arg_with_no_x_arg
(
self
):
self
.
assertEqual
(
int
(
base
=
6
),
0
)
# Even invalid bases don't raise an exception.
self
.
assertEqual
(
int
(
base
=
1
),
0
)
self
.
assertEqual
(
int
(
base
=
1000
),
0
)
self
.
assertEqual
(
int
(
base
=
'foo'
),
0
)
def
test_non_numeric_input_types
(
self
):
def
test_non_numeric_input_types
(
self
):
# Test possible non-numeric types for the argument x, including
# Test possible non-numeric types for the argument x, including
...
...
Misc/NEWS
Dosyayı görüntüle @
00e28431
...
@@ -12,6 +12,9 @@ What's New in Python 3.3.1?
...
@@ -12,6 +12,9 @@ What's New in Python 3.3.1?
Core and Builtins
Core and Builtins
-----------------
-----------------
- Issue #16761: Calling ``int()`` with *base* argument only now raises
TypeError.
- Issue #16759: Support the full DWORD (unsigned long) range in Reg2Py
- Issue #16759: Support the full DWORD (unsigned long) range in Reg2Py
when retreiving a REG_DWORD value. This corrects functions like
when retreiving a REG_DWORD value. This corrects functions like
winreg.QueryValueEx that may have been returning truncated values.
winreg.QueryValueEx that may have been returning truncated values.
...
...
Objects/longobject.c
Dosyayı görüntüle @
00e28431
...
@@ -4267,8 +4267,14 @@ long_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
...
@@ -4267,8 +4267,14 @@ long_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
if
(
!
PyArg_ParseTupleAndKeywords
(
args
,
kwds
,
"|OO:int"
,
kwlist
,
if
(
!
PyArg_ParseTupleAndKeywords
(
args
,
kwds
,
"|OO:int"
,
kwlist
,
&
x
,
&
obase
))
&
x
,
&
obase
))
return
NULL
;
return
NULL
;
if
(
x
==
NULL
)
if
(
x
==
NULL
)
{
if
(
obase
!=
NULL
)
{
PyErr_SetString
(
PyExc_TypeError
,
"int() missing string argument"
);
return
NULL
;
}
return
PyLong_FromLong
(
0L
);
return
PyLong_FromLong
(
0L
);
}
if
(
obase
==
NULL
)
if
(
obase
==
NULL
)
return
PyNumber_Long
(
x
);
return
PyNumber_Long
(
x
);
...
@@ -4277,7 +4283,7 @@ long_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
...
@@ -4277,7 +4283,7 @@ long_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
return
NULL
;
return
NULL
;
if
(
overflow
||
(
base
!=
0
&&
base
<
2
)
||
base
>
36
)
{
if
(
overflow
||
(
base
!=
0
&&
base
<
2
)
||
base
>
36
)
{
PyErr_SetString
(
PyExc_ValueError
,
PyErr_SetString
(
PyExc_ValueError
,
"int()
arg 2
must be >= 2 and <= 36"
);
"int()
base
must be >= 2 and <= 36"
);
return
NULL
;
return
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