-
Notifications
You must be signed in to change notification settings - Fork 996
Core: Add restricted_dumps
helper
#5117
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
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense to me
Co-authored-by: Doug Hoskisson <[email protected]>
I'm gonna merge this at the start of next release cycle |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looked over code
local generated, served, and played a game
This does make dumping quite a bit slower, and in some situations I feel it should never fail, like webhost upload. - where the increased performance cost would also be among the highest impacted. |
I think the two in |
I don't know which serialization you mean by "webhost upload". We've seen it fail in at least 3 of these places. But, yeah maybe some of them don't need it. |
What is this fixing or adding?
Adds a
restricted_dumps
method to Utils corresponding torestricted_loads
which errors if the object cannot be unpickled withrestricted_loads
, and replaces some current uses ofpickle.dumps
with it. I'm not positive if some of these uses might be safe to not have the check, although they might also be able to remove the corresponding use ofrestricted_loads
if so. There seemed to be no relevant uses ofpickle.dump
to a file instead, but it might be better to implement aRestrictedPickler
class instead of just the function if the flexibility is desired.I also changed the
test_pickle_dumps
test to also try getting the default withfrom_text
since this value might be different than the one gotten withfrom_any(option.default)
and cause issues.How was this tested?
I tested the changes with a problem that was present in the satisfactory world options that caused it to error when generating a single player game from the options page. It fails immediately in this case instead of first trying to generate and then failing later when unpickling. I also ran the updated test on the world and it was able to find the error whereas the world passed the test before.
If this makes graphical changes, please attach screenshots.
🚫🥒