Skip to content

Commit 12a6d94

Browse files
committed
Undo last commit. It's causing the tests to file.
1 parent c155dd4 commit 12a6d94

File tree

1 file changed

+0
-28
lines changed

1 file changed

+0
-28
lines changed

Objects/fileobject.c

-28
Original file line numberDiff line numberDiff line change
@@ -56,32 +56,6 @@ PyFile_Name(PyObject *f)
5656
return ((PyFileObject *)f)->f_name;
5757
}
5858

59-
/* On Unix, fopen will succeed for directories.
60-
In Python, there should be no file objects referring to
61-
directories, so we need a check. */
62-
63-
static PyFileObject*
64-
dircheck(PyFileObject* f)
65-
{
66-
#if defined(HAVE_FSTAT) && defined(S_IFDIR) && defined(EISDIR)
67-
struct stat buf;
68-
if (f->f_fp == NULL)
69-
return f;
70-
if (fstat(fileno(f->f_fp), &buf) == 0 &&
71-
S_ISDIR(buf.st_mode)) {
72-
#ifdef HAVE_STRERROR
73-
char *msg = strerror(EISDIR);
74-
#else
75-
char *msg = "Is a directory";
76-
#endif
77-
PyObject *exc = PyObject_CallFunction(PyExc_IOError, "(is)", EISDIR, msg);
78-
PyErr_SetObject(PyExc_IOError, exc);
79-
return NULL;
80-
}
81-
#endif
82-
return f;
83-
}
84-
8559

8660
static PyObject *
8761
fill_file_fields(PyFileObject *f, FILE *fp, char *name, char *mode,
@@ -103,7 +77,6 @@ fill_file_fields(PyFileObject *f, FILE *fp, char *name, char *mode,
10377
if (f->f_name == NULL || f->f_mode == NULL)
10478
return NULL;
10579
f->f_fp = fp;
106-
f = dircheck(f);
10780
return (PyObject *) f;
10881
}
10982

@@ -157,7 +130,6 @@ open_the_file(PyFileObject *f, char *name, char *mode)
157130
PyErr_SetFromErrnoWithFilename(PyExc_IOError, name);
158131
f = NULL;
159132
}
160-
f = dircheck(f);
161133
return (PyObject *)f;
162134
}
163135

0 commit comments

Comments
 (0)