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

Instance can not use deepcopy #181

Closed
yanganto opened this issue Jun 13, 2018 · 1 comment
Closed

Instance can not use deepcopy #181

yanganto opened this issue Jun 13, 2018 · 1 comment
Labels

Comments

@yanganto
Copy link

🐛 Bug Reports

The instance made by class written in pyo3 cannot be deep copied.

🌍 Environment

  • ArchLinux
  • Python 3.6.5 installed
  • rustup 1.11.0
  • rustc 1.28.0-nightly (2a0062974 2018-06-09)

💥 Reproducing

#![feature(proc_macro, specialization)]
#[macro_use]
extern crate pyo3;

use pyo3::prelude::*;

use pyo3::py::class;

#[class]
struct MyClass{
    #[prop(get)]
    title: String,
    #[prop(get)]
    num: i32,
    #[prop(get)]
    words: Vec<String>
}

It will got following error message.

The instance can not use copy.deepcopy.

Python 3.6.5 (default, May 11 2018, 04:00:52)
[GCC 8.1.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import copy
>>> import my_class.MyClass as C
>>> c = C()
>>> c2 = copy.deepcopy(c)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python3.6/copy.py", line 169, in deepcopy
    rv = reductor(4)
TypeError: can't pickle my_class._my_class.MyClass objects

If there is any better practice please tell me.
Thank you.

@konstin
Copy link
Member

konstin commented Aug 19, 2018

Closing in favor of #100

@konstin konstin closed this as completed Aug 19, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants