Skip to content

Commit 560fff3

Browse files
committed
Follow the PEP7 for the C Code
1 parent a7b624a commit 560fff3

File tree

1 file changed

+16
-8
lines changed

1 file changed

+16
-8
lines changed

Modules/_datetimemodule.c

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2884,17 +2884,20 @@ date_strptime(PyObject *cls, PyObject *args)
28842884

28852885
datetime = datetime_strptime((PyObject *)&PyDateTime_DateTimeType, args);
28862886

2887-
if (datetime == NULL)
2887+
if (datetime == NULL) {
28882888
return NULL;
2889+
}
28892890

28902891
if (DATE_GET_HOUR(datetime) ||
28912892
DATE_GET_MINUTE(datetime) ||
28922893
DATE_GET_SECOND(datetime) ||
2893-
DATE_GET_MICROSECOND(datetime))
2894+
DATE_GET_MICROSECOND(datetime)) {
28942895
PyErr_SetString(PyExc_ValueError,
28952896
"date.strptime value cannot have a time part");
2896-
else
2897+
}
2898+
else {
28972899
date = datetime_getdate((PyDateTime_DateTime *)datetime);
2900+
}
28982901

28992902
Py_DECREF(datetime);
29002903
return date;
@@ -3967,28 +3970,33 @@ time_strptime(PyObject *cls, PyObject *args)
39673970
*/
39683971
if (emptyDatetime == NULL) {
39693972
PyObject *emptyStringPair = Py_BuildValue("ss", "", "");
3970-
if (emptyStringPair == NULL)
3973+
if (emptyStringPair == NULL) {
39713974
return NULL;
3975+
}
39723976
emptyDatetime = datetime_strptime(
39733977
(PyObject *)&PyDateTime_DateTimeType,
39743978
emptyStringPair);
39753979
Py_DECREF(emptyStringPair);
3976-
if (emptyDatetime == NULL)
3980+
if (emptyDatetime == NULL) {
39773981
return NULL;
3982+
}
39783983
}
39793984

39803985
datetime = datetime_strptime((PyObject *)&PyDateTime_DateTimeType, args);
39813986

3982-
if (datetime == NULL)
3987+
if (datetime == NULL) {
39833988
return NULL;
3989+
}
39843990

39853991
if (GET_YEAR(datetime) != GET_YEAR(emptyDatetime)
39863992
|| GET_MONTH(datetime) != GET_MONTH(emptyDatetime)
3987-
|| GET_DAY(datetime) != GET_DAY(emptyDatetime))
3993+
|| GET_DAY(datetime) != GET_DAY(emptyDatetime)) {
39883994
PyErr_SetString(PyExc_ValueError,
39893995
"time.strptime value cannot have a date part");
3990-
else
3996+
}
3997+
else {
39913998
time = datetime_gettime((PyDateTime_DateTime *)datetime);
3999+
}
39924000

39934001
Py_DECREF(datetime);
39944002
return time;

0 commit comments

Comments
 (0)