8000 MAINT: Removed conditionals that are always false in datetime_strings.c by kawochen · Pull Request #7102 · numpy/numpy · GitHub
[go: up one dir, main page]

Skip to content

MAINT: Removed conditionals that are always false in datetime_strings.c #7102

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 29, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
MAINT: Removed conditionals that are always true in datetime_strings.c
  • Loading branch information
kawochen committed Jan 23, 2016
commit 5d1d6142ba2b6c9640c4a5b71a7ee7392d5ce176
6 changes: 3 additions & 3 deletions numpy/core/src/multiarray/datetime_strings.c
Original file line number Diff line number Diff line change
Expand Up @@ -484,7 +484,7 @@ parse_iso_8601_datetime(char *str, Py_ssize_t len,
if (sublen >= 2 && isdigit(substr[0]) && isdigit(substr[1])) {
out->hour = 10 * (substr[0] - '0') + (substr[1] - '0');
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

substr[0] and substr[1] are char digits (isdigit), of which '0' is the smallest, so out->hour can only be as small as 10 * 0 + 0 = 0


if (out->hour < 0 || out->hour >= 24) {
if (out->hour >= 24) {
PyErr_Format(PyExc_ValueError,
"Hours out of range in datetime string \"%s\"", str);
goto error;
Expand Down Expand Up @@ -515,7 +515,7 @@ parse_iso_8601_datetime(char *str, Py_ssize_t len,
if (sublen >= 2 && isdigit(substr[0]) && isdigit(substr[1])) {
out->min = 10 * (substr[0] - '0') + (substr[1] - '0');

if (out->hour < 0 || out->min >= 60) {
if (out->min >= 60) {
PyErr_Format(PyExc_ValueError,
"Minutes out of range in datetime string \"%s\"", str);
goto error;
Expand Down Expand Up @@ -546,7 +546,7 @@ parse_iso_8601_datetime(char *str, Py_ssize_t len,
if (sublen >= 2 && isdigit(substr[0]) && isdigit(substr[1])) {
out->sec = 10 * (substr[0] - '0') + (substr[1] - '0');

if (out->sec < 0 || out->sec >= 60) {
if (out->sec >= 60) {
PyErr_Format(PyExc_ValueError,
"Seconds out of range in datetime string \"%s\"", str);
goto error;
Expand Down
0