#4351: more appropriate DeprecationWarning stacklevels
This commit is contained in:
parent
e7d149ecf0
commit
a394f2dca3
|
@ -163,13 +163,13 @@ def parse(fp=None, environ=os.environ, keep_blank_values=0, strict_parsing=0):
|
||||||
def parse_qs(qs, keep_blank_values=0, strict_parsing=0):
|
def parse_qs(qs, keep_blank_values=0, strict_parsing=0):
|
||||||
"""Parse a query given as a string argument."""
|
"""Parse a query given as a string argument."""
|
||||||
warn("cgi.parse_qs is deprecated, use urllib.parse.parse_qs instead",
|
warn("cgi.parse_qs is deprecated, use urllib.parse.parse_qs instead",
|
||||||
DeprecationWarning)
|
DeprecationWarning, 2)
|
||||||
return urllib.parse.parse_qs(qs, keep_blank_values, strict_parsing)
|
return urllib.parse.parse_qs(qs, keep_blank_values, strict_parsing)
|
||||||
|
|
||||||
def parse_qsl(qs, keep_blank_values=0, strict_parsing=0):
|
def parse_qsl(qs, keep_blank_values=0, strict_parsing=0):
|
||||||
"""Parse a query given as a string argument."""
|
"""Parse a query given as a string argument."""
|
||||||
warn("cgi.parse_qsl is deprecated, use urllib.parse.parse_qsl instead",
|
warn("cgi.parse_qsl is deprecated, use urllib.parse.parse_qsl instead",
|
||||||
DeprecationWarning)
|
DeprecationWarning, 2)
|
||||||
return urllib.parse.parse_qsl(qs, keep_blank_values, strict_parsing)
|
return urllib.parse.parse_qsl(qs, keep_blank_values, strict_parsing)
|
||||||
|
|
||||||
def parse_multipart(fp, pdict):
|
def parse_multipart(fp, pdict):
|
||||||
|
|
|
@ -136,7 +136,7 @@ class GzipFile:
|
||||||
@property
|
@property
|
||||||
def filename(self):
|
def filename(self):
|
||||||
import warnings
|
import warnings
|
||||||
warnings.warn("use the name attribute", DeprecationWarning)
|
warnings.warn("use the name attribute", DeprecationWarning, 2)
|
||||||
if self.mode == WRITE and self.name[-3:] != ".gz":
|
if self.mode == WRITE and self.name[-3:] != ".gz":
|
||||||
return self.name + ".gz"
|
return self.name + ".gz"
|
||||||
return self.name
|
return self.name
|
||||||
|
|
|
@ -263,13 +263,13 @@ class _InternalDict(dict):
|
||||||
raise AttributeError(attr)
|
raise AttributeError(attr)
|
||||||
from warnings import warn
|
from warnings import warn
|
||||||
warn("Attribute access from plist dicts is deprecated, use d[key] "
|
warn("Attribute access from plist dicts is deprecated, use d[key] "
|
||||||
"notation instead", PendingDeprecationWarning)
|
"notation instead", PendingDeprecationWarning, 2)
|
||||||
return value
|
return value
|
||||||
|
|
||||||
def __setattr__(self, attr, value):
|
def __setattr__(self, attr, value):
|
||||||
from warnings import warn
|
from warnings import warn
|
||||||
warn("Attribute access from plist dicts is deprecated, use d[key] "
|
warn("Attribute access from plist dicts is deprecated, use d[key] "
|
||||||
"notation instead", PendingDeprecationWarning)
|
"notation instead", PendingDeprecationWarning, 2)
|
||||||
self[attr] = value
|
self[attr] = value
|
||||||
|
|
||||||
def __delattr__(self, attr):
|
def __delattr__(self, attr):
|
||||||
|
@ -279,14 +279,14 @@ class _InternalDict(dict):
|
||||||
raise AttributeError(attr)
|
raise AttributeError(attr)
|
||||||
from warnings import warn
|
from warnings import warn
|
||||||
warn("Attribute access from plist dicts is deprecated, use d[key] "
|
warn("Attribute access from plist dicts is deprecated, use d[key] "
|
||||||
"notation instead", PendingDeprecationWarning)
|
"notation instead", PendingDeprecationWarning, 2)
|
||||||
|
|
||||||
class Dict(_InternalDict):
|
class Dict(_InternalDict):
|
||||||
|
|
||||||
def __init__(self, **kwargs):
|
def __init__(self, **kwargs):
|
||||||
from warnings import warn
|
from warnings import warn
|
||||||
warn("The plistlib.Dict class is deprecated, use builtin dict instead",
|
warn("The plistlib.Dict class is deprecated, use builtin dict instead",
|
||||||
PendingDeprecationWarning)
|
PendingDeprecationWarning, 2)
|
||||||
super().__init__(**kwargs)
|
super().__init__(**kwargs)
|
||||||
|
|
||||||
|
|
||||||
|
@ -299,7 +299,7 @@ class Plist(_InternalDict):
|
||||||
def __init__(self, **kwargs):
|
def __init__(self, **kwargs):
|
||||||
from warnings import warn
|
from warnings import warn
|
||||||
warn("The Plist class is deprecated, use the readPlist() and "
|
warn("The Plist class is deprecated, use the readPlist() and "
|
||||||
"writePlist() functions instead", PendingDeprecationWarning)
|
"writePlist() functions instead", PendingDeprecationWarning, 2)
|
||||||
super().__init__(**kwargs)
|
super().__init__(**kwargs)
|
||||||
|
|
||||||
def fromFile(cls, pathOrFile):
|
def fromFile(cls, pathOrFile):
|
||||||
|
|
|
@ -51,7 +51,7 @@ def maketrans(frm: bytes, to: bytes) -> bytes:
|
||||||
"""
|
"""
|
||||||
import warnings
|
import warnings
|
||||||
warnings.warn("string.maketrans is deprecated, use bytes.maketrans instead",
|
warnings.warn("string.maketrans is deprecated, use bytes.maketrans instead",
|
||||||
DeprecationWarning)
|
DeprecationWarning, 2)
|
||||||
if len(frm) != len(to):
|
if len(frm) != len(to):
|
||||||
raise ValueError("maketrans arguments must have same length")
|
raise ValueError("maketrans arguments must have same length")
|
||||||
if not (isinstance(frm, bytes) and isinstance(to, bytes)):
|
if not (isinstance(frm, bytes) and isinstance(to, bytes)):
|
||||||
|
|
Loading…
Reference in New Issue