File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1964,48 +1964,6 @@ imp_is_frozen(PyObject *self, PyObject *args)
19641964 return PyBool_FromLong ((long ) (p == NULL ? 0 : p -> size ));
19651965}
19661966
1967- static FILE *
1968- get_file (PyObject * pathname , PyObject * fob , char * mode )
1969- {
1970- FILE * fp ;
1971- if (mode [0 ] == 'U' )
1972- mode = "r" PY_STDIOTEXTMODE ;
1973- if (fob == NULL ) {
1974- fp = _Py_fopen (pathname , mode );
1975- if (!fp ) {
1976- if (!PyErr_Occurred ())
1977- PyErr_SetFromErrno (PyExc_IOError );
1978- return NULL ;
1979- }
1980- return fp ;
1981- }
1982- else {
1983- int fd = PyObject_AsFileDescriptor (fob );
1984- if (fd == -1 )
1985- return NULL ;
1986- if (!_PyVerify_fd (fd )) {
1987- PyErr_SetFromErrno (PyExc_IOError );
1988- return NULL ;
1989- }
1990-
1991- /* the FILE struct gets a new fd, so that it can be closed
1992- * independently of the file descriptor given
1993- */
1994- fd = dup (fd );
1995- if (fd == -1 ) {
1996- PyErr_SetFromErrno (PyExc_IOError );
1997- return NULL ;
1998- }
1999-
2000- fp = fdopen (fd , mode );
2001- if (!fp ) {
2002- PyErr_SetFromErrno (PyExc_IOError );
2003- return NULL ;
2004- }
2005- return fp ;
2006- }
2007- }
2008-
20091967#ifdef HAVE_DYNAMIC_LOADING
20101968
20111969static PyObject *
@@ -2018,9 +1976,11 @@ imp_load_dynamic(PyObject *self, PyObject *args)
20181976 & name , PyUnicode_FSDecoder , & pathname , & fob ))
20191977 return NULL ;
20201978 if (fob != NULL ) {
2021- fp = get_file ( NULL , fob , "r" );
1979+ fp = _Py_fopen ( pathname , "r" );
20221980 if (fp == NULL ) {
20231981 Py_DECREF (pathname );
1982+ if (!PyErr_Occurred ())
1983+ PyErr_SetFromErrno (PyExc_IOError );
20241984 return NULL ;
20251985 }
20261986 }
You can’t perform that action at this time.
0 commit comments