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
0dd06f40
Kaydet (Commit)
0dd06f40
authored
Ock 08, 2011
tarafından
Alexander Belopolsky
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Fixed error handling branches. Thanks
Victor Stinner for pointing this out.
üst
b8bb4664
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
31 additions
and
15 deletions
+31
-15
test_time.py
Lib/test/test_time.py
+12
-1
timemodule.c
Modules/timemodule.c
+19
-14
No files found.
Lib/test/test_time.py
Dosyayı görüntüle @
0dd06f40
...
...
@@ -308,13 +308,24 @@ class TestDontAccept2Year(TestAccept2Year):
def
test_invalid
(
self
):
pass
class
TestAccept2YearBad
(
TestAccept2Year
):
class
X
:
def
__bool__
(
self
):
raise
RuntimeError
(
'boo'
)
accept2dyear
=
X
()
def
test_2dyear
(
self
):
pass
def
test_invalid
(
self
):
self
.
assertRaises
(
RuntimeError
,
self
.
yearstr
,
200
)
class
TestDontAccept2YearBool
(
TestDontAccept2Year
):
accept2dyear
=
False
def
test_main
():
support
.
run_unittest
(
TimeTestCase
,
TestLocale
,
TestAccept2Year
,
TestAccept2YearBool
,
TestAccept2Year
,
TestAccept2YearBool
,
TestAccept2YearBad
,
TestDontAccept2Year
,
TestDontAccept2YearBool
)
if
__name__
==
"__main__"
:
...
...
Modules/timemodule.c
Dosyayı görüntüle @
0dd06f40
...
...
@@ -332,23 +332,27 @@ gettmarg(PyObject *args, struct tm *p)
if
(
y
<
1000
)
{
PyObject
*
accept
=
PyDict_GetItemString
(
moddict
,
"accept2dyear"
);
int
acceptval
=
accept
!=
NULL
&&
PyObject_IsTrue
(
accept
);
if
(
acceptval
==
-
1
)
return
0
;
if
(
acceptval
)
{
if
(
0
<=
y
&&
y
<
69
)
y
+=
2000
;
else
if
(
69
<=
y
&&
y
<
100
)
y
+=
1900
;
else
{
PyErr_SetString
(
PyExc_ValueError
,
"year out of range"
);
if
(
accept
!=
NULL
)
{
int
acceptval
=
PyObject_IsTrue
(
accept
);
if
(
acceptval
==
-
1
)
return
0
;
if
(
acceptval
)
{
if
(
0
<=
y
&&
y
<
69
)
y
+=
2000
;
else
if
(
69
<=
y
&&
y
<
100
)
y
+=
1900
;
else
{
PyErr_SetString
(
PyExc_ValueError
,
"year out of range"
);
return
0
;
}
if
(
PyErr_WarnEx
(
PyExc_DeprecationWarning
,
"Century info guessed for a 2-digit year."
,
1
)
!=
0
)
return
0
;
}
if
(
PyErr_WarnEx
(
PyExc_DeprecationWarning
,
"Century info guessed for a 2-digit year."
,
1
)
!=
0
)
return
0
;
}
else
return
0
;
}
p
->
tm_year
=
y
-
1900
;
p
->
tm_mon
--
;
...
...
@@ -477,6 +481,7 @@ time_strftime(PyObject *self, PyObject *args)
PyErr_Format
(
PyExc_ValueError
,
"year=%d is before 1900; "
"the strftime() method requires year >= 1900"
,
buf
.
tm_year
+
1900
);
return
NULL
;
}
/* Normalize tm_isdst just in case someone foolishly implements %Z
...
...
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