Skip to content

Commit

Permalink
Replace string conversion to use six
Browse files Browse the repository at this point in the history
  • Loading branch information
thombashi committed Feb 4, 2018
1 parent 7564961 commit 8b45a0a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
4 changes: 2 additions & 2 deletions typepy/converter/_bool.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@ def __strict_strtobool(value):
try:
lower_text = value.lower()
except AttributeError:
raise ValueError("invalid value '{}'".format(str(value)))
raise ValueError("invalid value '{}'".format(six.text_type(value)))

binary_value = strtobool(lower_text)
if lower_text not in ["true", "false"]:
raise ValueError("invalid value '{}'".format(str(value)))
raise ValueError("invalid value '{}'".format(six.text_type(value)))

return bool(binary_value)
4 changes: 3 additions & 1 deletion typepy/converter/_realnumber.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@

import decimal

import six

from .._const import DefaultValue
from .._error import TypeConversionError
from ._interface import AbstractValueConverter
Expand All @@ -23,7 +25,7 @@ def __init__(self, value):

def force_convert(self):
if isinstance(self._value, float):
return self.float_class(str(self._value))
return self.float_class(six.text_type(self._value))

try:
return self.float_class(self._value)
Expand Down

0 comments on commit 8b45a0a

Please sign in to comment.