Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
f3a42dee
Commit
f3a42dee
authored
May 04, 2012
by
Antoine Pitrou
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Simplify code for load_dynamic()
parent
149e255e
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
3 additions
and
43 deletions
+3
-43
Python/import.c
Python/import.c
+3
-43
No files found.
Python/import.c
View file @
f3a42dee
...
...
@@ -1964,48 +1964,6 @@ imp_is_frozen(PyObject *self, PyObject *args)
return
PyBool_FromLong
((
long
)
(
p
==
NULL
?
0
:
p
->
size
));
}
static
FILE
*
get_file
(
PyObject
*
pathname
,
PyObject
*
fob
,
char
*
mode
)
{
FILE
*
fp
;
if
(
mode
[
0
]
==
'U'
)
mode
=
"r"
PY_STDIOTEXTMODE
;
if
(
fob
==
NULL
)
{
fp
=
_Py_fopen
(
pathname
,
mode
);
if
(
!
fp
)
{
if
(
!
PyErr_Occurred
())
PyErr_SetFromErrno
(
PyExc_IOError
);
return
NULL
;
}
return
fp
;
}
else
{
int
fd
=
PyObject_AsFileDescriptor
(
fob
);
if
(
fd
==
-
1
)
return
NULL
;
if
(
!
_PyVerify_fd
(
fd
))
{
PyErr_SetFromErrno
(
PyExc_IOError
);
return
NULL
;
}
/* the FILE struct gets a new fd, so that it can be closed
* independently of the file descriptor given
*/
fd
=
dup
(
fd
);
if
(
fd
==
-
1
)
{
PyErr_SetFromErrno
(
PyExc_IOError
);
return
NULL
;
}
fp
=
fdopen
(
fd
,
mode
);
if
(
!
fp
)
{
PyErr_SetFromErrno
(
PyExc_IOError
);
return
NULL
;
}
return
fp
;
}
}
#ifdef HAVE_DYNAMIC_LOADING
static
PyObject
*
...
...
@@ -2018,9 +1976,11 @@ imp_load_dynamic(PyObject *self, PyObject *args)
&
name
,
PyUnicode_FSDecoder
,
&
pathname
,
&
fob
))
return
NULL
;
if
(
fob
!=
NULL
)
{
fp
=
get_file
(
NULL
,
fob
,
"r"
);
fp
=
_Py_fopen
(
pathname
,
"r"
);
if
(
fp
==
NULL
)
{
Py_DECREF
(
pathname
);
if
(
!
PyErr_Occurred
())
PyErr_SetFromErrno
(
PyExc_IOError
);
return
NULL
;
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment