Skip to content

Commit

Permalink
Adjust cherry-pick for Python2
Browse files Browse the repository at this point in the history
Add InvalidFileException class.
RaisesRegex is RaisesRegexp in python2.
plistlib.loads is in the python3 version of plistlib,
but there are too many changes to backport this simply.
  • Loading branch information
icanhasmath committed Mar 14, 2024
1 parent 31fdfbf commit d8d3f10
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
5 changes: 5 additions & 0 deletions Lib/plistlib.py
Original file line number Diff line number Diff line change
Expand Up @@ -479,3 +479,8 @@ def end_data(self):
self.addObject(Data.fromBase64(self.getData()))
def end_date(self):
self.addObject(_dateFromString(self.getData()))


class InvalidFileException (ValueError):
def __init__(self, message="Invalid file"):
ValueError.__init__(self, message)
4 changes: 2 additions & 2 deletions Lib/test/test_plistlib.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,9 +209,9 @@ def test_nondictroot(self):
self.assertEqual(test2, result2)

def test_xml_plist_with_entity_decl(self):
with self.assertRaisesRegex(plistlib.InvalidFileException,
with self.assertRaisesRegexp(plistlib.InvalidFileException,
"XML entity declarations are not supported"):
plistlib.loads(XML_PLIST_WITH_ENTITY, fmt=plistlib.FMT_XML)
plistlib.readPlistFromString(XML_PLIST_WITH_ENTITY)

def test_main():
test_support.run_unittest(TestPlistlib)
Expand Down

0 comments on commit d8d3f10

Please sign in to comment.