Skip to content

Commit 58015c1

Browse files
authored
Merge pull request RustPython#3811 from zer0who/hoo_rustpython
added getnewargs() to str.rs
2 parents 07940cd + 8cbd2e5 commit 58015c1

File tree

5 files changed

+5
-34
lines changed

5 files changed

+5
-34
lines changed

Lib/test/test_enum.py

-2
Original file line numberDiff line numberDiff line change
@@ -1002,8 +1002,6 @@ def test_programmatic_function_type_from_subclass_with_start(self):
10021002
self.assertIn(e, SummerMonth)
10031003
self.assertIs(type(e), SummerMonth)
10041004

1005-
# TODO: RUSTPYTHON
1006-
@unittest.expectedFailure
10071005
def test_subclassing(self):
10081006
if isinstance(Name, Exception):
10091007
raise Name

Lib/test/test_pickle.py

-20
Original file line numberDiff line numberDiff line change
@@ -118,16 +118,6 @@ def test_in_band_buffers(self): # TODO: RUSTPYTHON, remove when this passes
118118
def test_nested_names(self): # TODO: RUSTPYTHON, remove when this passes
119119
super().test_nested_names() # TODO: RUSTPYTHON, remove when this passes
120120

121-
# TODO: RUSTPYTHON, AssertionError
122-
@unittest.expectedFailure
123-
def test_newobj_generic(self): # TODO: RUSTPYTHON, remove when this passes
124-
super().test_newobj_generic() # TODO: RUSTPYTHON, remove when this passes
125-
126-
# TODO: RUSTPYTHON, TypeError: cannot pickle 'weakproxy' object
127-
@unittest.expectedFailure
128-
def test_newobj_proxies(self): # TODO: RUSTPYTHON, remove when this passes
129-
super().test_newobj_proxies() # TODO: RUSTPYTHON, remove when this passes
130-
131121
def test_notimplemented(self): # TODO: RUSTPYTHON, remove when this passes
132122
super().test_notimplemented() # TODO: RUSTPYTHON, remove when this passes
133123

@@ -233,16 +223,6 @@ def test_load_python2_str_as_bytes(self): # TODO: RUSTPYTHON, remove when this p
233223
def test_nested_names(self): # TODO: RUSTPYTHON, remove when this passes
234224
super().test_nested_names() # TODO: RUSTPYTHON, remove when this passes
235225

236-
# TODO: RUSTPYTHON, AssertionError: 'hello' != '' : 'hello' is not a copy of ''
237-
@unittest.expectedFailure
238-
def test_newobj_generic(self): # TODO: RUSTPYTHON, remove when this passes
239-
super().test_newobj_generic() # TODO: RUSTPYTHON, remove when this passes
240-
241-
# TODO: RUSTPYTHON, TypeError: cannot pickle 'weakproxy' object
242-
@unittest.expectedFailure
243-
def test_newobj_proxies(self): # TODO: RUSTPYTHON, remove when this passes
244-
super().test_newobj_proxies() # TODO: RUSTPYTHON, remove when this passes
245-
246226
def test_notimplemented(self): # TODO: RUSTPYTHON, remove when this passes
247227
super().test_notimplemented() # TODO: RUSTPYTHON, remove when this passes
248228

Lib/test/test_pickletools.py

-10
Original file line numberDiff line numberDiff line change
@@ -40,16 +40,6 @@ def test_in_band_buffers(self): # TODO: RUSTPYTHON, remove when this passes
4040
def test_nested_names(self): # TODO: RUSTPYTHON, remove when this passes
4141
super().test_nested_names()
4242

43-
# TODO: RUSTPYTHON
44-
@unittest.expectedFailure
45-
def test_newobj_generic(self): # TODO: RUSTPYTHON, remove when this passes
46-
super().test_newobj_generic()
47-
48-
# TODO: RUSTPYTHON, TypeError: cannot pickle 'weakproxy' object
49-
@unittest.expectedFailure
50-
def test_newobj_proxies(self): # TODO: RUSTPYTHON, remove when this passes
51-
super().test_newobj_proxies()
52-
5343
def test_notimplemented(self): # TODO: RUSTPYTHON, remove when this passes
5444
super().test_notimplemented()
5545

Lib/test/test_unicode.py

-2
Original file line numberDiff line numberDiff line change
@@ -2392,8 +2392,6 @@ def __iadd__(self, o):
23922392
s += "4"
23932393
self.assertEqual(s, "3")
23942394

2395-
# TODO: RUSTPYTHON
2396-
@unittest.expectedFailure
23972395
def test_getnewargs(self):
23982396
text = 'abc'
23992397
args = text.__getnewargs__()

vm/src/builtins/str.rs

+5
Original file line numberDiff line numberDiff line change
@@ -1258,6 +1258,11 @@ impl PyStr {
12581258
fn encode(zelf: PyRef<Self>, args: EncodeArgs, vm: &VirtualMachine) -> PyResult<PyBytesRef> {
12591259
encode_string(zelf, args.encoding, args.errors, vm)
12601260
}
1261+
1262+
#[pymethod(magic)]
1263+
fn getnewargs(zelf: PyRef<Self>, vm: &VirtualMachine) -> PyObjectRef {
1264+
(zelf.as_str(),).to_pyobject(vm)
1265+
}
12611266
}
12621267

12631268
impl PyStrRef {

0 commit comments

Comments
 (0)