Skip to content

Commit

Permalink
Check validity of year for Python 2.x since it doesn't do that itself…
Browse files Browse the repository at this point in the history
… like

Python 3.x does (#166).
  • Loading branch information
anthony-tuininga committed Mar 29, 2018
1 parent c61973c commit fac7f9c
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/cxoTransform.c
Original file line number Diff line number Diff line change
Expand Up @@ -681,6 +681,11 @@ PyObject *cxoTransform_toPython(cxoTransformNum transformNum,
case CXO_TRANSFORM_TIMESTAMP:
case CXO_TRANSFORM_TIMESTAMP_LTZ:
timestamp = &dbValue->asTimestamp;
#if PY_MAJOR_VERSION < 3
if (timestamp->year < 1 || timestamp->year > 9999)
return PyErr_Format(PyExc_ValueError,
"year %d is out of range", timestamp->year);
#endif
return PyDateTime_FromDateAndTime(timestamp->year,
timestamp->month, timestamp->day, timestamp->hour,
timestamp->minute, timestamp->second,
Expand Down

0 comments on commit fac7f9c

Please sign in to comment.