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
d6ac380d
Commit
d6ac380d
authored
Jul 07, 1995
by
Guido van Rossum
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix bug in example (should close file at all times)
parent
6b686e94
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
26 additions
and
20 deletions
+26
-20
Doc/lib/libimp.tex
Doc/lib/libimp.tex
+13
-10
Doc/libimp.tex
Doc/libimp.tex
+13
-10
No files found.
Doc/lib/libimp.tex
View file @
d6ac380d
...
...
@@ -158,14 +158,17 @@ def __import__(name, globals=None, locals=None, fromlist=None):
fp, pathname, (suffix, mode, type) = imp.find
_
module(name)
# See what we got.
# Note that fp will be closed automatically when we return.
if type == imp.C
_
EXTENSION:
return imp.load
_
dynamic(name, pathname)
if type == imp.PY
_
SOURCE:
return imp.load
_
source(name, pathname, fp)
if type == imp.PY
_
COMPILED:
return imp.load
_
compiled(name, pathname, fp)
# Shouldn't get here at all.
raise ImportError, '
%s: unknown module type (%d)' % (name, type)
try:
if type == imp.C
_
EXTENSION:
return imp.load
_
dynamic(name, pathname)
if type == imp.PY
_
SOURCE:
return imp.load
_
source(name, pathname, fp)
if type == imp.PY
_
COMPILED:
return imp.load
_
compiled(name, pathname, fp)
# Shouldn't get here at all.
raise ImportError, '
%s: unknown module type (%d)' % (name, type)
finally:
# Since we may exit via an exception, close fp explicitly.
fp.close()
\end{verbatim}
Doc/libimp.tex
View file @
d6ac380d
...
...
@@ -158,14 +158,17 @@ def __import__(name, globals=None, locals=None, fromlist=None):
fp, pathname, (suffix, mode, type) = imp.find
_
module(name)
# See what we got.
# Note that fp will be closed automatically when we return.
if type == imp.C
_
EXTENSION:
return imp.load
_
dynamic(name, pathname)
if type == imp.PY
_
SOURCE:
return imp.load
_
source(name, pathname, fp)
if type == imp.PY
_
COMPILED:
return imp.load
_
compiled(name, pathname, fp)
# Shouldn't get here at all.
raise ImportError, '
%s: unknown module type (%d)' % (name, type)
try:
if type == imp.C
_
EXTENSION:
return imp.load
_
dynamic(name, pathname)
if type == imp.PY
_
SOURCE:
return imp.load
_
source(name, pathname, fp)
if type == imp.PY
_
COMPILED:
return imp.load
_
compiled(name, pathname, fp)
# Shouldn't get here at all.
raise ImportError, '
%s: unknown module type (%d)' % (name, type)
finally:
# Since we may exit via an exception, close fp explicitly.
fp.close()
\end{verbatim}
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