New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Plistlib outputs empty data tags when deeply nested #61555
Comments
To reproduce: Compare to: It looks like the max line length calculation in the Data class is causing the output to be empty once you get nested far enough. |
My second print should have been: print plistlib.writePlistToString([[[[[[[[{'test': plistlib.Data('aaaaaa')}]]]]]]]]) |
Quick source inspection suggests this is present in the latest version. |
We should limit the indentation to be less than the maximal line length. |
Looks like plistlib.writePlistToString is no loger in the plistlib. |
On 3.x it's called writePlistToBytes, and it seems to have the same issue. |
Yep you are correct.
>>>
plistlib.readPlistFromBytes(plistlib.writePlistToBytes([[[[[[[[{'test': plistlib.Data(b'aaaaaa')}]]]]]]]]))
[[[[[[[[{'test': Data(b'aaaaaa')}]]]]]]]]
>>> plistlib.readPlistFromBytes(plistlib.writePlistToBytes([[[[[[[[[{'test': plistlib.Data(b'aaaaaa')}]]]]]]]]]))
[[[[[[[[[{'test': Data(b'')}]]]]]]]]] I presume we want to raise a ValueError if the indentation is more than the maximal line length. |
If possible it would be better to still generate a valid output, possibly by limiting the indentation or removing it after a certain point. |
I agree that plistlib shouldn't raise an exception for data that can represented as a valid plist file. I've checked that the Cocoa class for generating plist files will happily create a plist file when the data is nested 100 levels deep. In that case NSData values generate lines of 12 characters long. An unrelated issue: PlistWriter.writeValue should treat bytes instances the same as Data instances in Python 3. That would be a (small) feature enhencement, and hence can only be done for Python 3.4. |
The attach patch should fix the issue (but there needs to be a unittest as well). |
Adding tests. |
The tests look good, thanks for writing them. |
New changeset a389700fbc74 by Ronald Oussoren in branch '2.7': New changeset 6a8cb4875ac6 by Ronald Oussoren in branch '3.3': New changeset e0c0bcd60033 by Ronald Oussoren in branch 'default': |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: