• L
    utils.astring: Allow converting any object "to_text" · 1828ccef
    Lukáš Doktor 提交于
    Previously the "astring.to_text" correctly handled bytes or string
    types. This commit allows using it to convert anything to text. The
    use-case is to turn any object into string in a safe manner, which is
    useful to replace "str(...)" calls on python2 which fails with unicode
    while working well on py3 as well.
    
    Note it's not necessary to convert all "str(...)" calls as objects that
    use "__repr__" are usually safe and "astring.to_text" becomes equivalent
    of "str(...)", but for objects (eg. Exception, ...) the
    "astring.to_text" is required.
    Signed-off-by: NLukáš Doktor <ldoktor@redhat.com>
    1828ccef
test_astring.py 5.6 KB