Remove assertion in type_conversions/to_tuple (Python3 prep)

This function starts by an assertion that the given parameter is
a string by checking its type. However, in Python 2, strings can
take 2 forms: type "str", or type "unicode". What we'd like to do
to help migrating this code to Python, is to start using unicode
strings throughout. But then, if we want to keep the assertion,
the problem becomes that we would need to change it to check for
type "unicode", which would be incompatible with Python 3, where
type "unicode" no longer exists.

Since the assertion is not really all that helpful and even
possibly unnecessarily restrictive, this commit simply removes it.

Change-Id: If9014c35b5f2107cfc0bb03338b9a977f44587ba
This commit is contained in:
Joel Brobecker
2021-05-03 05:17:41 -07:00
parent fe24b59970
commit a1ab32afb3

View File

@@ -35,15 +35,12 @@ def to_tuple(val):
PARAMETERS
val: The value to convert, assumed to be a string for now.
An assertion will be raised if this is not the case.
REMARKS
Handling of val being a tuple, or even maybe other types
could be added as well. But there is no need for it at
the moment.
"""
assert isinstance(val, str)
# Handle the case where val is empty separately, as split would
# return a tuple containing an empty string. We want to return
# an empty tuple in this case.