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
85fdfa85
Kaydet (Commit)
85fdfa85
authored
Ock 26, 2012
tarafından
Victor Stinner
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Issue #13847: time.clock() now raises a RuntimeError if the processor time used
is not available or its value cannot be represented
üst
e9cd9005
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
29 additions
and
12 deletions
+29
-12
NEWS
Misc/NEWS
+2
-1
timemodule.c
Modules/timemodule.c
+27
-11
No files found.
Misc/NEWS
Dosyayı görüntüle @
85fdfa85
...
...
@@ -463,7 +463,8 @@ Library
-
Issue
#
13847
:
time
.
localtime
()
and
time
.
gmtime
()
now
raise
an
OSError
instead
of
ValueError
on
failure
.
time
.
ctime
()
and
time
.
asctime
()
now
raises
an
OSError
if
localtime
()
failed
.
OSError
if
localtime
()
failed
.
time
.
clock
()
now
raises
a
RuntimeError
if
the
processor
time
used
is
not
available
or
its
value
cannot
be
represented
-
Issue
#
13862
:
Fix
spurious
failure
in
test_zlib
due
to
runtime
/
compile
time
minor
versions
not
matching
.
...
...
Modules/timemodule.c
Dosyayı görüntüle @
85fdfa85
...
...
@@ -62,6 +62,31 @@ PyDoc_STRVAR(time_doc,
Return the current time in seconds since the Epoch.
\n
\
Fractions of a second may be present if the system clock provides them."
);
#if defined(HAVE_CLOCK)
#ifndef CLOCKS_PER_SEC
#ifdef CLK_TCK
#define CLOCKS_PER_SEC CLK_TCK
#else
#define CLOCKS_PER_SEC 1000000
#endif
#endif
static
PyObject
*
pyclock
(
void
)
{
clock_t
value
;
value
=
clock
();
if
(
value
==
(
clock_t
)
-
1
)
{
PyErr_SetString
(
PyExc_RuntimeError
,
"the processor time used is not available "
"or its value cannot be represented"
);
return
NULL
;
}
return
PyFloat_FromDouble
((
double
)
value
/
CLOCKS_PER_SEC
);
}
#endif
/* HAVE_CLOCK */
#if defined(MS_WINDOWS) && !defined(__BORLANDC__)
/* Win32 has better clock replacement; we have our own version, due to Mark
Hammond and Tim Peters */
...
...
@@ -79,8 +104,7 @@ time_clock(PyObject *self, PyObject *unused)
if
(
!
QueryPerformanceFrequency
(
&
freq
)
||
freq
.
QuadPart
==
0
)
{
/* Unlikely to happen - this works on all intel
machines at least! Revert to clock() */
return
PyFloat_FromDouble
(((
double
)
clock
())
/
CLOCKS_PER_SEC
);
return
pyclock
();
}
divisor
=
(
double
)
freq
.
QuadPart
;
}
...
...
@@ -91,18 +115,10 @@ time_clock(PyObject *self, PyObject *unused)
#elif defined(HAVE_CLOCK)
#ifndef CLOCKS_PER_SEC
#ifdef CLK_TCK
#define CLOCKS_PER_SEC CLK_TCK
#else
#define CLOCKS_PER_SEC 1000000
#endif
#endif
static
PyObject
*
time_clock
(
PyObject
*
self
,
PyObject
*
unused
)
{
return
PyFloat_FromDouble
(((
double
)
clock
())
/
CLOCKS_PER_SEC
);
return
pyclock
(
);
}
#endif
/* HAVE_CLOCK */
...
...
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