From 3a8a0ebfc91ae1c8cd54685930330cdaca2a1398 Mon Sep 17 00:00:00 2001 From: Ben Darnell Date: Sat, 19 Jan 2013 13:38:48 -0500 Subject: [PATCH] Remove conditional imports for py25. ssl, json, and multiprocessing are now ubiquitous. Also misc pyflakes cleanups (unused imports) --- tornado/auth.py | 1 - tornado/concurrent.py | 2 -- tornado/escape.py | 34 ++++----------------------------- tornado/httpserver.py | 6 +----- tornado/httputil.py | 1 - tornado/ioloop.py | 1 - tornado/iostream.py | 6 +----- tornado/netutil.py | 6 +----- tornado/platform/epoll.py | 1 - tornado/platform/twisted.py | 1 - tornado/process.py | 7 +------ tornado/simple_httpclient.py | 7 +------ tornado/test/httpclient_test.py | 1 - tornado/test/httpserver_test.py | 10 ++-------- tornado/test/iostream_test.py | 7 +------ tornado/test/template_test.py | 1 - tornado/test/testing_test.py | 1 - tornado/testing.py | 1 - tornado/wsgi.py | 3 +-- 19 files changed, 13 insertions(+), 84 deletions(-) diff --git a/tornado/auth.py b/tornado/auth.py index 6fa65442c..d158410a1 100644 --- a/tornado/auth.py +++ b/tornado/auth.py @@ -51,7 +51,6 @@ import binascii import hashlib import hmac import time -import urllib import uuid from tornado import httpclient diff --git a/tornado/concurrent.py b/tornado/concurrent.py index 14786b03b..8af16d73e 100644 --- a/tornado/concurrent.py +++ b/tornado/concurrent.py @@ -16,10 +16,8 @@ from __future__ import absolute_import, division, print_function, with_statement import functools -import sys from tornado.stack_context import ExceptionStackContext -from tornado.util import raise_exc_info try: from concurrent import futures diff --git a/tornado/escape.py b/tornado/escape.py index 6a2cbbb01..8b3e67b4c 100644 --- a/tornado/escape.py +++ b/tornado/escape.py @@ -30,10 +30,7 @@ from tornado.util import bytes_type, unicode_type, basestring_type, u try: from urllib.parse import parse_qs # py3 except ImportError: - try: - from urlparse import parse_qs # Python 2.6+ - except ImportError: - from cgi import parse_qs + from urlparse import parse_qs # Python 2.6+ try: import htmlentitydefs # py2 @@ -45,30 +42,7 @@ try: except ImportError: import urllib as urllib_parse # py2 -# json module is in the standard library as of python 2.6; fall back to -# simplejson if present for older versions. -try: - import json - assert hasattr(json, "loads") and hasattr(json, "dumps") - _json_decode = json.loads - _json_encode = json.dumps -except Exception: - try: - import simplejson - _json_decode = lambda s: simplejson.loads(_unicode(s)) - _json_encode = lambda v: simplejson.dumps(v) - except ImportError: - try: - # For Google AppEngine - from django.utils import simplejson - _json_decode = lambda s: simplejson.loads(_unicode(s)) - _json_encode = lambda v: simplejson.dumps(v) - except ImportError: - def _json_decode(s): - raise NotImplementedError( - "A JSON parser is required, e.g., simplejson at " - "http://pypi.python.org/pypi/simplejson/") - _json_encode = _json_decode +import json try: unichr @@ -98,12 +72,12 @@ def json_encode(value): # the javscript. Some json libraries do this escaping by default, # although python's standard library does not, so we do it here. # http://stackoverflow.com/questions/1580647/json-why-are-forward-slashes-escaped - return _json_encode(recursive_unicode(value)).replace("