Skip to content
This repository was archived by the owner on May 27, 2025. It is now read-only.

Commit f31073a

Browse files
committed
Remove unnecessary allow_fd to avoid PyLong_AsLongAndOverflow which doesn't exist on Python 2.6
1 parent 39432b8 commit f31073a

File tree

1 file changed

+0
-48
lines changed

1 file changed

+0
-48
lines changed

_scandir.c

Lines changed: 0 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -713,37 +713,6 @@ static PyStructSequence_Desc stat_result_desc = {
713713
};
714714

715715

716-
static int
717-
_fd_converter(PyObject *o, int *p, const char *allowed)
718-
{
719-
int overflow;
720-
long long_value;
721-
722-
PyObject *index = PyNumber_Index(o);
723-
if (index == NULL) {
724-
PyErr_Format(PyExc_TypeError,
725-
"argument should be %s, not %.200s",
726-
allowed, Py_TYPE(o)->tp_name);
727-
return 0;
728-
}
729-
730-
long_value = PyLong_AsLongAndOverflow(index, &overflow);
731-
Py_DECREF(index);
732-
if (overflow > 0 || long_value > INT_MAX) {
733-
PyErr_SetString(PyExc_OverflowError,
734-
"fd is greater than maximum");
735-
return 0;
736-
}
737-
if (overflow < 0 || long_value < INT_MIN) {
738-
PyErr_SetString(PyExc_OverflowError,
739-
"fd is less than minimum");
740-
return 0;
741-
}
742-
743-
*p = (int)long_value;
744-
return 1;
745-
}
746-
747716
#ifdef MS_WINDOWS
748717
static int
749718
win32_warn_bytes_api()
@@ -759,7 +728,6 @@ typedef struct {
759728
const char *function_name;
760729
const char *argument_name;
761730
int nullable;
762-
int allow_fd;
763731
wchar_t *wide;
764732
char *narrow;
765733
int fd;
@@ -768,9 +736,6 @@ typedef struct {
768736
PyObject *cleanup;
769737
} path_t;
770738

771-
#define PATH_T_INITIALIZE(function_name, argument_name, nullable, allow_fd) \
772-
{function_name, argument_name, nullable, allow_fd, NULL, NULL, -1, 0, NULL, NULL}
773-
774739
static void
775740
path_cleanup(path_t *path) {
776741
if (path->cleanup) {
@@ -868,19 +833,6 @@ path_converter(PyObject *o, void *p) {
868833
bytes = NULL;
869834
if (!bytes) {
870835
PyErr_Clear();
871-
if (path->allow_fd) {
872-
int fd;
873-
int result = _fd_converter(o, &fd,
874-
"string, bytes or integer");
875-
if (result) {
876-
path->wide = NULL;
877-
path->narrow = NULL;
878-
path->length = 0;
879-
path->object = o;
880-
path->fd = fd;
881-
return result;
882-
}
883-
}
884836
}
885837
}
886838

0 commit comments

Comments
 (0)