Fix some stubs in urllib.parse (#334)

* urllib.parse: Make return type of unquote_from_bytes str.

* urllib.parse: Reject encoding when quote is passed bytes.

encoding and errors must not be supplied to quote_plus and
quote if the first parameter is a bytes, or a TypeError is raised.
So overload quote and do not put encoding and errors in the
version where bytes is the first parameter.

quote and quote_plus also allow string and safe to be of different
types.  Also allow that in the stubs.
This commit is contained in:
Eklavya Sharma
2016-07-05 02:23:46 +05:30
committed by Guido van Rossum
parent 37e42bfa96
commit a424eeb1f8

View File

@@ -88,11 +88,17 @@ def parse_qs(qs: str, keep_blank_values : bool = ..., strict_parsing : bool = ..
def parse_qsl(qs: str, keep_blank_values: bool = ..., strict_parsing: bool = ..., encoding: str = ..., errors: str = ...) -> List[Tuple[str,str]]: ...
def quote(string: AnyStr, safe: AnyStr = ..., encoding: str = ..., errors: str = ...) -> str: ...
@overload
def quote(string: str, safe: AnyStr = ..., encoding: str = ..., errors: str = ...) -> str: ...
@overload
def quote(string: bytes, safe: AnyStr = ...) -> str: ...
def quote_from_bytes(bs: bytes, safe: AnyStr = ...) -> bytes: ...
def quote_from_bytes(bs: bytes, safe: AnyStr = ...) -> str: ...
def quote_plus(string: AnyStr, safe: AnyStr = ..., encoding: str = ..., errors: str = ...) -> str: ...
@overload
def quote_plus(string: str, safe: AnyStr = ..., encoding: str = ..., errors: str = ...) -> str: ...
@overload
def quote_plus(string: bytes, safe: AnyStr = ...) -> str: ...
def unquote(string: str, encoding: str = ..., errors: str = ...) -> str: ...