MCPcopy Index your code
hub / github.com/RustPython/RustPython / _coerce_args

Function _coerce_args

Lib/urllib/parse.py:119–133  ·  view source on GitHub ↗
(*args)

Source from the content-addressed store, hash-verified

117 return tuple(x.decode(encoding, errors) if x else '' for x in args)
118
119def _coerce_args(*args):
120 # Invokes decode if necessary to create str args
121 # and returns the coerced inputs along with
122 # an appropriate result coercion function
123 # - noop for str inputs
124 # - encoding function otherwise
125 str_input = isinstance(args[0], str)
126 for arg in args[1:]:
127 # We special-case the empty string to support the
128 # "scheme=''" default argument to some functions
129 if arg and isinstance(arg, str) != str_input:
130 raise TypeError("Cannot mix str and non-str arguments")
131 if str_input:
132 return args + (_noop,)
133 return _decode_args(args) + (_encode_result,)
134
135# Result objects are more helpful than simple tuples
136class _ResultMixinStr(object):

Callers 6

urlparseFunction · 0.85
urlsplitFunction · 0.85
urlunparseFunction · 0.85
urlunsplitFunction · 0.85
urljoinFunction · 0.85
urldefragFunction · 0.85

Calls 2

isinstanceFunction · 0.85
_decode_argsFunction · 0.85

Tested by

no test coverage detected