From cf3c4217c755164a6b762c5846ee82636565d6f0 Mon Sep 17 00:00:00 2001 From: "Kurt B. Kaiser" Date: Wed, 29 Aug 2007 18:44:24 +0000 Subject: 1. Debugger was failing to start due to DictProxy limitations. 2. Fix some debug prints in RemoteDebugger.py - use py3k syntax. --- Lib/idlelib/Debugger.py | 15 ++++++++++++++- Lib/idlelib/RemoteDebugger.py | 27 ++++++++++++++++++--------- 2 files changed, 32 insertions(+), 10 deletions(-) diff --git a/Lib/idlelib/Debugger.py b/Lib/idlelib/Debugger.py index cd31914..346763f 100644 --- a/Lib/idlelib/Debugger.py +++ b/Lib/idlelib/Debugger.py @@ -446,7 +446,20 @@ class NamespaceViewer: l = Label(subframe, text="None") l.grid(row=0, column=0) else: - names = sorted(dict) + #names = sorted(dict) + ### + # Because of (temporary) limitations on the dict_keys type (not yet + # public or pickleable), have the subprocess to send a list of + # keys, not a dict_keys object. sorted() will take a dict_keys + # (no subprocess) or a list. + # + # There is also an obscure bug in sorted(dict) where the + # interpreter gets into a loop requesting non-existing dict[0], + # dict[1], dict[2], etc from the RemoteDebugger.DictProxy. + ### + keys_list = dict.keys() + names = sorted(keys_list) + ### row = 0 for name in names: value = dict[name] diff --git a/Lib/idlelib/RemoteDebugger.py b/Lib/idlelib/RemoteDebugger.py index 8a0970d..e5b95b4 100644 --- a/Lib/idlelib/RemoteDebugger.py +++ b/Lib/idlelib/RemoteDebugger.py @@ -94,16 +94,13 @@ class IdbAdapter: self.idb.set_return(frame) def get_stack(self, fid, tbid): - ##print >>sys.__stderr__, "get_stack(%r, %r)" % (fid, tbid) frame = frametable[fid] if tbid is None: tb = None else: tb = tracebacktable[tbid] stack, i = self.idb.get_stack(frame, tb) - ##print >>sys.__stderr__, "get_stack() ->", stack stack = [(wrap_frame(frame), k) for frame, k in stack] - ##print >>sys.__stderr__, "get_stack() ->", stack return stack, i def run(self, cmd): @@ -162,13 +159,20 @@ class IdbAdapter: #----------called by a DictProxy---------- def dict_keys(self, did): + raise NotImplemented("dict_keys not public or pickleable") +## dict = dicttable[did] +## return dict.keys() + + ### Needed until dict_keys is type is finished and pickealable. + ### Will probably need to extend rpc.py:SocketIO._proxify at that time. + def dict_keys_list(self, did): dict = dicttable[did] return list(dict.keys()) def dict_item(self, did, key): dict = dicttable[did] value = dict[key] - value = repr(value) + value = repr(value) ### can't pickle module '__builtin__' return value #----------end class IdbAdapter---------- @@ -261,15 +265,20 @@ class DictProxy: self._oid = oid self._did = did +## def keys(self): +## return self._conn.remotecall(self._oid, "dict_keys", (self._did,), {}) + + # 'temporary' until dict_keys is a pickleable built-in type def keys(self): - return self._conn.remotecall(self._oid, "dict_keys", (self._did,), {}) + return self._conn.remotecall(self._oid, + "dict_keys_list", (self._did,), {}) def __getitem__(self, key): return self._conn.remotecall(self._oid, "dict_item", (self._did, key), {}) def __getattr__(self, name): - ##print >>sys.__stderr__, "failed DictProxy.__getattr__:", name + ##print("*** Failed DictProxy.__getattr__:", name) raise AttributeError(name) @@ -280,7 +289,7 @@ class GUIAdapter: self.gui = gui def interaction(self, message, fid, modified_info): - ##print "interaction: (%s, %s, %s)" % (message, fid, modified_info) + ##print("*** Interaction: (%s, %s, %s)" % (message, fid, modified_info)) frame = FrameProxy(self.conn, fid) self.gui.interaction(message, frame, modified_info) @@ -293,9 +302,9 @@ class IdbProxy: self.shell = shell def call(self, methodname, *args, **kwargs): - ##print "**IdbProxy.call %s %s %s" % (methodname, args, kwargs) + ##print("*** IdbProxy.call %s %s %s" % (methodname, args, kwargs)) value = self.conn.remotecall(self.oid, methodname, args, kwargs) - ##print "**IdbProxy.call %s returns %r" % (methodname, value) + ##print("*** IdbProxy.call %s returns %r" % (methodname, value)) return value def run(self, cmd, locals): -- cgit v0.12 option value='bug_2992970'>bug_2992970 Tcl is a high-level, general-purpose, interpreted, dynamic programming language. It was designed with the goal of being very simple but powerful.
summaryrefslogtreecommitdiffstats
path: root/tools/str2c
blob: c761f91ffc25d13804aff76ac2f877316e0e8d22 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#! /bin/sh
#
# Transform text (.ps, .tcl,...) into a C string
#
# 1997/10 -- dl
#
# restart with tclsh \
exec tclsh8.0 "$0" "$@"

# Max string length
# (some C compiler have a 2048 chars limits (so 2047 real chars with
#  the tariling 0) so we use 2000 to make the count nice)
set MAX 2000

if {$argc} {
    puts stderr "Usage: [file tail [info script]] < text > text.c"
    exit 1
}

set r [read stdin]

proc translate {what} {
    regsub -all {\\} $what {\\\\} what
    regsub -all {"} $what {\\"} what
    regsub -all "\n" $what "\\\\n\\\\\n" what;
    return $what;
}

set lg [string length $r]
if {$lg<$MAX} {
    puts "/*
 * Single part writeable string generated by str2c
 */
static char data\[\]=\"[translate $r]\";"
} else {
    puts "/*
 * Multi parts read only string generated by str2c
 */
static CONST char * CONST data\[\]= {"
    set n 1
    for {set i 0} {$i<$lg} {incr i $MAX} {
	set part [string range $r $i [expr $i+$MAX-1]]
	set len  [string length $part];
	puts "\t/* Start of part $n ($len characters) */"
	puts "\t\"[translate $part]\","
	puts "\t/* End of part $n */\n"
	incr n
    }
    puts "\tNULL\t/* End of data marker */\n};"
    puts "\n/* use for instance with:
    CONST char * CONST *chunk;
    for (chunk=data; *chunk; chunk++) {
        Tcl_AppendResult(interp, *chunk, (char *) NULL);
    }
*/"
}