Thanks to visit codestin.com
Credit goes to github.com

Skip to content

gh-99631: Add custom loads and dumps support for the shelve module #99632

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

Closed
wants to merge 17 commits into from
Closed

gh-99631: Add custom loads and dumps support for the shelve module #99632

wants to merge 17 commits into from

Conversation

furkanonder
Copy link
Contributor

@furkanonder furkanonder commented Nov 20, 2022

@merwok merwok added type-feature A feature request or enhancement stdlib Python modules in the Lib dir 3.12 only security fixes labels Dec 1, 2022
@merwok
Copy link
Member

merwok commented Dec 1, 2022

Could you add docs and tests?

@serhiy-storchaka
Copy link
Member

Do we need to specify the pickler and unpickler classes or just dumps() and loads() functions?

@isidentical
Copy link
Member

I'd also go fordumps and loads instead of pickler/unpickler classes. With a proper definition (e.g. takes a Python object and returns bytes) I think that should make it much more simpler (it is also similar how other pickle-related APIs work outside of the stdlib)

@furkanonder furkanonder changed the title gh-99631: Add custom unpickler and pickler support for the shelve module gh-99631: Add custom loads and dumps support for the shelve module Dec 3, 2022
@furkanonder
Copy link
Contributor Author

Doc and test have been added. @merwok

The pickler and unpickler classes have been replaced with dumps() and load() functions. @isidentical @serhiy-storchaka

Copy link
Member

@isidentical isidentical left a comment

Choose a reason for hiding this comment

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

Thanks a lot for your efforts @furkanonder, I have a few minor suggestions but this already looks great!

@netlify
Copy link

netlify bot commented Dec 7, 2022

Deploy Preview for python-cpython-preview canceled.

Name Link
🔨 Latest commit 11cbfbf
🔍 Latest deploy log https://app.netlify.com/sites/python-cpython-preview/deploys/63934b91a06334000855fb77

@serhiy-storchaka
Copy link
Member

Should we require the serializer to accept the pickle protocol? It does not make sense for other than pickle formats.

What happens if only serializer or only deserializer are passed?

@furkanonder
Copy link
Contributor Author

What happens if only serializer or only deserializer are passed?

elif (serializer is None and deserializer is not None) or (deserializer is None and serializer is not None):
    raise ShelveError("Serializer and deserializer must be defined together.")

In this case, shelve raises an error.

@furkanonder furkanonder requested review from rhettinger and isidentical and removed request for rhettinger and isidentical December 20, 2022 20:05
@furkanonder furkanonder closed this by deleting the head repository Dec 23, 2022
@furkanonder furkanonder reopened this Dec 23, 2022
@furkanonder furkanonder requested review from rhettinger and isidentical and removed request for isidentical and rhettinger December 23, 2022 18:52
@encukou
Copy link
Member

encukou commented Apr 9, 2024

This seems to have been forgotten over end-of-year break in 2022. Do you want to revive it?

The BsdDbShelf class needs to be updated as well; its extra functions should use deserializer rather than Unpickler

@furkanonder
Copy link
Contributor Author

I accidentally deleted my forked repository, so I can't update my old PRs. So I opened a new PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3.12 only security fixes awaiting merge stdlib Python modules in the Lib dir type-feature A feature request or enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants