From patchwork Thu Aug 14 13:53:03 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Siva Chandra Reddy X-Patchwork-Id: 2395 Received: (qmail 18836 invoked by alias); 14 Aug 2014 13:53:08 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 18826 invoked by uid 89); 14 Aug 2014 13:53:07 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.1 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_LOW, RP_MATCHES_RCVD, SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-oi0-f50.google.com Received: from mail-oi0-f50.google.com (HELO mail-oi0-f50.google.com) (209.85.218.50) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Thu, 14 Aug 2014 13:53:05 +0000 Received: by mail-oi0-f50.google.com with SMTP id a141so733441oig.23 for ; Thu, 14 Aug 2014 06:53:03 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:date:message-id:subject:from:to:cc :content-type; bh=BSfshP3KbcISicHYqz0/6C4LBqQ/fp4KX+BN6mwMHs0=; b=WYUec6+hXjqwdVwHK/it+A2XOlAsY3F17EWJK74SZTUM/UCMJjRIx5goRlNSI1J+Rf HPOHFVPlWhw9XIaRRSKH37CVWIObJ+eLfVe2100gsnxo88CfNXblRJXuFd2ZFfJhuckc SYRV7TJ0hsAeLv2jjCQKoX7hEpps5ZSrAdyACmgnXkI1WyoDN3Me4XPyxlbZV22oC35e HH5j72HRhay4HNK8PMmtCkqqk7+0atB8pd+XK34SEBqLdqjiZR6IUgUyu2Snk43+xeCy pP87TERqLqgwpO1UaMfMw95LjXcGy6azImOk1rHgKquK4FkKnxdCzIq7pULIog7dsTiu CYVA== X-Gm-Message-State: ALoCoQnTnZUjFqdoG+bet+6rAAR9pP1odGvEC9MIs3Np7hWMGDYBxqY/wJNRw55aomd+NRk6NdRM MIME-Version: 1.0 X-Received: by 10.60.176.104 with SMTP id ch8mr12904649oec.64.1408024383468; Thu, 14 Aug 2014 06:53:03 -0700 (PDT) Received: by 10.202.12.193 with HTTP; Thu, 14 Aug 2014 06:53:03 -0700 (PDT) Date: Thu, 14 Aug 2014 06:53:03 -0700 Message-ID: Subject: [PATCH v2] Fix xmethod Python so that it works with Python 3 From: Siva Chandra To: gdb-patches Cc: Doug Evans X-IsSubscribed: yes The attached patch fixes the "no space before parenthesis in Python" comment by Joel. The comment was for the changes in the test suite. Going by examples, I thought the test case code (but not the .exp files) did not require adherence to coding style. I also agree with Joel that this patch should also pushed to the 7.8 branch. ChangeLog: 2014-08-14 Siva Chandra Reddy 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. 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..47fb00b 100644 --- a/gdb/testsuite/gdb.python/py-xmethods.py +++ b/gdb/testsuite/gdb.python/py-xmethods.py @@ -25,22 +25,22 @@ from gdb.xmethod import SimpleXMethodMatcher def A_plus_A(obj, opr): - print ('From Python :') + print('From Python :') return obj['a'] + opr['a'] def plus_plus_A(obj): - print ('From Python :') + print('From Python :') return obj['a'] + 1 def A_geta(obj): - print ('From Python :') + print('From Python :') return obj['a'] def A_getarrayind(obj, index): - print 'From Python :' + print('From Python :') 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 ' + print('From Python ') 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 ' + print('From Python ') 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: @@ -109,7 +109,7 @@ class G_size_diff_worker(XMethodWorker): pass def __call__(self, obj): - print ('From Python G<>::size_diff()') + print('From Python G<>::size_diff()') return (self._method_template_type.sizeof - self._class_template_type.sizeof) @@ -123,7 +123,7 @@ class G_size_mul_worker(XMethodWorker): pass def __call__(self, obj): - print ('From Python G<>::size_mul()') + print('From Python G<>::size_mul()') return self._class_template_type.sizeof * self._method_template_val @@ -136,7 +136,7 @@ class G_mul_worker(XMethodWorker): return self._method_template_type def __call__(self, obj, arg): - print ('From Python G<>::mul()') + print('From Python G<>::mul()') return obj['t'] * arg