changeset: 91779:09746dc1a3b4 branch: 3.4 parent: 91777:825137d0d4ca user: Serhiy Storchaka date: Wed Jul 23 18:49:31 2014 +0300 files: Lib/plistlib.py Lib/test/test_plistlib.py Misc/NEWS description: Issue #21888: plistlib's load() and loads() now work if the fmt parameter is specified. diff -r 825137d0d4ca -r 09746dc1a3b4 Lib/plistlib.py --- a/Lib/plistlib.py Wed Jul 23 18:41:21 2014 +0300 +++ b/Lib/plistlib.py Wed Jul 23 18:49:31 2014 +0300 @@ -984,18 +984,16 @@ fp.seek(0) for info in _FORMATS.values(): if info['detect'](header): - p = info['parser']( - use_builtin_types=use_builtin_types, - dict_type=dict_type, - ) + P = info['parser'] break else: raise InvalidFileException() else: - p = _FORMATS[fmt]['parser'](use_builtin_types=use_builtin_types) + P = _FORMATS[fmt]['parser'] + p = P(use_builtin_types=use_builtin_types, dict_type=dict_type) return p.parse(fp) diff -r 825137d0d4ca -r 09746dc1a3b4 Lib/test/test_plistlib.py --- a/Lib/test/test_plistlib.py Wed Jul 23 18:41:21 2014 +0300 +++ b/Lib/test/test_plistlib.py Wed Jul 23 18:49:31 2014 +0300 @@ -207,6 +207,9 @@ for fmt in ALL_FORMATS: with self.subTest(fmt=fmt): pl = self._create(fmt=fmt) + pl2 = plistlib.loads(TESTDATA[fmt], fmt=fmt) + self.assertEqual(dict(pl), dict(pl2), + "generated data was not identical to Apple's output") pl2 = plistlib.loads(TESTDATA[fmt]) self.assertEqual(dict(pl), dict(pl2), "generated data was not identical to Apple's output") @@ -217,6 +220,8 @@ b = BytesIO() pl = self._create(fmt=fmt) plistlib.dump(pl, b, fmt=fmt) + pl2 = plistlib.load(BytesIO(b.getvalue()), fmt=fmt) + self.assertEqual(dict(pl), dict(pl2)) pl2 = plistlib.load(BytesIO(b.getvalue())) self.assertEqual(dict(pl), dict(pl2)) diff -r 825137d0d4ca -r 09746dc1a3b4 Misc/NEWS --- a/Misc/NEWS Wed Jul 23 18:41:21 2014 +0300 +++ b/Misc/NEWS Wed Jul 23 18:49:31 2014 +0300 @@ -27,6 +27,9 @@ Library ------- +- Issue #21888: plistlib's load() and loads() now work if the fmt parameter is + specified. + - Issue #21044: tarfile.open() now handles fileobj with an integer 'name' attribute. Based on patch by Antoine Pietri.