]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
libstdc++/77645 fix deque and vector xmethods for Python 3
authorJonathan Wakely <jwakely@redhat.com>
Mon, 19 Sep 2016 17:14:11 +0000 (18:14 +0100)
committerJonathan Wakely <redi@gcc.gnu.org>
Mon, 19 Sep 2016 17:14:11 +0000 (18:14 +0100)
PR libstdc++/77645
* python/libstdcxx/v6/xmethods.py (DequeWorkerBase.__init__)
(DequeWorkerBase.index, VectorWorkerBase.get): Cast results of
division to int to work with Python 3.

From-SVN: r240242

libstdc++-v3/ChangeLog
libstdc++-v3/python/libstdcxx/v6/xmethods.py

index 42a8716b687072abd18d69d00440846d34a49f54..47af5a081c92c5f5e4639ef31329fed19bb17abd 100644 (file)
@@ -1,3 +1,10 @@
+2016-09-19  Jonathan Wakely  <jwakely@redhat.com>
+
+       PR libstdc++/77645
+       * python/libstdcxx/v6/xmethods.py (DequeWorkerBase.__init__)
+       (DequeWorkerBase.index, VectorWorkerBase.get): Cast results of
+       division to int to work with Python 3.
+
 2016-08-23  Jonathan Wakely  <jwakely@redhat.com>
 
        * testsuite/23_containers/map/77334.cc: Use dg-options for C++11.
index 6db0e163e9835d3f7bd239147b4791c67353bd6c..17f5937b2c60ade4fa8ad0eb099801610a9775de 100644 (file)
@@ -165,7 +165,7 @@ class ArrayMethodsMatcher(gdb.xmethod.XMethodMatcher):
 class DequeWorkerBase(gdb.xmethod.XMethodWorker):
     def __init__(self, val_type):
         self._val_type = val_type
-        self._bufsize = (512 / val_type.sizeof) or 1
+        self._bufsize = int(512 / val_type.sizeof) or 1
 
     def size(self, obj):
         first_node = obj['_M_impl']['_M_start']['_M_node']
@@ -176,7 +176,7 @@ class DequeWorkerBase(gdb.xmethod.XMethodWorker):
 
     def index(self, obj, index):
         first_node = obj['_M_impl']['_M_start']['_M_node']
-        index_node = first_node + index / self._bufsize
+        index_node = first_node + int(index / self._bufsize)
         return index_node[0][index % self._bufsize]
 
 class DequeEmptyWorker(DequeWorkerBase):
@@ -410,7 +410,7 @@ class VectorWorkerBase(gdb.xmethod.XMethodWorker):
         if self._val_type.code == gdb.TYPE_CODE_BOOL:
             start = obj['_M_impl']['_M_start']['_M_p']
             bit_size = start.dereference().type.sizeof * 8
-            valp = start + index / bit_size
+            valp = start + int(index / bit_size)
             offset = index % bit_size
             return (valp.dereference() & (1 << offset)) > 0
         else: