Skip to content

added getnewargs() to str.rs #3811

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

Merged
merged 4 commits into from
Jul 14, 2022
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
2 changes: 0 additions & 2 deletions Lib/test/test_enum.py
Original file line number Diff line number Diff line change
Expand Up @@ -1002,8 +1002,6 @@ def test_programmatic_function_type_from_subclass_with_start(self):
self.assertIn(e, SummerMonth)
self.assertIs(type(e), SummerMonth)

# TODO: RUSTPYTHON
@unittest.expectedFailure
def test_subclassing(self):
if isinstance(Name, Exception):
raise Name
Expand Down
20 changes: 0 additions & 20 deletions Lib/test/test_pickle.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,16 +118,6 @@ def test_in_band_buffers(self): # TODO: RUSTPYTHON, remove when this passes
def test_nested_names(self): # TODO: RUSTPYTHON, remove when this passes
super().test_nested_names() # TODO: RUSTPYTHON, remove when this passes

# TODO: RUSTPYTHON, AssertionError
@unittest.expectedFailure
def test_newobj_generic(self): # TODO: RUSTPYTHON, remove when this passes
super().test_newobj_generic() # TODO: RUSTPYTHON, remove when this passes

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

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

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

# TODO: RUSTPYTHON, AssertionError: 'hello' != '' : 'hello' is not a copy of ''
@unittest.expectedFailure
def test_newobj_generic(self): # TODO: RUSTPYTHON, remove when this passes
super().test_newobj_generic() # TODO: RUSTPYTHON, remove when this passes

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

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

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 @@ -40,16 +40,6 @@ def test_in_band_buffers(self): # TODO: RUSTPYTHON, remove when this passes
def test_nested_names(self): # TODO: RUSTPYTHON, remove when this passes
super().test_nested_names()

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

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

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

Expand Down
2 changes: 0 additions & 2 deletions Lib/test/test_unicode.py
Original file line number Diff line number Diff line change
Expand Up @@ -2392,8 +2392,6 @@ def __iadd__(self, o):
s += "4"
self.assertEqual(s, "3")

# TODO: RUSTPYTHON
@unittest.expectedFailure
def test_getnewargs(self):
text = 'abc'
args = text.__getnewargs__()
Expand Down
5 changes: 5 additions & 0 deletions vm/src/builtins/str.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1258,6 +1258,11 @@ impl PyStr {
fn encode(zelf: PyRef<Self>, args: EncodeArgs, vm: &VirtualMachine) -> PyResult<PyBytesRef> {
encode_string(zelf, args.encoding, args.errors, vm)
}

#[pymethod(magic)]
fn getnewargs(zelf: PyRef<Self>, vm: &VirtualMachine) -> PyObjectRef {
(zelf.as_str(),).to_pyobject(vm)
}
}

impl PyStrRef {
Expand Down