mirror of
https://github.com/RustPython/RustPython.git
synced 2026-06-02 19:39:49 +09:00
Merge pull request #2683 from RustPython/method-self-getter
Add method.__self__ attribute
This commit is contained in:
@@ -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):
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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'
|
||||
|
||||
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user