FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Fix `object.__init__` excess-arg checks for heap types by moreal · Pull Request #7116 · RustPython/RustPython · GitHub

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

Filter by extension

Filter by extension .py  (2) .rs  (1) All 2 file types selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
1 change: 0 additions & 1 deletion Lib/test/test_class.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -741,7 +741,6 @@ def __setattr__(self, name, value) -> None:
with self.assertRaisesRegex(AttributeError, error_msg):
del B().z

@unittest.expectedFailure # TODO: RUSTPYTHON
def testConstructorErrorMessages(self):
# bpo-31506: Improves the error message logic for object_new & object_init

Expand Down
1 change: 0 additions & 1 deletion Lib/test/test_descr.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -1853,7 +1853,6 @@ class C(list):
__new__ = object.__new__
self.assertRaises(TypeError, C)

@unittest.expectedFailure # TODO: RUSTPYTHON
def test_object_new(self):
class A(object):
pass
Expand Down
9 changes: 5 additions & 4 deletions crates/vm/src/builtins/object.rs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -138,11 +138,12 @@ impl Initializer for PyBaseObject {
));
}

let typ_new = typ.slots.new.load().map(|f| f as usize);
let object_new = object_type.slots.new.load().map(|f| f as usize);

// if (type->tp_new == object_new) → second error
if typ_new == object_new {
if let (Some(typ_new), Some(object_new)) = (
typ.get_attr(identifier!(vm, __new__)),
object_type.get_attr(identifier!(vm, __new__)),
) && typ_new.is(&object_new)
{
return Err(vm.new_type_error(format!(
"{}.__init__() takes exactly one argument (the instance to initialize)",
typ.name()
Expand Down
Loading

Back | FazBrowse Home | New Git URL