B
Y @ sf d Z ddlmZmZ ddlZddlmZmZmZm Z m
Z
dd Zdd
dZdd
Z
dd Zdd ZdS )z
raven.utils.encoding
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
:copyright: (c) 2010-2012 by the Sentry Team, see AUTHORS for more details.
:license: BSD, see LICENSE for more details.
)absolute_importunicode_literalsN)
integer_types text_typebinary_typestring_typesPY2c C s4 ddl }ddl}t| ttdt||j|j|jf S )zDetermine if the object instance is of a protected type.
Objects of protected types are preserved as-is when passed to
force_text(strings_only=True).
r N)Decimaldatetime
isinstancer typefloatZdateZtime)objr r
r E/opt/alt/python37/lib/python3.7/site-packages/raven/utils/encoding.pyis_protected_type s r utf-8Fstrictc
s t | tr| S rt| r| S yft | tsvt| dr>| } qtsdt | trZt| } qtt| } qtt| } n| } W nT t k
r } z6t | t
st |j nd fdd| D } W dd}~X Y nX | S )z
Similar to smart_text, except that lazy instances are resolved to
strings, rather than kept as lazy objects.
If strings_only is True, don't convert (some) non-string-like objects.
__unicode__ c s g | ]}t | qS r )
force_text).0arg)encodingerrorsstrings_onlyr r
<listcomp>C s zforce_text.<locals>.<listcomp>N)
r r r r hasattrr r bytesdecodeUnicodeDecodeError Exceptionargsjoin)sr r r er )r r r r r s(
r c C s ddl m} tdt || S )Nr ) transformz5You should switch to raven.utils.serializer.transform)Zraven.utils.serializerr&