Add method.__self__ attribute

This commit is contained in:
Noah committed 2021-06-02 21:17:15 -05:00
1 parent 658d175e5b
commit 6f0013a3a8
4 files changed
+5 -6

No files matched your search

-2
View File
@@ -887,8 +887,6 @@ class TestCopy(unittest.TestCase):
del d
self.assertEqual(len(v), 1)
# TODO: RUSTPYTHON
@unittest.expectedFailure
def test_deepcopy_bound_method(self):
class Foo(object):
def m(self):
-2
View File
@@ -543,8 +543,6 @@ class TestPartialMethod(unittest.TestCase):
self.assertEqual(self.A.over_partial(self.a, 5, d=8), ((self.a, 7, 5), {'c': 6, 'd': 8}))
# TODO: RUSTPYTHON
@unittest.expectedFailure
def test_bound_method_introspection(self):
obj = self.a
self.assertIs(obj.both.__self__, obj)
-2
View File
@@ -1325,8 +1325,6 @@ class TestDetectEncoding(TestCase):
self.assertEqual(fp.encoding, 'utf-8-sig')
self.assertEqual(fp.mode, 'r')
# TODO: RUSTPYTHON
@unittest.expectedFailure
def test_filename_in_exception(self):
# When possible, include the file name in the exception.
path = 'some_file_path'
+5
View File
@@ -473,6 +473,11 @@ impl PyBoundMethod {
self.function.clone()
}
#[pyproperty(name = "__self__")]
fn get_self(&self) -> PyObjectRef {
self.object.clone()
}
#[pyproperty(magic)]
fn module(&self, vm: &VirtualMachine) -> Option<PyObjectRef> {
vm.get_attribute(self.function.clone(), "__module__").ok()