[pypy-commit] pypy default: set a good example for the children.

alex_gaynor noreply at buildbot.pypy.org
Thu Aug 4 19:58:53 CEST 2011


Author: Alex Gaynor <alex.gaynor at gmail.com>
Branch: 
Changeset: r46277:89041e70a53c
Date: 2011-08-04 11:00 -0700
http://bitbucket.org/pypy/pypy/changeset/89041e70a53c/

Log:	set a good example for the children.

diff --git a/pypy/tool/gdb_pypy.py b/pypy/tool/gdb_pypy.py
--- a/pypy/tool/gdb_pypy.py
+++ b/pypy/tool/gdb_pypy.py
@@ -8,6 +8,8 @@
 (gdb) python execfile('/path/to/gdb_pypy.py')
 """
 
+from __future__ import with_statement
+
 import sys
 import os.path
 
@@ -108,11 +110,12 @@
         typeids_txt = os.path.join(root, 'typeids.txt')
         print 'loading', typeids_txt
         typeids = {}
-        for line in open(typeids_txt):
-            member, descr = map(str.strip, line.split(None, 1))
-            expr = "((char*)(&pypy_g_typeinfo.%s)) - (char*)&pypy_g_typeinfo" % member
-            offset = int(self.gdb.parse_and_eval(expr))
-            typeids[offset] = descr
+        with open(typeids_txt) as f:
+            for line in f:
+                member, descr = map(str.strip, line.split(None, 1))
+                expr = "((char*)(&pypy_g_typeinfo.%s)) - (char*)&pypy_g_typeinfo" % member
+                offset = int(self.gdb.parse_and_eval(expr))
+                typeids[offset] = descr
         return typeids
 
 try:


More information about the pypy-commit mailing list