Skip to content

Commit

Permalink
capitialize utime statuses
Browse files Browse the repository at this point in the history
  • Loading branch information
benjaminp committed May 25, 2012
1 parent f09c2e9 commit cb98f69
Showing 1 changed file with 20 additions and 20 deletions.
40 changes: 20 additions & 20 deletions Modules/posixmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -3661,11 +3661,11 @@ typedef struct {
*/

typedef enum {
utime_success = 0,
utime_parse_failure = 1,
utime_times_and_ns_collision = 2,
utime_times_conversion_failure = 3,
utime_ns_conversion_failure = 4,
UTIME_SUCCESS = 0,
UTIME_PARSE_FAILURE = 1,
UTIME_TIMES_AND_NS_COLLISION = 2,
UTIME_TIMES_CONVERSION_FAILURE = 3,
UTIME_NS_CONVERSION_FAILURE = 4,
} utime_status;

static utime_status
Expand Down Expand Up @@ -3697,14 +3697,14 @@ utime_read_time_arguments(utime_arguments *ua)
format, kwlist, ua->path, &times, &ns);

if (!parse_result)
return utime_parse_failure;
return UTIME_PARSE_FAILURE;

if (times && ns) {
PyErr_Format(PyExc_RuntimeError,
"%s: you may specify either 'times'"
" or 'ns' but not both",
ua->function_name);
return_value = utime_times_and_ns_collision;
return_value = UTIME_TIMES_AND_NS_COLLISION;
goto fail;
}

Expand All @@ -3714,42 +3714,42 @@ utime_read_time_arguments(utime_arguments *ua)
"%s: 'times' must be either"
" a tuple of two ints or None",
ua->function_name);
return_value = utime_times_conversion_failure;
return_value = UTIME_TIMES_CONVERSION_FAILURE;
goto fail;
}
ua->now = 0;
if (_PyTime_ObjectToTimespec(PyTuple_GET_ITEM(times, 0),
&ua->atime_s, &ua->atime_ns) == -1 ||
_PyTime_ObjectToTimespec(PyTuple_GET_ITEM(times, 1),
&ua->mtime_s, &ua->mtime_ns) == -1) {
return_value = utime_times_conversion_failure;
return_value = UTIME_TIMES_CONVERSION_FAILURE;
goto fail;
}
return utime_success;
return UTIME_SUCCESS;
}

if (ns) {
if (!PyTuple_CheckExact(ns) || (PyTuple_Size(ns) != 2)) {
PyErr_Format(PyExc_TypeError,
"%s: 'ns' must be a tuple of two ints",
ua->function_name);
return_value = utime_ns_conversion_failure;
return_value = UTIME_NS_CONVERSION_FAILURE;
goto fail;
}
ua->now = 0;
if (!split_py_long_to_s_and_ns(PyTuple_GET_ITEM(ns, 0),
&ua->atime_s, &ua->atime_ns) ||
!split_py_long_to_s_and_ns(PyTuple_GET_ITEM(ns, 1),
&ua->mtime_s, &ua->mtime_ns)) {
return_value = utime_ns_conversion_failure;
return_value = UTIME_NS_CONVERSION_FAILURE;
goto fail;
}
return utime_success;
return UTIME_SUCCESS;
}

/* either times=None, or neither times nor ns was specified. use "now". */
ua->now = 1;
return utime_success;
return UTIME_SUCCESS;

fail:
if (ua->converter)
Expand Down Expand Up @@ -3786,7 +3786,7 @@ posix_utime(PyObject *self, PyObject *args, PyObject *kwargs)
switch (utime_read_time_arguments(&ua)) {
default:
return NULL;
case utime_success: {
case UTIME_SUCCESS: {
wchar_t *wpath = PyUnicode_AsUnicode(upath);
if (wpath == NULL)
return NULL;
Expand All @@ -3799,15 +3799,15 @@ posix_utime(PyObject *self, PyObject *args, PyObject *kwargs)
return win32_error_object("utime", upath);
break;
}
case utime_parse_failure: {
case UTIME_PARSE_FAILURE: {
const char *apath;
/* Drop the argument parsing error as narrow strings
are also valid. */
PyErr_Clear();

ua.path_format = 'y';
ua.path = (PyObject **)&apath;
if (utime_read_time_arguments(&ua) != utime_success)
if (utime_read_time_arguments(&ua) != UTIME_SUCCESS)
return NULL;
if (win32_warn_bytes_api())
return NULL;
Expand Down Expand Up @@ -3862,7 +3862,7 @@ posix_utime(PyObject *self, PyObject *args, PyObject *kwargs)
ua.path = &opath;
ua.converter = PyUnicode_FSConverter;

if (utime_read_time_arguments(&ua) != utime_success)
if (utime_read_time_arguments(&ua) != UTIME_SUCCESS)
return NULL;
path = PyBytes_AsString(opath);
if (ua.now) {
Expand Down Expand Up @@ -3915,7 +3915,7 @@ posix_futimes(PyObject *self, PyObject *args, PyObject *kwargs)
ua.path = (PyObject **)&fd;
ua.first_argument_name = "fd";

if (utime_read_time_arguments(&ua) != utime_success)
if (utime_read_time_arguments(&ua) != UTIME_SUCCESS)
return NULL;

if (ua.now) {
Expand Down Expand Up @@ -3960,7 +3960,7 @@ posix_lutimes(PyObject *self, PyObject *args, PyObject *kwargs)
ua.path = &opath;
ua.converter = PyUnicode_FSConverter;

if (utime_read_time_arguments(&ua) != utime_success)
if (utime_read_time_arguments(&ua) != UTIME_SUCCESS)
return NULL;
path = PyBytes_AsString(opath);

Expand Down

0 comments on commit cb98f69

Please sign in to comment.