4747"""
4848__all__ = [
4949 "readPlist" , "writePlist" , "readPlistFromBytes" , "writePlistToBytes" ,
50- "Plist" , " Data" , "Dict " , "InvalidFileException" , "FMT_XML" , "FMT_BINARY" ,
50+ "Data" , "InvalidFileException" , "FMT_XML" , "FMT_BINARY" ,
5151 "load" , "dump" , "loads" , "dumps"
5252]
5353
7676#
7777
7878
79- class _InternalDict (dict ):
80-
81- # This class is needed while Dict is scheduled for deprecation:
82- # we only need to warn when a *user* instantiates Dict or when
83- # the "attribute notation for dict keys" is used.
84- __slots__ = ()
85-
86- def __getattr__ (self , attr ):
87- try :
88- value = self [attr ]
89- except KeyError :
90- raise AttributeError (attr )
91- warn ("Attribute access from plist dicts is deprecated, use d[key] "
92- "notation instead" , DeprecationWarning , 2 )
93- return value
94-
95- def __setattr__ (self , attr , value ):
96- warn ("Attribute access from plist dicts is deprecated, use d[key] "
97- "notation instead" , DeprecationWarning , 2 )
98- self [attr ] = value
99-
100- def __delattr__ (self , attr ):
101- try :
102- del self [attr ]
103- except KeyError :
104- raise AttributeError (attr )
105- warn ("Attribute access from plist dicts is deprecated, use d[key] "
106- "notation instead" , DeprecationWarning , 2 )
107-
108-
109- class Dict (_InternalDict ):
110-
111- def __init__ (self , ** kwargs ):
112- warn ("The plistlib.Dict class is deprecated, use builtin dict instead" ,
113- DeprecationWarning , 2 )
114- super ().__init__ (** kwargs )
115-
116-
11779@contextlib .contextmanager
11880def _maybe_open (pathOrFile , mode ):
11981 if isinstance (pathOrFile , str ):
@@ -124,31 +86,6 @@ def _maybe_open(pathOrFile, mode):
12486 yield pathOrFile
12587
12688
127- class Plist (_InternalDict ):
128- """This class has been deprecated. Use dump() and load()
129- functions instead, together with regular dict objects.
130- """
131-
132- def __init__ (self , ** kwargs ):
133- warn ("The Plist class is deprecated, use the load() and "
134- "dump() functions instead" , DeprecationWarning , 2 )
135- super ().__init__ (** kwargs )
136-
137- @classmethod
138- def fromFile (cls , pathOrFile ):
139- """Deprecated. Use the load() function instead."""
140- with _maybe_open (pathOrFile , 'rb' ) as fp :
141- value = load (fp )
142- plist = cls ()
143- plist .update (value )
144- return plist
145-
146- def write (self , pathOrFile ):
147- """Deprecated. Use the dump() function instead."""
148- with _maybe_open (pathOrFile , 'wb' ) as fp :
149- dump (self , fp )
150-
151-
15289def readPlist (pathOrFile ):
15390 """
15491 Read a .plist from a path or file. pathOrFile should either
@@ -160,8 +97,7 @@ def readPlist(pathOrFile):
16097 DeprecationWarning , 2 )
16198
16299 with _maybe_open (pathOrFile , 'rb' ) as fp :
163- return load (fp , fmt = None , use_builtin_types = False ,
164- dict_type = _InternalDict )
100+ return load (fp , fmt = None , use_builtin_types = False )
165101
166102def writePlist (value , pathOrFile ):
167103 """
@@ -184,8 +120,7 @@ def readPlistFromBytes(data):
184120 """
185121 warn ("The readPlistFromBytes function is deprecated, use loads() instead" ,
186122 DeprecationWarning , 2 )
187- return load (BytesIO (data ), fmt = None , use_builtin_types = False ,
188- dict_type = _InternalDict )
123+ return load (BytesIO (data ), fmt = None , use_builtin_types = False )
189124
190125
191126def writePlistToBytes (value ):
0 commit comments