From: Ben Darnell Date: Mon, 14 Jan 2013 02:19:45 +0000 (-0500) Subject: Get autoreload working in py3 without 2to3. X-Git-Tag: v3.0.0~179 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ed786510578dafb94794a2e1d21eadd0c02aa9e9;p=thirdparty%2Ftornado.git Get autoreload working in py3 without 2to3. --- diff --git a/tornado/autoreload.py b/tornado/autoreload.py index 7aa153c18..e7b86f055 100644 --- a/tornado/autoreload.py +++ b/tornado/autoreload.py @@ -79,6 +79,7 @@ import weakref from tornado import ioloop from tornado.log import gen_log from tornado import process +from tornado.util import exec_in try: import signal @@ -277,7 +278,7 @@ def main(): # Use globals as our "locals" dictionary so that # something that tries to import __main__ (e.g. the unittest # module) will see the right things. - exec f.read() in globals(), globals() + exec_in(f.read(), globals(), globals()) except SystemExit as e: logging.basicConfig() gen_log.info("Script exited with status %s", e.code) diff --git a/tornado/ioloop.py b/tornado/ioloop.py index d114107e3..3b6f27696 100644 --- a/tornado/ioloop.py +++ b/tornado/ioloop.py @@ -33,6 +33,7 @@ import errno import functools import heapq import logging +import numbers import os import select import sys @@ -654,7 +655,7 @@ class _Timeout(object): __slots__ = ['deadline', 'callback'] def __init__(self, deadline, callback, io_loop): - if isinstance(deadline, (int, long, float)): + if isinstance(deadline, numbers.Real): self.deadline = deadline elif isinstance(deadline, datetime.timedelta): self.deadline = io_loop.time() + _Timeout.timedelta_to_seconds(deadline) diff --git a/tornado/util.py b/tornado/util.py index 3a7a0bfd2..988331d9e 100644 --- a/tornado/util.py +++ b/tornado/util.py @@ -114,16 +114,16 @@ if sys.version_info > (3,): def raise_exc_info(exc_info): raise exc_info[1].with_traceback(exc_info[2]) -def exec_in(code, namespace): - exec(code, namespace) +def exec_in(code, glob, loc=None): + exec(code, glob, loc) """) else: exec(""" def raise_exc_info(exc_info): raise exc_info[0], exc_info[1], exc_info[2] -def exec_in(code, namespace): - exec code in namespace +def exec_in(code, glob, loc=None): + exec code in glob, loc """) class Configurable(object):