From ac7a5367c801d19da4445fe47d19d26ada8ba83e Mon Sep 17 00:00:00 2001 From: Stefan Behnel Date: Sat, 5 Feb 2011 17:46:22 +0100 Subject: [PATCH] fix Py2.5-isms in test code --- Cython/Debugger/Tests/TestLibCython.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/Cython/Debugger/Tests/TestLibCython.py b/Cython/Debugger/Tests/TestLibCython.py index 79b0d8df..8bf7f7a1 100644 --- a/Cython/Debugger/Tests/TestLibCython.py +++ b/Cython/Debugger/Tests/TestLibCython.py @@ -1,4 +1,3 @@ -from __future__ import with_statement import os import re @@ -22,8 +21,12 @@ from Cython.Debugger import Cygdb as cygdb root = os.path.dirname(os.path.abspath(__file__)) codefile = os.path.join(root, 'codefile') cfuncs_file = os.path.join(root, 'cfuncs.c') -with open(codefile) as f: + +f = open(codefile) +try: source_to_lineno = dict((line.strip(), i + 1) for i, line in enumerate(f)) +finally: + f.close() # Cython.Distutils.__init__ imports build_ext from build_ext which means we # can't access the module anymore. Get it from sys.modules instead. @@ -205,8 +208,11 @@ class GdbDebuggerTestCase(DebuggerTestCase): self.gdb_command_file = cygdb.make_command_file(self.tempdir, prefix_code) - with open(self.gdb_command_file, 'a') as f: + f = open(self.gdb_command_file, 'a') + try: f.write(code) + finally: + f.close() args = ['gdb', '-batch', '-x', self.gdb_command_file, '-n', '--args', sys.executable, '-c', 'import codefile'] -- 2.26.2