Skip to content

Commit fd45e9e

Browse files
authored
Merge pull request RustPython#3738 from gnsxun/notimpl_reduce
Add NotImplemented.__reduce__()
2 parents bd4f7ab + e5816a4 commit fd45e9e

File tree

3 files changed

+5
-12
lines changed

3 files changed

+5
-12
lines changed

Lib/test/test_pickle.py

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -128,8 +128,6 @@ def test_newobj_generic(self): # TODO: RUSTPYTHON, remove when this passes
128128
def test_newobj_proxies(self): # TODO: RUSTPYTHON, remove when this passes
129129
super().test_newobj_proxies() # TODO: RUSTPYTHON, remove when this passes
130130

131-
# TODO: RUSTPYTHON, TypeError: cannot pickle 'NotImplementedType' object
132-
@unittest.expectedFailure
133131
def test_notimplemented(self): # TODO: RUSTPYTHON, remove when this passes
134132
super().test_notimplemented() # TODO: RUSTPYTHON, remove when this passes
135133

@@ -163,8 +161,6 @@ def test_py_methods(self): # TODO: RUSTPYTHON, remove when this passes
163161
def test_recursive_nested_names(self): # TODO: RUSTPYTHON, remove when this passes
164162
super().test_recursive_nested_names() # TODO: RUSTPYTHON, remove when this passes
165163

166-
# TODO: RUSTPYTHON, TypeError: cannot pickle 'NotImplementedType' object
167-
@unittest.expectedFailure
168164
def test_singleton_types(self): # TODO: RUSTPYTHON, remove when this passes
169165
super().test_singleton_types() # TODO: RUSTPYTHON, remove when this passes
170166

@@ -247,8 +243,6 @@ def test_newobj_generic(self): # TODO: RUSTPYTHON, remove when this passes
247243
def test_newobj_proxies(self): # TODO: RUSTPYTHON, remove when this passes
248244
super().test_newobj_proxies() # TODO: RUSTPYTHON, remove when this passes
249245

250-
# TODO: RUSTPYTHON, TypeError: cannot pickle 'NotImplementedType' object
251-
@unittest.expectedFailure
252246
def test_notimplemented(self): # TODO: RUSTPYTHON, remove when this passes
253247
super().test_notimplemented() # TODO: RUSTPYTHON, remove when this passes
254248

@@ -282,8 +276,6 @@ def test_py_methods(self): # TODO: RUSTPYTHON, remove when this passes
282276
def test_recursive_nested_names(self): # TODO: RUSTPYTHON, remove when this passes
283277
super().test_recursive_nested_names() # TODO: RUSTPYTHON, remove when this passes
284278

285-
# TODO: RUSTPYTHON, TypeError: cannot pickle 'NotImplementedType' object
286-
@unittest.expectedFailure
287279
def test_singleton_types(self): # TODO: RUSTPYTHON, remove when this passes
288280
super().test_singleton_types() # TODO: RUSTPYTHON, remove when this passes
289281

Lib/test/test_pickletools.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,6 @@ def test_newobj_generic(self): # TODO: RUSTPYTHON, remove when this passes
5050
def test_newobj_proxies(self): # TODO: RUSTPYTHON, remove when this passes
5151
super().test_newobj_proxies()
5252

53-
# TODO: RUSTPYTHON, TypeError: cannot pickle 'NotImplementedType' object
54-
@unittest.expectedFailure
5553
def test_notimplemented(self): # TODO: RUSTPYTHON, remove when this passes
5654
super().test_notimplemented()
5755

@@ -85,8 +83,6 @@ def test_py_methods(self): # TODO: RUSTPYTHON, remove when this passes
8583
def test_recursive_nested_names(self): # TODO: RUSTPYTHON, remove when this passes
8684
super().test_recursive_nested_names()
8785

88-
# TODO: RUSTPYTHON, TypeError: cannot pickle 'NotImplementedType' object
89-
@unittest.expectedFailure
9086
def test_singleton_types(self): # TODO: RUSTPYTHON, remove when this passes
9187
super().test_singleton_types()
9288

vm/src/builtins/singletons.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,11 @@ impl PyNotImplemented {
8484
fn repr(&self) -> String {
8585
"NotImplemented".to_owned()
8686
}
87+
88+
#[pymethod(magic)]
89+
fn reduce(&self) -> String {
90+
"NotImplemented".to_owned()
91+
}
8792
}
8893

8994
pub fn init(context: &Context) {

0 commit comments

Comments
 (0)