Skip to content
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

bpo-32072: Fix issues with binary plists. #4455

Merged
merged 3 commits into from
Nov 30, 2017

Conversation

serhiy-storchaka
Copy link
Member

@serhiy-storchaka serhiy-storchaka commented Nov 18, 2017

  • Fixed saving bytearrays.
  • Identical objects will be saved only once.
  • Equal references will be load as identical objects.
  • Added support for saving and loading recursive data structures.

https://bugs.python.org/issue32072

* Fixed saving bytearrays.
* Identical objects will be saved only once.
* Equal references will be load as identical objects.
* Added support for saving and loading recursive data structures.
Copy link
Contributor

@ronaldoussoren ronaldoussoren left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me.

I have two small comments, but the code is fine even if those are not addressed.

Lib/plistlib.py Outdated
result = []
self._objects[ref] = result
result.extend(self._read_object(x) for x in obj_refs)
return result
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why the return statement? This saves a duplicate store to self._objects[ref] at the end of the method, but makes handling this token different from he previous ones.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The tokens "array" and "dict" are special. Since they are containers and can contain a cyclic reference to itself, self._objects[ref] should be set before reading the content. These tokens already handled different from tokens for scalar types, and the difference will be kept even if remove the return statement here.

Lib/plistlib.py Outdated
for k, o in zip(key_refs, obj_refs):
result[self._read_object(self._object_offsets[k])
] = self._read_object(self._object_offsets[o])
result[self._read_object(k)] = self._read_object(o)
return result
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess the same applies to this (existing) return statement.

@serhiy-storchaka serhiy-storchaka merged commit a897aee into python:master Nov 30, 2017
@miss-islington
Copy link
Contributor

Thanks @serhiy-storchaka for the PR 🌮🎉.. I'm working now to backport this PR to: 3.6.
🐍🍒⛏🤖

@serhiy-storchaka serhiy-storchaka deleted the plistlib-refs branch November 30, 2017 21:26
miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Nov 30, 2017
* Fixed saving bytearrays.
* Identical objects will be saved only once.
* Equal references will be load as identical objects.
* Added support for saving and loading recursive data structures.
(cherry picked from commit a897aee)
@bedevere-bot
Copy link

GH-4654 is a backport of this pull request to the 3.6 branch.

@serhiy-storchaka
Copy link
Member Author

Thank you for your review @ronaldoussoren.

serhiy-storchaka added a commit to serhiy-storchaka/cpython that referenced this pull request Nov 30, 2017
* Fixed saving bytearrays.
* Identical objects will be saved only once.
* Equal references will be load as identical objects.
* Added support for saving and loading recursive data structures.
(cherry picked from commit a897aee)
serhiy-storchaka added a commit to serhiy-storchaka/cpython that referenced this pull request Nov 30, 2017
* Fixed saving bytearrays.
* Identical objects will be saved only once.
* Equal references will be load as identical objects.
* Added support for saving and loading recursive data structures..
(cherry picked from commit a897aee)
serhiy-storchaka pushed a commit that referenced this pull request Nov 30, 2017
* Fixed saving bytearrays.
* Identical objects will be saved only once.
* Equal references will be load as identical objects.
* Added support for saving and loading recursive data structures.
(cherry picked from commit a897aee)
larryhastings pushed a commit that referenced this pull request Jan 22, 2018
* [3.4] bpo-32072: Fix issues with binary plists. (GH-4455)

* Fixed saving bytearrays.
* Identical objects will be saved only once.
* Equal references will be load as identical objects.
* Added support for saving and loading recursive data structures..
(cherry picked from commit a897aee)

* Fix implementation dependent assertion in test_plistlib. (#4813)

It is failed with an advanced optimizer.
larryhastings pushed a commit that referenced this pull request Jan 23, 2018
* [3.5] bpo-32072: Fix issues with binary plists. (GH-4455)

* Fixed saving bytearrays.
* Identical objects will be saved only once.
* Equal references will be load as identical objects.
* Added support for saving and loading recursive data structures.
(cherry picked from commit a897aee)

* Fix implementation dependent assertion in test_plistlib. (#4813)

It is failed with an advanced optimizer.
serhiy-storchaka pushed a commit that referenced this pull request Nov 1, 2019
* Add missing test class (mistake in GH-4455)

* Increase coverage with 4 more test cases

* Rename neg_uid to huge_uid in test_modified_uid_huge

* Replace test_main() with unittest.main()

* Update plistlib docs
serhiy-storchaka pushed a commit that referenced this pull request Nov 2, 2019
* Add missing test class (mistake in GH-4455)

* Increase coverage with 4 more test cases

* Rename neg_uid to huge_uid in test_modified_uid_huge

* Replace test_main() with unittest.main()

* Update plistlib docs.
(cherry picked from commit d0d9f7c)

Co-authored-by: Jon Janzen <jjjonjanzen@gmail.com>
jacobneiltaylor pushed a commit to jacobneiltaylor/cpython that referenced this pull request Dec 5, 2019
* Add missing test class (mistake in pythonGH-4455)

* Increase coverage with 4 more test cases

* Rename neg_uid to huge_uid in test_modified_uid_huge

* Replace test_main() with unittest.main()

* Update plistlib docs
shihai1991 pushed a commit to shihai1991/cpython that referenced this pull request Jan 31, 2020
* Add missing test class (mistake in pythonGH-4455)

* Increase coverage with 4 more test cases

* Rename neg_uid to huge_uid in test_modified_uid_huge

* Replace test_main() with unittest.main()

* Update plistlib docs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type-bug An unexpected behavior, bug, or error type-security A security issue
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants