(*args)
| 117 | return tuple(x.decode(encoding, errors) if x else '' for x in args) |
| 118 | |
| 119 | def _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 |
| 136 | class _ResultMixinStr(object): |
no test coverage detected