Mercurial > cpython-lru_cache-weakref
annotate Lib/idlelib/RemoteObjectBrowser.py @ 80661:94de77bd0b4b 2.7
Issue #16194: document imp.load_dynamic problems
when read several extension modules from the same binary object file.
| author | Andrew Svetlov <andrew.svetlov@gmail.com> |
|---|---|
| date | Thu, 29 Nov 2012 19:51:28 +0200 |
| parents | eab361617f6a |
| children |
| rev | line source |
|---|---|
|
60144
eab361617f6a
#7092: Fix additional "-3" warnings in the idlelib package, and convert to absolute imports.
Florent Xicluna <florent.xicluna@gmail.com>
parents:
23547
diff
changeset
|
1 from idlelib import rpc |
| 23547 | 2 |
| 3 def remote_object_tree_item(item): | |
| 4 wrapper = WrappedObjectTreeItem(item) | |
| 5 oid = id(wrapper) | |
| 6 rpc.objecttable[oid] = wrapper | |
| 7 return oid | |
| 8 | |
| 9 class WrappedObjectTreeItem: | |
| 10 # Lives in PYTHON subprocess | |
| 11 | |
| 12 def __init__(self, item): | |
| 13 self.__item = item | |
| 14 | |
| 15 def __getattr__(self, name): | |
| 16 value = getattr(self.__item, name) | |
| 17 return value | |
| 18 | |
| 19 def _GetSubList(self): | |
| 20 list = self.__item._GetSubList() | |
| 21 return map(remote_object_tree_item, list) | |
| 22 | |
| 23 class StubObjectTreeItem: | |
| 24 # Lives in IDLE process | |
| 25 | |
| 26 def __init__(self, sockio, oid): | |
| 27 self.sockio = sockio | |
| 28 self.oid = oid | |
| 29 | |
| 30 def __getattr__(self, name): | |
| 31 value = rpc.MethodProxy(self.sockio, self.oid, name) | |
| 32 return value | |
| 33 | |
| 34 def _GetSubList(self): | |
| 35 list = self.sockio.remotecall(self.oid, "_GetSubList", (), {}) | |
| 36 return [StubObjectTreeItem(self.sockio, oid) for oid in list] |
