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

marshal module is imcomplete #3458

Open
youknowone opened this issue Nov 26, 2021 · 2 comments
Open

marshal module is imcomplete #3458

youknowone opened this issue Nov 26, 2021 · 2 comments

Comments

@youknowone
Copy link
Member

@youknowone youknowone commented Nov 26, 2021

Feature

marshal dumps and loads are incomplete

Python Documentation

https://docs.python.org/3/library/marshal.html

@jakearmendariz
Copy link
Contributor

@jakearmendariz jakearmendariz commented Dec 19, 2021

Hi, I was looking at this issue (new to this project) and I am struggling a bit.

I assume the primary changes would be made to the marshal.rs file. My first thought is that we would add more cases the loads and dumps match statements to handle PyStr, PyInt, PyFloat etc. However, the loads function expects the returning of a PyCode object, thus at some point a PyCode object would have to be created (either in loads after reading the raw bytes, or in dumps by converting all PyObjectRef into PyCode first.

Am I understanding this correctly? If so, how can we convert and the ConstantData/PyObjectRef/bytes into a PyCode or CodeObject?

FYI I am able to get any constant to a PyConstant without much trouble, it's the CodeObject creation that seems necessary and is confusing.

Thanks for any advice or tips you can give. I'm somewhat new to rust and interpreters and appreciate all the help I can get!

@youknowone
Copy link
Member Author

@youknowone youknowone commented Dec 19, 2021

Your approach is correct. The return type can be changed to PyObjectRef to include any type of python object. The most common way to convert PyCode or other types into PyObjectRef is using into_pyobject. The other way - PyObjectRef to each type - will be try_into_value.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants