diff --git a/gluon/import_all.py b/gluon/import_all.py index f350f61d..a8cbffc6 100644 --- a/gluon/import_all.py +++ b/gluon/import_all.py @@ -79,15 +79,14 @@ alert_dependency = ['hashlib', 'uuid'] # python version. # # List of modules deprecated in Python 2.6 or 2.7 that are in the above set -py26_deprecated = ['mhlib', 'multifile', 'mimify', 'sets', 'MimeWriter'] -py27_deprecated = [] # ['optparse'] but we need it for now +py27_deprecated = ['mhlib', 'multifile', 'mimify', 'sets', 'MimeWriter'] # And ['optparse'] but we need it for now if python_version >= '2.6': base_modules += ['json', 'multiprocessing'] base_modules = list(set(base_modules).difference(set(py26_deprecated))) if python_version >= '2.7': - base_modules += ['argparse'] + base_modules += ['argparse', 'json', 'multiprocessing'] base_modules = list(set(base_modules).difference(set(py27_deprecated))) # Now iterate in the base_modules, trying to do the import diff --git a/gluon/restricted.py b/gluon/restricted.py index 7a592d84..e7e3f9cf 100644 --- a/gluon/restricted.py +++ b/gluon/restricted.py @@ -236,6 +236,7 @@ def restricted(code, environment=None, layer='Unknown'): # XXX Show exception in Wing IDE if running in debugger if __debug__ and 'WINGDB_ACTIVE' in os.environ: sys.excepthook(etype, evalue, tb) + del tb output = "%s %s" % (etype, evalue) raise RestrictedError(layer, code, output, environment) @@ -261,6 +262,7 @@ def snapshot(info=None, context=5, code=None, environment=None): # start to process frames records = inspect.getinnerframes(etb, context) + del etb # Prevent circular references that would cause memory leaks s['frames'] = [] for frame, file, lnum, func, lines, index in records: file = file and os.path.abspath(file) or '?' @@ -319,10 +321,8 @@ def snapshot(info=None, context=5, code=None, environment=None): s['exception'] = {} if isinstance(evalue, BaseException): for name in dir(evalue): - # prevent py26 DeprecatedWarning: - if name != 'message' or sys.version_info < (2.6): - value = pydoc.text.repr(getattr(evalue, name)) - s['exception'][name] = value + value = pydoc.text.repr(getattr(evalue, name)) + s['exception'][name] = value # add all local values (of last frame) to the snapshot s['locals'] = {} diff --git a/gluon/tests/test_sqlhtml.py b/gluon/tests/test_sqlhtml.py index a7d2a738..19a60dfb 100644 --- a/gluon/tests/test_sqlhtml.py +++ b/gluon/tests/test_sqlhtml.py @@ -6,10 +6,7 @@ """ import os import sys -if sys.version < "2.7": - import unittest2 as unittest -else: - import unittest +import unittest from fix_path import fix_sys_path diff --git a/gluon/tests/test_tools.py b/gluon/tests/test_tools.py index cc45154b..547a0c95 100644 --- a/gluon/tests/test_tools.py +++ b/gluon/tests/test_tools.py @@ -8,10 +8,7 @@ import os import sys import smtplib import datetime -if sys.version < "2.7": - import unittest2 as unittest -else: - import unittest +import unittest from fix_path import fix_sys_path diff --git a/gluon/tests/test_web.py b/gluon/tests/test_web.py index a75ae574..69589783 100644 --- a/gluon/tests/test_web.py +++ b/gluon/tests/test_web.py @@ -5,10 +5,7 @@ """ import sys import os -if sys.version_info < (2, 7): - import unittest2 as unittest -else: - import unittest +import unittest import subprocess import time import signal @@ -48,27 +45,10 @@ def startwebserver(): print '' -def terminate_process(pid): - # Taken from http://stackoverflow.com/questions/1064335/in-python-2-5-how-do-i-kill-a-subprocess - # all this **blah** is because we are stuck with Python 2.5 and \ - # we cannot use Popen.terminate() - if sys.platform.startswith('win'): - import ctypes - PROCESS_TERMINATE = 1 - handle = ctypes.windll.kernel32.OpenProcess(PROCESS_TERMINATE, False, pid) - ctypes.windll.kernel32.TerminateProcess(handle, -1) - ctypes.windll.kernel32.CloseHandle(handle) - else: - os.kill(pid, signal.SIGKILL) - - def stopwebserver(): global webserverprocess print 'Killing webserver' - if sys.version_info < (2, 6): - terminate_process(webserverprocess.pid) - else: - webserverprocess.terminate() + webserverprocess.terminate() class LiveTest(unittest.TestCase): diff --git a/gluon/widget.py b/gluon/widget.py index 5fe0210a..4db9e208 100644 --- a/gluon/widget.py +++ b/gluon/widget.py @@ -41,8 +41,8 @@ ProgramInfo = '''%s %s %s''' % (ProgramName, ProgramAuthor, ProgramVersion) -if not sys.version[:3] in ['2.6', '2.7']: - msg = 'Warning: web2py requires Python 2.6 or 2.7 but you are running:\n%s' +if not sys.version[:3] in ['2.7']: + msg = 'Warning: web2py requires Python 2.7 but you are running:\n%s' msg = msg % sys.version sys.stderr.write(msg) @@ -57,10 +57,7 @@ def run_system_tests(options): major_version = sys.version_info[0] minor_version = sys.version_info[1] if major_version == 2: - if minor_version in (6,): - sys.stderr.write('Python 2.6\n') - ret = subprocess.call(['unit2', '-v', 'gluon.tests']) - elif minor_version in (7,): + if minor_version in (7,): call_args = [sys.executable, '-m', 'unittest', '-v', 'gluon.tests'] if options.with_coverage: try: