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
214a7d26
Kaydet (Commit)
214a7d26
authored
Nis 13, 2013
tarafından
Benjamin Peterson
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
properly lookup the __round__ special method (closes #17722)
üst
c1ab0bd7
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
15 additions
and
15 deletions
+15
-15
test_descr.py
Lib/test/test_descr.py
+2
-1
NEWS
Misc/NEWS
+2
-0
bltinmodule.c
Python/bltinmodule.c
+11
-14
No files found.
Lib/test/test_descr.py
Dosyayı görüntüle @
214a7d26
...
...
@@ -1743,7 +1743,7 @@ order (MRO) for bases """
return
b
"hello"
def
empty_seq
(
self
):
return
[]
def
zero
(
self
):
def
zero
(
self
,
other
=
None
):
return
0
def
complex_num
(
self
):
return
1
j
...
...
@@ -1789,6 +1789,7 @@ order (MRO) for bases """
(
"__trunc__"
,
int
,
zero
,
set
(),
{}),
(
"__ceil__"
,
math
.
ceil
,
zero
,
set
(),
{}),
(
"__dir__"
,
dir
,
empty_seq
,
set
(),
{}),
(
"__round__"
,
round
,
zero
,
set
(),
{}),
]
class
Checker
(
object
):
...
...
Misc/NEWS
Dosyayı görüntüle @
214a7d26
...
...
@@ -10,6 +10,8 @@ What's New in Python 3.4.0 Alpha 1?
Core and Builtins
-----------------
- Issue #17722: When looking up __round__, resolve descriptors.
- Issue #16061: Speed up str.replace() for replacing 1-character strings.
- Issue #17715: Fix segmentation fault from raising an exception in a __trunc__
...
...
Python/bltinmodule.c
Dosyayı görüntüle @
214a7d26
...
...
@@ -1810,10 +1810,10 @@ For most object types, eval(repr(object)) == object.");
static
PyObject
*
builtin_round
(
PyObject
*
self
,
PyObject
*
args
,
PyObject
*
kwds
)
{
static
PyObject
*
round_str
=
NULL
;
PyObject
*
ndigits
=
NULL
;
static
char
*
kwlist
[]
=
{
"number"
,
"ndigits"
,
0
};
PyObject
*
number
,
*
round
;
PyObject
*
number
,
*
round
,
*
result
;
_Py_IDENTIFIER
(
__round__
);
if
(
!
PyArg_ParseTupleAndKeywords
(
args
,
kwds
,
"O|O:round"
,
kwlist
,
&
number
,
&
ndigits
))
...
...
@@ -1824,24 +1824,21 @@ builtin_round(PyObject *self, PyObject *args, PyObject *kwds)
return
NULL
;
}
if
(
round_str
==
NULL
)
{
round_str
=
PyUnicode_InternFromString
(
"__round__"
);
if
(
round_str
==
NULL
)
return
NULL
;
}
round
=
_PyType_Lookup
(
Py_TYPE
(
number
),
round_str
);
round
=
_PyObject_LookupSpecial
(
number
,
&
PyId___round__
);
if
(
round
==
NULL
)
{
PyErr_Format
(
PyExc_TypeError
,
"type %.100s doesn't define __round__ method"
,
Py_TYPE
(
number
)
->
tp_name
);
if
(
!
PyErr_Occurred
())
PyErr_Format
(
PyExc_TypeError
,
"type %.100s doesn't define __round__ method"
,
Py_TYPE
(
number
)
->
tp_name
);
return
NULL
;
}
if
(
ndigits
==
NULL
)
re
turn
PyObject_CallFunction
(
round
,
"O"
,
number
);
re
sult
=
PyObject_CallFunctionObjArgs
(
round
,
NULL
);
else
return
PyObject_CallFunction
(
round
,
"OO"
,
number
,
ndigits
);
result
=
PyObject_CallFunctionObjArgs
(
round
,
ndigits
,
NULL
);
Py_DECREF
(
round
);
return
result
;
}
PyDoc_STRVAR
(
round_doc
,
...
...
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