diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2017-05-15 10:21:31 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-05-15 10:21:31 (GMT) |
commit | edef358ed6d05f927bf1636cc5a920a9d868b131 (patch) | |
tree | 287ae68661a797aa09b0aa979f776a5329b7c881 /Lib/plistlib.py | |
parent | d812eb731d886065bdd9bc94a3f0e5dfdcd671a4 (diff) | |
download | cpython-edef358ed6d05f927bf1636cc5a920a9d868b131.zip cpython-edef358ed6d05f927bf1636cc5a920a9d868b131.tar.gz cpython-edef358ed6d05f927bf1636cc5a920a9d868b131.tar.bz2 |
bpo-29196: Removed old-deprecated classes Plist, Dict and _InternalDict (#488)
in the plistlib module. Dict values in the result of functions
readPlist() and readPlistFromBytes() are now exact dicts.
Diffstat (limited to 'Lib/plistlib.py')
-rw-r--r-- | Lib/plistlib.py | 71 |
1 files changed, 3 insertions, 68 deletions
diff --git a/Lib/plistlib.py b/Lib/plistlib.py index 09be5fd..8262fb0 100644 --- a/Lib/plistlib.py +++ b/Lib/plistlib.py @@ -47,7 +47,7 @@ Parse Plist example: """ __all__ = [ "readPlist", "writePlist", "readPlistFromBytes", "writePlistToBytes", - "Plist", "Data", "Dict", "InvalidFileException", "FMT_XML", "FMT_BINARY", + "Data", "InvalidFileException", "FMT_XML", "FMT_BINARY", "load", "dump", "loads", "dumps" ] @@ -76,44 +76,6 @@ globals().update(PlistFormat.__members__) # -class _InternalDict(dict): - - # This class is needed while Dict is scheduled for deprecation: - # we only need to warn when a *user* instantiates Dict or when - # the "attribute notation for dict keys" is used. - __slots__ = () - - def __getattr__(self, attr): - try: - value = self[attr] - except KeyError: - raise AttributeError(attr) - warn("Attribute access from plist dicts is deprecated, use d[key] " - "notation instead", DeprecationWarning, 2) - return value - - def __setattr__(self, attr, value): - warn("Attribute access from plist dicts is deprecated, use d[key] " - "notation instead", DeprecationWarning, 2) - self[attr] = value - - def __delattr__(self, attr): - try: - del self[attr] - except KeyError: - raise AttributeError(attr) - warn("Attribute access from plist dicts is deprecated, use d[key] " - "notation instead", DeprecationWarning, 2) - - -class Dict(_InternalDict): - - def __init__(self, **kwargs): - warn("The plistlib.Dict class is deprecated, use builtin dict instead", - DeprecationWarning, 2) - super().__init__(**kwargs) - - @contextlib.contextmanager def _maybe_open(pathOrFile, mode): if isinstance(pathOrFile, str): @@ -124,31 +86,6 @@ def _maybe_open(pathOrFile, mode): yield pathOrFile -class Plist(_InternalDict): - """This class has been deprecated. Use dump() and load() - functions instead, together with regular dict objects. - """ - - def __init__(self, **kwargs): - warn("The Plist class is deprecated, use the load() and " - "dump() functions instead", DeprecationWarning, 2) - super().__init__(**kwargs) - - @classmethod - def fromFile(cls, pathOrFile): - """Deprecated. Use the load() function instead.""" - with _maybe_open(pathOrFile, 'rb') as fp: - value = load(fp) - plist = cls() - plist.update(value) - return plist - - def write(self, pathOrFile): - """Deprecated. Use the dump() function instead.""" - with _maybe_open(pathOrFile, 'wb') as fp: - dump(self, fp) - - def readPlist(pathOrFile): """ Read a .plist from a path or file. pathOrFile should either @@ -160,8 +97,7 @@ def readPlist(pathOrFile): DeprecationWarning, 2) with _maybe_open(pathOrFile, 'rb') as fp: - return load(fp, fmt=None, use_builtin_types=False, - dict_type=_InternalDict) + return load(fp, fmt=None, use_builtin_types=False) def writePlist(value, pathOrFile): """ @@ -184,8 +120,7 @@ def readPlistFromBytes(data): """ warn("The readPlistFromBytes function is deprecated, use loads() instead", DeprecationWarning, 2) - return load(BytesIO(data), fmt=None, use_builtin_types=False, - dict_type=_InternalDict) + return load(BytesIO(data), fmt=None, use_builtin_types=False) def writePlistToBytes(value): |