Repository navigation
gh-83913: encode UIDs in XML as CF$UID - #18622
Artoria2e5 wants to merge 17 commits into
Conversation
|
Uhh, hello? @serhiy-storchaka care to take a look? Just in case someone quotes "NSKeyedArchiver only does binary" - it doesn't. The swift version accepts both XML and Binary as output (https://github.com/apple/swift-corelibs-foundation/blob/master/Sources/Foundation/NSKeyedArchiver.swift) and they got plenty of test cases with XML CF$UID at https://github.com/apple/swift-corelibs-foundation/tree/2a5bc4d8a0b073532e60410682f5eb8f00144870/Tests/Foundation/Resources. |
There was a problem hiding this comment.
Consider this more advise than a review, but since I wrote the PR for plistlib.UID support I thought I might chime in.
Just in case someone quotes "NSKeyedArchiver only does binary" - it doesn't
Yes I realize this now and regret the error, I just recently hit the problem this PR is trying to address.
bigfootjon
left a comment
There was a problem hiding this comment.
I have a few more thoughts (sorry this took me so long)
I don't actually have commit rights in cpython so take these suggestions with a grain of salt.
|
It's quite cool that the PR is still alive -- thanks for the edits @arhadthedev! Just the sort of motivation I need to actually see things to completion :) In other news the CLA thing is giving me Internal Server Error. I will use the manual form. |
|
Just ran into the same issue of files with errors occuring when writing PLists containing UIDs and this PR works perfectly. Is there anything one can help with for merging this fix? Btw. the resulting files are identical w.r.t. UIDs to what |
This commit lets the XML writer encode UIDs in XML as a dictionary with a single key CF$UID pointing to an integer value. This is how Apple handles UIDs when writing XMLs. It appears significantly harder to get the parser to replace a value it has just written, so I am not attempting it yet. I mean, I know how to replace it when the parent is a list, but when it is a dictionary it seems that I will need some extra key-saving along the stack.
The apple ref does not mention UID at all. Use a source that does.
|
Another advantage of this PR is btw. that it also fixes loading XML files that contain UIDs, e.g. generated by |
No idea if it works. It's all NS to me!
|
Aight, I should be able to get to a mac some time soon. |
|
This PR is stale because it has been open for 30 days with no activity. |
# Conflicts: # Doc/library/plistlib.rst
Documentation build overview
204 files changed ·
|
Encode UID objects as a dictionary with a single CFUID_KEY key when writing XML, and convert such dictionaries back to UID objects when parsing. Track the key of the enclosing dictionary per dict so that nested structures are handled correctly. Also document CFUID_KEY, add XML tests, and drop a broken, unused fragment from the macOS testdata generator. Co-Authored-By: Skadi "Skadeep" Deepseek <noreply@deepseek.com>
This commit lets the XML writer encode UIDs in XML as a dictionary with a single key CF$UID pointing to an integer value. This is how Apple handles UIDs when writing XMLs.
It also makes the XML parser convert such dictionaries back to :class:
plistlib.UIDobjects, so XML plists round-trip. The parse side handles UIDs nested in dicts and arrays, and dictionaries that merely contain a CF$UID key alongside other keys are left alone.Updated in November 2026: bumped the documentation version entries to 3.16, documented :data:
plistlib.CFUID_KEY, fixed the NEWS entry's line endings (which broke the "generated files" CI job), made the parser track the enclosing key per dictionary instead of a single reused attribute, added tests for the XML format, and removed a broken, unused fragment from the macOS test-data generator. AI assistance was used for this update.