aboutsummaryrefslogtreecommitdiffstats
path: root/pkg_resources.py
diff options
context:
space:
mode:
authorJason R. Coombs <jaraco@jaraco.com>2014-09-18 07:21:24 -0400
committerJason R. Coombs <jaraco@jaraco.com>2014-09-18 07:21:24 -0400
commit8f56e928f03f69a5e787f830c04714467307601e (patch)
tree051fe9ef18f2e7b756fc3e99d36d5cfc79acafe4 /pkg_resources.py
parent26e4f9534a35fc13ec2c5e111e639d4af03e5644 (diff)
downloadexternal_python_setuptools-8f56e928f03f69a5e787f830c04714467307601e.tar.gz
external_python_setuptools-8f56e928f03f69a5e787f830c04714467307601e.tar.bz2
external_python_setuptools-8f56e928f03f69a5e787f830c04714467307601e.zip
Use PY3/PY2 indicators to reliably select behavior. Fixes #237
--HG-- extra : amend_source : 33f3d298acd39933ccf60810902feb2a5d51c793
Diffstat (limited to 'pkg_resources.py')
-rw-r--r--pkg_resources.py17
1 files changed, 9 insertions, 8 deletions
diff --git a/pkg_resources.py b/pkg_resources.py
index a0566688..5dcfd66e 100644
--- a/pkg_resources.py
+++ b/pkg_resources.py
@@ -38,16 +38,13 @@ from pkgutil import get_importer
PY3 = sys.version_info > (3,)
PY2 = not PY3
-try:
- from urlparse import urlparse, urlunparse
-except ImportError:
+if PY3:
from urllib.parse import urlparse, urlunparse
-try:
- basestring
- next = lambda o: o.next()
- from cStringIO import StringIO as BytesIO
-except NameError:
+if PY2:
+ from urlparse import urlparse, urlunparse
+
+if PY3:
basestring = str
from io import BytesIO
def execfile(fn, globs=None, locs=None):
@@ -57,6 +54,10 @@ except NameError:
locs = globs
exec(compile(open(fn).read(), fn, 'exec'), globs, locs)
+if PY2:
+ next = lambda o: o.next()
+ from cStringIO import StringIO as BytesIO
+
# capture these to bypass sandboxing
from os import utime
try: