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
8bb9cde6
Kaydet (Commit)
8bb9cde6
authored
Tem 01, 2010
tarafından
Benjamin Peterson
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
correctly lookup __trunc__ and __floor__
üst
6e73b197
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
17 additions
and
20 deletions
+17
-20
test_descr.py
Lib/test/test_descr.py
+3
-0
NEWS
Misc/NEWS
+3
-0
mathmodule.c
Modules/mathmodule.c
+11
-20
No files found.
Lib/test/test_descr.py
Dosyayı görüntüle @
8bb9cde6
import
builtins
import
builtins
import
sys
import
sys
import
types
import
types
import
math
import
unittest
import
unittest
from
copy
import
deepcopy
from
copy
import
deepcopy
...
@@ -1578,6 +1579,8 @@ order (MRO) for bases """
...
@@ -1578,6 +1579,8 @@ order (MRO) for bases """
(
"__exit__"
,
run_context
,
swallow
,
set
(),
{
"__enter__"
:
iden
}),
(
"__exit__"
,
run_context
,
swallow
,
set
(),
{
"__enter__"
:
iden
}),
(
"__complex__"
,
complex
,
complex_num
,
set
(),
{}),
(
"__complex__"
,
complex
,
complex_num
,
set
(),
{}),
(
"__format__"
,
format
,
format_impl
,
set
(),
{}),
(
"__format__"
,
format
,
format_impl
,
set
(),
{}),
(
"__floor__"
,
math
.
floor
,
zero
,
set
(),
{}),
(
"__trunc__"
,
math
.
trunc
,
zero
,
set
(),
{}),
]
]
class
Checker
(
object
):
class
Checker
(
object
):
...
...
Misc/NEWS
Dosyayı görüntüle @
8bb9cde6
...
@@ -1374,6 +1374,9 @@ Library
...
@@ -1374,6 +1374,9 @@ Library
Extension Modules
Extension Modules
-----------------
-----------------
- In the math module, correctly lookup __trunc__ and __floor__ as special
methods.
- Issue #9005: Prevent utctimetuple() from producing year 0 or year
- Issue #9005: Prevent utctimetuple() from producing year 0 or year
10,000. Prior to this change, timezone adjustment in utctimetuple()
10,000. Prior to this change, timezone adjustment in utctimetuple()
could produce tm_year value of 0 or 10,000. Now an OverflowError is
could produce tm_year value of 0 or 10,000. Now an OverflowError is
...
...
Modules/mathmodule.c
Dosyayı görüntüle @
8bb9cde6
...
@@ -883,17 +883,13 @@ static PyObject * math_floor(PyObject *self, PyObject *number) {
...
@@ -883,17 +883,13 @@ static PyObject * math_floor(PyObject *self, PyObject *number) {
static
PyObject
*
floor_str
=
NULL
;
static
PyObject
*
floor_str
=
NULL
;
PyObject
*
method
;
PyObject
*
method
;
if
(
floor_str
==
NULL
)
{
method
=
_PyObject_LookupSpecial
(
number
,
"__floor__"
,
&
floor_str
);
floor_str
=
PyUnicode_InternFromString
(
"__floor__"
);
if
(
method
==
NULL
)
{
if
(
floor_str
==
NULL
)
if
(
PyErr_Occurred
()
)
return
NULL
;
return
NULL
;
}
method
=
_PyType_Lookup
(
Py_TYPE
(
number
),
floor_str
);
if
(
method
==
NULL
)
return
math_1_to_int
(
number
,
floor
,
0
);
return
math_1_to_int
(
number
,
floor
,
0
);
else
}
return
PyObject_CallFunction
(
method
,
"O"
,
number
);
return
PyObject_CallFunctionObjArgs
(
method
,
NULL
);
}
}
PyDoc_STRVAR
(
math_floor_doc
,
PyDoc_STRVAR
(
math_floor_doc
,
...
@@ -1427,20 +1423,15 @@ math_trunc(PyObject *self, PyObject *number)
...
@@ -1427,20 +1423,15 @@ math_trunc(PyObject *self, PyObject *number)
return
NULL
;
return
NULL
;
}
}
if
(
trunc_str
==
NULL
)
{
trunc
=
_PyObject_LookupSpecial
(
number
,
"__trunc__"
,
&
trunc_str
);
trunc_str
=
PyUnicode_InternFromString
(
"__trunc__"
);
if
(
trunc_str
==
NULL
)
return
NULL
;
}
trunc
=
_PyType_Lookup
(
Py_TYPE
(
number
),
trunc_str
);
if
(
trunc
==
NULL
)
{
if
(
trunc
==
NULL
)
{
PyErr_Format
(
PyExc_TypeError
,
if
(
!
PyErr_Occurred
())
"type %.100s doesn't define __trunc__ method"
,
PyErr_Format
(
PyExc_TypeError
,
Py_TYPE
(
number
)
->
tp_name
);
"type %.100s doesn't define __trunc__ method"
,
Py_TYPE
(
number
)
->
tp_name
);
return
NULL
;
return
NULL
;
}
}
return
PyObject_CallFunctionObjArgs
(
trunc
,
number
,
NULL
);
return
PyObject_CallFunctionObjArgs
(
trunc
,
NULL
);
}
}
PyDoc_STRVAR
(
math_trunc_doc
,
PyDoc_STRVAR
(
math_trunc_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