Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [PATCH] Fix xmethod Python so that it works with Python 3
@ 2014-08-05 15:43 Siva Chandra
  2014-08-05 17:30 ` Joel Brobecker
  0 siblings, 1 reply; 2+ messages in thread
From: Siva Chandra @ 2014-08-05 15:43 UTC (permalink / raw)
  To: gdb-patches

[-- Attachment #1: Type: text/plain, Size: 633 bytes --]

Attached is a patch which fixes few misses in my original xmethods
patch which do not work with Python 3.

Tested with Python 2.7.3 and Python 3.2.3.

ChangeLog

2014-08-05  Siva Chandra Reddy  <sivachandra@google.com>

    gdb/

        * python/lib/gdb/command/xmethods.py (set_xm_status1): Use the
        'items' methods instead of 'iteritems' method on dictionaries.

    gdb/testsuite/

        * gdb.python/py-xmethods.py (A_getarrayind)
        (E_method_char_worker.__call__, E_method_int_worker.__call__):
        Use 'print' with function call syntax.
        (E_method_matcher.match): Fix tab vs space indentation mixup.

[-- Attachment #2: fix_xmethods_for_python3.txt --]
[-- Type: text/plain, Size: 1905 bytes --]

diff --git a/gdb/python/lib/gdb/command/xmethods.py b/gdb/python/lib/gdb/command/xmethods.py
index 55cc81f..206313e 100644
--- a/gdb/python/lib/gdb/command/xmethods.py
+++ b/gdb/python/lib/gdb/command/xmethods.py
@@ -140,7 +140,7 @@ def print_xm_info(xm_dict, name_re):
 
 def set_xm_status1(xm_dict, name_re, status):
     """Set the status (enabled/disabled) of a dictionary of xmethods."""
-    for locus_str, matchers in xm_dict.iteritems():
+    for locus_str, matchers in xm_dict.items():
         for matcher in matchers:
             if not name_re:
                 # If the name regex is missing, then set the status of the
diff --git a/gdb/testsuite/gdb.python/py-xmethods.py b/gdb/testsuite/gdb.python/py-xmethods.py
index 6fecf2b..26df3de 100644
--- a/gdb/testsuite/gdb.python/py-xmethods.py
+++ b/gdb/testsuite/gdb.python/py-xmethods.py
@@ -40,7 +40,7 @@ def A_geta(obj):
 
 
 def A_getarrayind(obj, index):
-  print 'From Python <A_getarrayind>:'
+  print ('From Python <A_getarrayind>:')
   return obj['array'][index]
 
 
@@ -61,7 +61,7 @@ class E_method_char_worker(XMethodWorker):
         return gdb.lookup_type('char')
 
     def __call__(self, obj, arg):
-        print 'From Python <E_method_char>'
+        print ('From Python <E_method_char>')
         return None
 
 
@@ -73,7 +73,7 @@ class E_method_int_worker(XMethodWorker):
         return gdb.lookup_type('int')
 
     def __call__(self, obj, arg):
-        print 'From Python <E_method_int>'
+        print ('From Python <E_method_int>')
         return None
 
 
@@ -86,7 +86,7 @@ class E_method_matcher(XMethodMatcher):
         class_tag = class_type.unqualified().tag
         if not re.match('^dop::E$', class_tag):
             return None
-	if not re.match('^method$', method_name):
+        if not re.match('^method$', method_name):
             return None
         workers = []
         if self.methods[0].enabled:

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2014-08-05 17:30 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-08-05 15:43 [PATCH] Fix xmethod Python so that it works with Python 3 Siva Chandra
2014-08-05 17:30 ` Joel Brobecker

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox