Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(613)

Side by Side Diff: Modules/_datetimemodule.c

Issue 13847: Catch time(), ftime(), localtime() and clock() errors
Patch Set: Created 1 year, 4 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « Include/pytime.h ('k') | Modules/_randommodule.c » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* C implementation for the date/time type documented at 1 /* C implementation for the date/time type documented at
2 * http://www.zope.org/Members/fdrake/DateTimeWiki/FrontPage 2 * http://www.zope.org/Members/fdrake/DateTimeWiki/FrontPage
3 */ 3 */
4 4
5 #include "Python.h" 5 #include "Python.h"
6 #include "structmember.h" 6 #include "structmember.h"
7 7
8 #include <time.h> 8 #include <time.h>
9 9
10 #include "_time.h" 10 #include "_time.h"
(...skipping 4114 matching lines...) Expand 10 before | Expand all | Expand 10 after
4125 } 4125 }
4126 4126
4127 /* Internal helper. 4127 /* Internal helper.
4128 * Build most accurate possible datetime for current time. Pass localtime or 4128 * Build most accurate possible datetime for current time. Pass localtime or
4129 * gmtime for f as appropriate. 4129 * gmtime for f as appropriate.
4130 */ 4130 */
4131 static PyObject * 4131 static PyObject *
4132 datetime_best_possible(PyObject *cls, TM_FUNC f, PyObject *tzinfo) 4132 datetime_best_possible(PyObject *cls, TM_FUNC f, PyObject *tzinfo)
4133 { 4133 {
4134 _PyTime_timeval t; 4134 _PyTime_timeval t;
4135 _PyTime_gettimeofday(&t); 4135 if (_PyTime_gettimeofday(&t) == -1)
4136 return NULL;
4136 return datetime_from_timet_and_us(cls, f, t.tv_sec, (int)t.tv_usec, 4137 return datetime_from_timet_and_us(cls, f, t.tv_sec, (int)t.tv_usec,
4137 tzinfo); 4138 tzinfo);
4138 } 4139 }
4139 4140
4140 /* Return best possible local time -- this isn't constrained by the 4141 /* Return best possible local time -- this isn't constrained by the
4141 * precision of a timestamp. 4142 * precision of a timestamp.
4142 */ 4143 */
4143 static PyObject * 4144 static PyObject *
4144 datetime_now(PyObject *cls, PyObject *args, PyObject *kw) 4145 datetime_now(PyObject *cls, PyObject *args, PyObject *kw)
4145 { 4146 {
(...skipping 1277 matching lines...) Expand 10 before | Expand all | Expand 10 after
5423 enough to say. 5424 enough to say.
5424 5425
5425 In any case, it's clear that the default fromutc() is strong enough to handle 5426 In any case, it's clear that the default fromutc() is strong enough to handle
5426 "almost all" time zones: so long as the standard offset is invariant, it 5427 "almost all" time zones: so long as the standard offset is invariant, it
5427 doesn't matter if daylight time transition points change from year to year, or 5428 doesn't matter if daylight time transition points change from year to year, or
5428 if daylight time is skipped in some years; it doesn't matter how large or 5429 if daylight time is skipped in some years; it doesn't matter how large or
5429 small dst() may get within its bounds; and it doesn't even matter if some 5430 small dst() may get within its bounds; and it doesn't even matter if some
5430 perverse time zone returns a negative dst()). So a breaking case must be 5431 perverse time zone returns a negative dst()). So a breaking case must be
5431 pretty bizarre, and a tzinfo subclass can override fromutc() if it is. 5432 pretty bizarre, and a tzinfo subclass can override fromutc() if it is.
5432 --------------------------------------------------------------------------- */ 5433 --------------------------------------------------------------------------- */
OLDNEW
« no previous file with comments | « Include/pytime.h ('k') | Modules/_randommodule.c » ('j') | no next file with comments »

RSS Feeds Recent Issues | This issue
This is Rietveld cbc36f91f3f7