Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 0 additions & 20 deletions Lib/test/test_pickle.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,11 +95,6 @@ def test_buffer_callback_error(self): # TODO: RUSTPYTHON, remove when this passe
def test_buffers_error(self): # TODO: RUSTPYTHON, remove when this passes
super().test_buffers_error() # TODO: RUSTPYTHON, remove when this passes

# TODO: RUSTPYTHON, TypeError: cannot pickle 'method' object
@unittest.expectedFailure
def test_c_methods(self): # TODO: RUSTPYTHON, remove when this passes
super().test_c_methods() # TODO: RUSTPYTHON, remove when this passes

# TODO: RUSTPYTHON, AssertionError
@unittest.expectedFailure
def test_complex_newobj_ex(self): # TODO: RUSTPYTHON, remove when this passes
Expand Down Expand Up @@ -130,11 +125,6 @@ def test_optional_frames(self): # TODO: RUSTPYTHON, remove when this passes
def test_picklebuffer_error(self): # TODO: RUSTPYTHON, remove when this passes
super().test_picklebuffer_error() # TODO: RUSTPYTHON, remove when this passes

# TODO: RUSTPYTHON, pickle.PicklingError
@unittest.expectedFailure
def test_py_methods(self): # TODO: RUSTPYTHON, remove when this passes
super().test_py_methods() # TODO: RUSTPYTHON, remove when this passes

def dumps(self, arg, proto=None, **kwargs):
f = io.BytesIO()
p = self.pickler(f, proto, **kwargs)
Expand Down Expand Up @@ -171,11 +161,6 @@ def test_buffer_callback_error(self): # TODO: RUSTPYTHON, remove when this passe
def test_buffers_error(self): # TODO: RUSTPYTHON, remove when this passes
super().test_buffers_error() # TODO: RUSTPYTHON, remove when this passes

# TODO: RUSTPYTHON, TypeError: cannot pickle 'method' object
@unittest.expectedFailure
def test_c_methods(self): # TODO: RUSTPYTHON, remove when this passes
super().test_c_methods() # TODO: RUSTPYTHON, remove when this passes

# TODO: RUSTPYTHON, AssertionError
@unittest.expectedFailure
def test_complex_newobj_ex(self): # TODO: RUSTPYTHON, remove when this passes
Expand Down Expand Up @@ -216,11 +201,6 @@ def test_optional_frames(self): # TODO: RUSTPYTHON, remove when this passes
def test_picklebuffer_error(self): # TODO: RUSTPYTHON, remove when this passes
super().test_picklebuffer_error() # TODO: RUSTPYTHON, remove when this passes

# TODO: RUSTPYTHON, pickle.PicklingError
@unittest.expectedFailure
def test_py_methods(self): # TODO: RUSTPYTHON, remove when this passes
super().test_py_methods() # TODO: RUSTPYTHON, remove when this passes

def dumps(self, arg, protocol=None, **kwargs):
return pickle.dumps(arg, protocol, **kwargs)

Expand Down
10 changes: 0 additions & 10 deletions Lib/test/test_pickletools.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,6 @@ def test_buffer_callback_error(self): # TODO: RUSTPYTHON, remove when this passe
def test_buffers_error(self): # TODO: RUSTPYTHON, remove when this passes
super().test_buffers_error()

# TODO: RUSTPYTHON, TypeError: cannot pickle 'method' object
@unittest.expectedFailure
def test_c_methods(self): # TODO: RUSTPYTHON, remove when this passes
super().test_c_methods()

def test_compat_pickle(self): # TODO: RUSTPYTHON, remove when this passes
super().test_compat_pickle()

Expand Down Expand Up @@ -58,11 +53,6 @@ def test_optional_frames(self): # TODO: RUSTPYTHON, remove when this passes
def test_picklebuffer_error(self): # TODO: RUSTPYTHON, remove when this passes
super().test_picklebuffer_error()

# TODO: RUSTPYTHON, pickle.PicklingError
@unittest.expectedFailure
def test_py_methods(self): # TODO: RUSTPYTHON, remove when this passes
super().test_py_methods()

def dumps(self, arg, proto=None, **kwargs):
return pickletools.optimize(pickle.dumps(arg, proto, **kwargs))

Expand Down
9 changes: 9 additions & 0 deletions vm/src/builtins/builtinfunc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,15 @@ impl PyBuiltinMethod {
self.class.name()
)
}
#[pymethod(magic)]
fn reduce(
&self,
vm: &VirtualMachine,
) -> (Option<PyObjectRef>, (Option<PyObjectRef>, PyStrRef)) {
let builtinfunc_getattr = vm.builtins.get_attr("getattr", vm).ok();
let classname = vm.builtins.get_attr(self.class.name().to_string(), vm).ok();
(builtinfunc_getattr, (classname, self.value.name.clone()))
}
}
impl Unconstructible for PyBuiltinMethod {}

Expand Down
11 changes: 11 additions & 0 deletions vm/src/builtins/function.rs
Original file line number Diff line number Diff line change
Expand Up @@ -552,6 +552,17 @@ impl PyBoundMethod {
))
}

#[pymethod(magic)]
fn reduce(
&self,
vm: &VirtualMachine,
) -> (Option<PyObjectRef>, (PyObjectRef, Option<PyObjectRef>)) {
let builtinfunc_getattr = vm.builtins.get_attr("getattr", vm).ok();
let funcself = self.object.clone();
let funcname = self.function.get_attr("__name__", vm).ok();
(builtinfunc_getattr, (funcself, funcname))
}

#[pygetset(magic)]
fn doc(&self, vm: &VirtualMachine) -> PyResult {
self.function.get_attr("__doc__", vm)
Expand Down