diff options
author | Jason R. Coombs <jaraco@jaraco.com> | 2014-09-18 07:31:09 -0400 |
---|---|---|
committer | Jason R. Coombs <jaraco@jaraco.com> | 2014-09-18 07:31:09 -0400 |
commit | 5d3002955232bb6a2b83faee486cd362dbbf8fa3 (patch) | |
tree | 3a5c3f6e08d9e514d36e5dafb7f0960705674085 | |
parent | a2201d3d5a74ea034caf2f6eeeb877708e9017bf (diff) | |
download | external_python_setuptools-5d3002955232bb6a2b83faee486cd362dbbf8fa3.tar.gz external_python_setuptools-5d3002955232bb6a2b83faee486cd362dbbf8fa3.tar.bz2 external_python_setuptools-5d3002955232bb6a2b83faee486cd362dbbf8fa3.zip |
Use the term 'string_types', following the pattern in six
--HG--
extra : amend_source : 3a4aeb2627549c3dfec15067579eccc8e1314de2
-rw-r--r-- | pkg_resources.py | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/pkg_resources.py b/pkg_resources.py index d8c73320..825b3004 100644 --- a/pkg_resources.py +++ b/pkg_resources.py @@ -46,13 +46,15 @@ if PY2: from urlparse import urlparse, urlunparse if PY3: - basestring = str + string_types = str, def execfile(fn, globs=None, locs=None): if globs is None: globs = globals() if locs is None: locs = globs exec(compile(open(fn).read(), fn, 'exec'), globs, locs) +else: + string_types = str, eval('unicode') # capture these to bypass sandboxing from os import utime @@ -330,7 +332,7 @@ run_main = run_script def get_distribution(dist): """Return a current distribution object for a Requirement or string""" - if isinstance(dist, basestring): + if isinstance(dist, string_types): dist = Requirement.parse(dist) if isinstance(dist, Requirement): dist = get_provider(dist) @@ -2050,8 +2052,8 @@ def _set_parent_ns(packageName): def yield_lines(strs): - """Yield non-empty/non-comment lines of a ``basestring`` or sequence""" - if isinstance(strs, basestring): + """Yield non-empty/non-comment lines of a string or sequence""" + if isinstance(strs, string_types): for s in strs.splitlines(): s = s.strip() # skip blank lines/comments @@ -2643,8 +2645,7 @@ def issue_warning(*args,**kw): def parse_requirements(strs): """Yield ``Requirement`` objects for each specification in `strs` - `strs` must be an instance of ``basestring``, or a (possibly-nested) - iterable thereof. + `strs` must be a string, or a (possibly-nested) iterable thereof. """ # create a steppable iterator, so we can handle \-continuations lines = iter(yield_lines(strs)) @@ -2745,7 +2746,7 @@ class Requirement: # only get if we need it if self.index: item = item.parsed_version - elif isinstance(item, basestring): + elif isinstance(item, string_types): item = parse_version(item) last = None # -1, 0, 1 |