From bb00d41ff9423f4f1ebe34481d2475d93764a401 Mon Sep 17 00:00:00 2001 From: benoitc Date: Wed, 24 Oct 2012 23:08:15 +0200 Subject: [PATCH] fixes for py27 --- gunicorn/config.py | 2 -- gunicorn/six.py | 11 ++++++----- tests/treq.py | 4 ++-- 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/gunicorn/config.py b/gunicorn/config.py index e8f7fc32..41f176b0 100644 --- a/gunicorn/config.py +++ b/gunicorn/config.py @@ -137,8 +137,6 @@ class SettingMeta(type): setattr(cls, "short", desc.splitlines()[0]) class Setting(object): - __metaclass__ = SettingMeta - name = None value = None section = None diff --git a/gunicorn/six.py b/gunicorn/six.py index 9070e400..8f698d07 100644 --- a/gunicorn/six.py +++ b/gunicorn/six.py @@ -282,10 +282,6 @@ _add_doc(u, """Text literal""") if PY3: - def execfile_(fname, *args): - return exec(compile(open(fname, 'rb').read(), fname, 'exec'), *args) - - import builtins exec_ = getattr(builtins, "exec") @@ -296,6 +292,11 @@ if PY3: print_ = getattr(builtins, "print") + + def execfile_(fname, *args): + return exec_(compile(open(fname, 'rb').read(), fname, 'exec'), *args) + + del builtins else: @@ -395,4 +396,4 @@ else: urlparse = orig_urlparse.urlparse import urllib - urlunquote = urllib.unquote + unquote = urllib.unquote diff --git a/tests/treq.py b/tests/treq.py index 5ec54be3..072f0ae0 100644 --- a/tests/treq.py +++ b/tests/treq.py @@ -79,8 +79,8 @@ class request(object): yield lines def send_bytes(self): - for d in str(self.data, "latin1"): - yield bytes(d, "latin1") + for d in str(self.data.decode("latin1")): + yield bytes(d.encode("latin1")) def send_random(self): maxs = round(len(self.data) / 10)