Rev 151: Merge Andrew's frame name code, add a test for it. in http://bazaar.launchpad.net/~meliae-dev/meliae/trunk
John Arbash Meinel
john at arbash-meinel.com
Mon Jul 12 21:20:19 BST 2010
At http://bazaar.launchpad.net/~meliae-dev/meliae/trunk
------------------------------------------------------------
revno: 151 [merge]
revision-id: john at arbash-meinel.com-20100712202013-w39fzomwpkw4hnbj
parent: john at arbash-meinel.com-20100712201034-kkjc4c1v6pmdsb6r
parent: andrew at bemusement.org-20100712171401-j7td0ubm0n4nf41e
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: trunk
timestamp: Mon 2010-07-12 15:20:13 -0500
message:
Merge Andrew's frame name code, add a test for it.
modified:
meliae/_scanner_core.c _scanner_core.c-20090402012435-66bb6fp08v4begco-1
meliae/_scanner_core.h _scanner_core.h-20090402012435-66bb6fp08v4begco-2
meliae/tests/test__scanner.py test__scanner.py-20090401185718-094vrprmymne09r1-3
-------------- next part --------------
=== modified file 'meliae/_scanner_core.c'
--- a/meliae/_scanner_core.c 2010-06-30 18:05:55 +0000
+++ b/meliae/_scanner_core.c 2010-07-12 17:14:01 +0000
@@ -472,6 +472,12 @@
_write_to_ref_info(info, ", \"len\": " SSIZET_FMT, PySet_GET_SIZE(c_obj));
} else if (PyDict_Check(c_obj)) {
_write_to_ref_info(info, ", \"len\": " SSIZET_FMT, PyDict_Size(c_obj));
+ } else if (PyFrame_Check(c_obj)) {
+ PyCodeObject *co = ((PyFrameObject*)c_obj)->f_code;
+ if (co) {
+ _write_static_to_info(info, ", \"value\": ");
+ _dump_string(info, co->co_name);
+ }
}
_write_static_to_info(info, ", \"refs\": [");
do_traverse = 1;
=== modified file 'meliae/_scanner_core.h'
--- a/meliae/_scanner_core.h 2009-12-30 16:25:15 +0000
+++ b/meliae/_scanner_core.h 2010-07-12 20:20:13 +0000
@@ -1,4 +1,4 @@
-/* Copyright (C) 2009 Canonical Ltd
+/* Copyright (C) 2009, 2010 Canonical Ltd
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -23,6 +23,8 @@
#define _SCANNER_CORE_H_
#include <Python.h>
+#include <code.h>
+#include <frameobject.h>
#include <stdio.h>
/**
=== modified file 'meliae/tests/test__scanner.py'
--- a/meliae/tests/test__scanner.py 2009-12-30 16:33:56 +0000
+++ b/meliae/tests/test__scanner.py 2010-07-12 20:20:13 +0000
@@ -1,4 +1,4 @@
-# Copyright (C) 2009 Canonical Ltd
+# Copyright (C) 2009, 2010 Canonical Ltd
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 3 as
@@ -267,6 +267,8 @@
content.append(', "value": "False"')
elif isinstance(obj, int):
content.append(', "value": %d' % (obj,))
+ elif isinstance(obj, types.FrameType):
+ content.append(', "value": "%s"' % (obj.f_code.co_name,))
first = True
content.append(', "refs": [')
ref_strs = []
@@ -475,6 +477,13 @@
self.assertDumpInfo(True)
self.assertDumpInfo(False)
+ def test_frame(self):
+ def local_frame():
+ f = sys._getframe()
+ return f
+ f = local_frame()
+ self.assertDumpInfo(f)
+
class TestGetReferents(tests.TestCase):
More information about the bazaar-commits
mailing list