PyO3 / PyO3/pyo3

Pickle support for `PyErr`

Open
#4,728 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Rust
Stars
16.2k
Forks
1k
Avg merge
2d 6h
Merged PRs (30d)
66

Description

Pickle support was already discussed in #100, customizing __setstate__, __getstate__ and __getnewargs_ex__ works well for customized pyclass.

Unfortunately, when we want to create customized exception using create_exception, it's hard to implement such methods. It seems that the arguments are stored in PyErr instead of the class itself, how can we implement these magic methods ourselves?

#[pyclass(extends=PyException, subclass)]
pub struct Error;

Of course, it's better for pyo3 to support these methods directly on PyErr. I'd like to help if there is a consensus to do that.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reviewing the prior discussion in issue #100 and the PyErr and create_exception behavior described here. Clarify how customized exception state and pickle methods should work, then establish the expected behavior and tests before implementation.

Written by the indexing model from the issue text.

Assessment

Tech stack
python, rust
Domain
backend-api-design
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.