MCPcopy Index your code
hub / github.com/python/cpython / _coerce_args

Function _coerce_args

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

Source from the content-addressed store, hash-verified

118 for x in args)
119
120def _coerce_args(*args):
121 # Invokes decode if necessary to create str args
122 # and returns the coerced inputs along with
123 # an appropriate result coercion function
124 # - noop for str inputs
125 # - encoding function otherwise
126 str_input = None
127 for arg in args:
128 if arg:
129 if str_input is None:
130 str_input = isinstance(arg, str)
131 else:
132 if isinstance(arg, str) != str_input:
133 raise TypeError("Cannot mix str and non-str arguments")
134 if str_input is None:
135 for arg in args:
136 if arg is not None:
137 str_input = isinstance(arg, str)
138 break
139 if str_input is not False:
140 return args + (_noop,)
141 return _decode_args(args) + (_encode_result,)
142
143# Result objects are more helpful than simple tuples
144class _ResultMixinStr(object):

Callers 6

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

Calls 1

_decode_argsFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…