Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
setuptools
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
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jérome Perrin
setuptools
Commits
773f1ec3
Commit
773f1ec3
authored
Oct 27, 2019
by
Jason R. Coombs
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Rely on contextlib.closing for brevity.
parent
85a9ca5e
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
5 deletions
+13
-5
setuptools/depends.py
setuptools/depends.py
+13
-5
No files found.
setuptools/depends.py
View file @
773f1ec3
import
sys
import
marshal
import
contextlib
from
distutils.version
import
StrictVersion
from
.py33compat
import
Bytecode
...
...
@@ -81,6 +82,17 @@ class Require:
return
self
.
version_ok
(
version
)
def
maybe_close
(
f
):
@
contextlib
.
contextmanager
def
empty
():
yield
return
if
not
f
:
return
empty
()
return
contextlib
.
closing
(
f
)
def
get_module_constant
(
module
,
symbol
,
default
=-
1
,
paths
=
None
):
"""Find 'module' by searching 'paths', and extract 'symbol'
...
...
@@ -94,7 +106,7 @@ def get_module_constant(module, symbol, default=-1, paths=None):
# Module doesn't exist
return
None
try
:
with
maybe_close
(
f
)
:
if
kind
==
PY_COMPILED
:
f
.
read
(
8
)
# skip magic & date
code
=
marshal
.
load
(
f
)
...
...
@@ -107,10 +119,6 @@ def get_module_constant(module, symbol, default=-1, paths=None):
imported
=
py27compat
.
get_module
(
module
,
paths
,
info
)
return
getattr
(
imported
,
symbol
,
None
)
finally
:
if
f
:
f
.
close
()
return
extract_constant
(
code
,
symbol
,
default
)
...
...
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