Rev 87: Add a helper for finding the 'interned' dict used by intern() in http://bazaar.launchpad.net/~meliae-dev/meliae/trunk
John Arbash Meinel
john at arbash-meinel.com
Wed Sep 30 05:02:04 BST 2009
At http://bazaar.launchpad.net/~meliae-dev/meliae/trunk
------------------------------------------------------------
revno: 87
revision-id: john at arbash-meinel.com-20090930040159-g6mx4be90so1do13
parent: john at arbash-meinel.com-20090918170034-pka6rqn23mm3o6j6
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: trunk
timestamp: Tue 2009-09-29 23:01:59 -0500
message:
Add a helper for finding the 'interned' dict used by intern()
-------------- next part --------------
=== modified file 'meliae/scanner.py'
--- a/meliae/scanner.py 2009-09-18 17:00:34 +0000
+++ b/meliae/scanner.py 2009-09-30 04:01:59 +0000
@@ -135,3 +135,19 @@
else:
pending.append(child)
return all
+
+
+def find_interned_dict():
+ """Go through all gc objects and find the interned python dict."""
+ for obj in gc.get_objects():
+ if (type(obj) is not dict
+ or 'find_interned_dict' not in obj
+ or obj['find_interned_dict'] is not 'find_interned_dict'
+ or 'get_recursive_items' not in obj
+ or obj['get_recursive_items'] is not 'get_recursive_items'):
+ # The above check assumes that local strings will be interned,
+ # which is the standard cpython behavior, but perhaps not the best
+ # to require? However, if we used something like a custom string
+ # that we intern() we still could have problems with locals(), etc.
+ continue
+ return obj
More information about the bazaar-commits
mailing list