Skip to content

Commit cf3c421

Browse files
committed
1. Debugger was failing to start due to DictProxy limitations.
2. Fix some debug prints in RemoteDebugger.py - use py3k syntax.
1 parent 39342f4 commit cf3c421

File tree

2 files changed

+32
-10
lines changed

2 files changed

+32
-10
lines changed

Lib/idlelib/Debugger.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -446,7 +446,20 @@ def load_dict(self, dict, force=0, rpc_client=None):
446446
l = Label(subframe, text="None")
447447
l.grid(row=0, column=0)
448448
else:
449-
names = sorted(dict)
449+
#names = sorted(dict)
450+
###
451+
# Because of (temporary) limitations on the dict_keys type (not yet
452+
# public or pickleable), have the subprocess to send a list of
453+
# keys, not a dict_keys object. sorted() will take a dict_keys
454+
# (no subprocess) or a list.
455+
#
456+
# There is also an obscure bug in sorted(dict) where the
457+
# interpreter gets into a loop requesting non-existing dict[0],
458+
# dict[1], dict[2], etc from the RemoteDebugger.DictProxy.
459+
###
460+
keys_list = dict.keys()
461+
names = sorted(keys_list)
462+
###
450463
row = 0
451464
for name in names:
452465
value = dict[name]

Lib/idlelib/RemoteDebugger.py

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -94,16 +94,13 @@ def set_return(self, fid):
9494
self.idb.set_return(frame)
9595

9696
def get_stack(self, fid, tbid):
97-
##print >>sys.__stderr__, "get_stack(%r, %r)" % (fid, tbid)
9897
frame = frametable[fid]
9998
if tbid is None:
10099
tb = None
101100
else:
102101
tb = tracebacktable[tbid]
103102
stack, i = self.idb.get_stack(frame, tb)
104-
##print >>sys.__stderr__, "get_stack() ->", stack
105103
stack = [(wrap_frame(frame), k) for frame, k in stack]
106-
##print >>sys.__stderr__, "get_stack() ->", stack
107104
return stack, i
108105

109106
def run(self, cmd):
@@ -162,13 +159,20 @@ def code_filename(self, cid):
162159
#----------called by a DictProxy----------
163160

164161
def dict_keys(self, did):
162+
raise NotImplemented("dict_keys not public or pickleable")
163+
## dict = dicttable[did]
164+
## return dict.keys()
165+
166+
### Needed until dict_keys is type is finished and pickealable.
167+
### Will probably need to extend rpc.py:SocketIO._proxify at that time.
168+
def dict_keys_list(self, did):
165169
dict = dicttable[did]
166170
return list(dict.keys())
167171

168172
def dict_item(self, did, key):
169173
dict = dicttable[did]
170174
value = dict[key]
171-
value = repr(value)
175+
value = repr(value) ### can't pickle module '__builtin__'
172176
return value
173177

174178
#----------end class IdbAdapter----------
@@ -261,15 +265,20 @@ def __init__(self, conn, oid, did):
261265
self._oid = oid
262266
self._did = did
263267

268+
## def keys(self):
269+
## return self._conn.remotecall(self._oid, "dict_keys", (self._did,), {})
270+
271+
# 'temporary' until dict_keys is a pickleable built-in type
264272
def keys(self):
265-
return self._conn.remotecall(self._oid, "dict_keys", (self._did,), {})
273+
return self._conn.remotecall(self._oid,
274+
"dict_keys_list", (self._did,), {})
266275

267276
def __getitem__(self, key):
268277
return self._conn.remotecall(self._oid, "dict_item",
269278
(self._did, key), {})
270279

271280
def __getattr__(self, name):
272-
##print >>sys.__stderr__, "failed DictProxy.__getattr__:", name
281+
##print("*** Failed DictProxy.__getattr__:", name)
273282
raise AttributeError(name)
274283

275284

@@ -280,7 +289,7 @@ def __init__(self, conn, gui):
280289
self.gui = gui
281290

282291
def interaction(self, message, fid, modified_info):
283-
##print "interaction: (%s, %s, %s)" % (message, fid, modified_info)
292+
##print("*** Interaction: (%s, %s, %s)" % (message, fid, modified_info))
284293
frame = FrameProxy(self.conn, fid)
285294
self.gui.interaction(message, frame, modified_info)
286295

@@ -293,9 +302,9 @@ def __init__(self, conn, shell, oid):
293302
self.shell = shell
294303

295304
def call(self, methodname, *args, **kwargs):
296-
##print "**IdbProxy.call %s %s %s" % (methodname, args, kwargs)
305+
##print("*** IdbProxy.call %s %s %s" % (methodname, args, kwargs))
297306
value = self.conn.remotecall(self.oid, methodname, args, kwargs)
298-
##print "**IdbProxy.call %s returns %r" % (methodname, value)
307+
##print("*** IdbProxy.call %s returns %r" % (methodname, value))
299308
return value
300309

301310
def run(self, cmd, locals):

0 commit comments

Comments
 (0)