def ensure_timezone(func, argname, arg):
 if isinstance(arg, tzinfo):
  return arg
 if isinstance(arg, string_types):
  return timezone(arg)
 raise TypeError("{func}() couldn't convert argument {argname}={arg!r} to a timezone.".format(func=_qualified_name(func), argname=argname, arg=arg))

def ensure_timezone ( func , argname , arg ) : if isinstance ( arg , tzinfo ) : return arg if isinstance ( arg , string_types ) : return timezone ( arg ) raise TypeError ( "{func}() couldn't convert argument {argname}={arg!r} to a timezone." . format ( func = _qualified_name ( func ) , argname = argname , arg = arg ) )
argument preprocessor that converts the input into a tzinfo object .