fixed potential wrong config param type resolution (#102)

This fixes an issue that can potentially happen with unordered dicts
in python3. A boolean typed config parameter can be handles as
integer dependin on the order of iteration in getParam(value).

The reason for this is because True/False are both, bool and int
at the same time, however its not the other way around.
pull/104/head
Levente Polyak 9 years ago committed by Zach Riggle
parent d816e103a6
commit 73b58dae65

@ -21,12 +21,17 @@ from __future__ import unicode_literals
import sys
import types
import collections
import six
import gdb
TYPES = {}
TYPES = collections.OrderedDict()
# The value is a plain boolean.
# The Python boolean values, True and False are the only valid values.
TYPES[bool] = gdb.PARAM_BOOLEAN
# The value is an integer.
# This is like PARAM_INTEGER, except 0 is interpreted as itself.
@ -40,10 +45,6 @@ for type in six.integer_types:
for type in six.string_types:
TYPES[type] = gdb.PARAM_STRING
# The value is a plain boolean.
# The Python boolean values, True and False are the only valid values.
TYPES[bool] = gdb.PARAM_BOOLEAN
def getParam(value):
for k,v in TYPES.items():
if isinstance(value, k):

Loading…
Cancel
Save