def _patch_naive_datetimes(obj):
    '\n    If a naive datetime is found, attach local time.\n\n    Msgpack can only serialize datetimes with tzinfo.\n    '
    if hasattr(obj, 'items'):
        patched_obj = {}
        for (k, v) in obj.items():
            patched_obj[k] = _patch_naive_datetimes(v)
    elif ((not isinstance(obj, str)) and isinstance(obj, collections.abc.Iterable)):
        patched_obj = []
        for item in obj:
            patched_obj.append(_patch_naive_datetimes(item))
    elif (isinstance(obj, datetime) and (obj.tzinfo is None)):
        patched_obj = obj.astimezone(_LOCAL_TZINFO)
    else:
        patched_obj = obj
    return patched_obj
If a naive datetime is found, attach local time.

Msgpack can only serialize datetimes with tzinfo.
def _patch_naive_datetimes(obj):
    '\n    If a naive datetime is found, attach local time.\n\n    Msgpack can only serialize datetimes with tzinfo.\n    '
    if hasattr(obj, 'items'):
        patched_obj = {}
        for (k, v) in obj.items():
            patched_obj[k] = _patch_naive_datetimes(v)
    elif ((not isinstance(obj, str)) and isinstance(obj, collections.abc.Iterable)):
        patched_obj = []
        for item in obj:
            patched_obj.append(_patch_naive_datetimes(item))
    elif (isinstance(obj, datetime) and (obj.tzinfo is None)):
        patched_obj = obj.astimezone(_LOCAL_TZINFO)
    else:
        patched_obj = obj
    return patched_obj