[Lldb-commits] [PATCH] D14028: Convert long to int and portably detect integral types
Zachary Turner via lldb-commits
lldb-commits at lists.llvm.org
Fri Oct 23 13:35:59 PDT 2015
zturner created this revision.
zturner added a reviewer: tfiala.
zturner added a subscriber: lldb-commits.
In a few of the examples fixed up here, the distinction between long and int was not important here. As a result, I converted those to use int instead of long everywhere to make the code simpler since six doesn't have something like `six.long` that resolves to int in py3 and long in py2. So we just use int everywhere.
The other fixes are fairly straightforward.
http://reviews.llvm.org/D14028
Files:
test/functionalities/abbreviation/TestCommonShortSpellings.py
test/lang/c/array_types/TestArrayTypes.py
test/lldbcurses.py
test/python_api/sbdata/TestSBData.py
test/tools/lldb-server/lldbgdbserverutils.py
Index: test/tools/lldb-server/lldbgdbserverutils.py
===================================================================
--- test/tools/lldb-server/lldbgdbserverutils.py
+++ test/tools/lldb-server/lldbgdbserverutils.py
@@ -9,6 +9,7 @@
import os.path
import platform
import re
+import six
import socket_packet_pump
import subprocess
import time
@@ -808,8 +809,8 @@
If we don't know how to check running process ids on the given OS:
return the value provided by the unknown_value arg.
"""
- if type(pid) not in [int, long]:
- raise Exception("pid must be of type int (actual type: %s)" % str(type(pid)))
+ if not isinstance(pid, six.integer_types):
+ raise Exception("pid must be an integral type (actual type: %s)" % str(type(pid)))
process_ids = []
Index: test/python_api/sbdata/TestSBData.py
===================================================================
--- test/python_api/sbdata/TestSBData.py
+++ test/python_api/sbdata/TestSBData.py
@@ -220,8 +220,8 @@
self.assertTrue(data2.uint8[4] == 111, 'o == 111')
self.assert_data(data2.GetUnsignedInt8, 5, 33) # !
- uint_lists = [ [1,2,3,4,5], [long(i) for i in [1, 2, 3, 4, 5]] ]
- int_lists = [ [2, -2], [long(i) for i in [2, -2]] ]
+ uint_lists = [ [1,2,3,4,5], [int(i) for i in [1, 2, 3, 4, 5]] ]
+ int_lists = [ [2, -2], [int(i) for i in [2, -2]] ]
for l in uint_lists:
data2 = lldb.SBData.CreateDataFromUInt64Array(process.GetByteOrder(), process.GetAddressByteSize(), l)
Index: test/lldbcurses.py
===================================================================
--- test/lldbcurses.py
+++ test/lldbcurses.py
@@ -1,5 +1,8 @@
+import lldb_shared
+
import curses, curses.panel
import sys
+import six
import time
class Point(object):
@@ -138,7 +141,7 @@
for key in arg:
self.add_key_action(key, callback, description)
else:
- if isinstance(arg, ( int, long )):
+ if isinstance(arg, six.integer_types):
key_action_dict = { 'key' : arg,
'callback' : callback,
'description' : decription }
Index: test/lang/c/array_types/TestArrayTypes.py
===================================================================
--- test/lang/c/array_types/TestArrayTypes.py
+++ test/lang/c/array_types/TestArrayTypes.py
@@ -182,7 +182,7 @@
"Variable 'long_6' should have 6 children")
child5 = variable.GetChildAtIndex(5)
self.DebugSBValue(child5)
- self.assertTrue(long(child5.GetValue(), 0) == 6,
+ self.assertTrue(int(child5.GetValue(), 0) == 6,
"long_6[5] == 6")
# Last, check that "long_6" has a value type of eValueTypeVariableLocal
Index: test/functionalities/abbreviation/TestCommonShortSpellings.py
===================================================================
--- test/functionalities/abbreviation/TestCommonShortSpellings.py
+++ test/functionalities/abbreviation/TestCommonShortSpellings.py
@@ -32,7 +32,7 @@
('ta st li', 'target stop-hook list'),
]
- for (short, long) in abbrevs:
- command_interpreter.ResolveCommand(short, result)
+ for (short_val, long_val) in abbrevs:
+ command_interpreter.ResolveCommand(short_val, result)
self.assertTrue(result.Succeeded())
- self.assertEqual(long, result.GetOutput())
+ self.assertEqual(long_val, result.GetOutput())
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D14028.38259.patch
Type: text/x-patch
Size: 3597 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20151023/ef72b499/attachment.bin>
More information about the lldb-commits
mailing list