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
28deea1f
Kaydet (Commit)
28deea1f
authored
Nis 06, 2011
tarafından
Alexander Belopolsky
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Sade Fark
Issue #11576: Fixed timedelta subtraction glitch on big timedelta values
üst
3bd9729d
b6f5ec73
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
19 additions
and
8 deletions
+19
-8
datetime.py
Lib/datetime.py
+5
-1
datetimetester.py
Lib/test/datetimetester.py
+6
-0
_datetimemodule.c
Modules/_datetimemodule.c
+8
-7
No files found.
Lib/datetime.py
Dosyayı görüntüle @
28deea1f
...
@@ -485,7 +485,11 @@ class timedelta:
...
@@ -485,7 +485,11 @@ class timedelta:
def
__sub__
(
self
,
other
):
def
__sub__
(
self
,
other
):
if
isinstance
(
other
,
timedelta
):
if
isinstance
(
other
,
timedelta
):
return
self
+
-
other
# for CPython compatibility, we cannot use
# our __class__ here, but need a real timedelta
return
timedelta
(
self
.
_days
-
other
.
_days
,
self
.
_seconds
-
other
.
_seconds
,
self
.
_microseconds
-
other
.
_microseconds
)
return
NotImplemented
return
NotImplemented
def
__rsub__
(
self
,
other
):
def
__rsub__
(
self
,
other
):
...
...
Lib/test/datetimetester.py
Dosyayı görüntüle @
28deea1f
...
@@ -383,6 +383,12 @@ class TestTimeDelta(HarmlessMixedComparison, unittest.TestCase):
...
@@ -383,6 +383,12 @@ class TestTimeDelta(HarmlessMixedComparison, unittest.TestCase):
for
i
in
range
(
-
10
,
10
):
for
i
in
range
(
-
10
,
10
):
eq
((
i
*
us
/-
3
)
//
us
,
round
(
i
/-
3
))
eq
((
i
*
us
/-
3
)
//
us
,
round
(
i
/-
3
))
# Issue #11576
eq
(
td
(
999999999
,
86399
,
999999
)
-
td
(
999999999
,
86399
,
999998
),
td
(
0
,
0
,
1
))
eq
(
td
(
999999999
,
1
,
1
)
-
td
(
999999999
,
1
,
0
),
td
(
0
,
0
,
1
))
def
test_disallowed_computations
(
self
):
def
test_disallowed_computations
(
self
):
a
=
timedelta
(
42
)
a
=
timedelta
(
42
)
...
...
Modules/_datetimemodule.c
Dosyayı görüntüle @
28deea1f
...
@@ -1801,13 +1801,14 @@ delta_subtract(PyObject *left, PyObject *right)
...
@@ -1801,13 +1801,14 @@ delta_subtract(PyObject *left, PyObject *right)
if
(
PyDelta_Check
(
left
)
&&
PyDelta_Check
(
right
))
{
if
(
PyDelta_Check
(
left
)
&&
PyDelta_Check
(
right
))
{
/* delta - delta */
/* delta - delta */
PyObject
*
minus_right
=
PyNumber_Negative
(
right
);
/* The C-level additions can't overflow because of the
if
(
minus_right
)
{
* invariant bounds.
result
=
delta_add
(
left
,
minus_right
);
*/
Py_DECREF
(
minus_right
);
int
days
=
GET_TD_DAYS
(
left
)
-
GET_TD_DAYS
(
right
);
}
int
seconds
=
GET_TD_SECONDS
(
left
)
-
GET_TD_SECONDS
(
right
);
else
int
microseconds
=
GET_TD_MICROSECONDS
(
left
)
-
result
=
NULL
;
GET_TD_MICROSECONDS
(
right
);
result
=
new_delta
(
days
,
seconds
,
microseconds
,
1
);
}
}
if
(
result
==
Py_NotImplemented
)
if
(
result
==
Py_NotImplemented
)
...
...
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