| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -87,18 +87,6 @@ public static int tp_setattro(IntPtr ob, IntPtr key, IntPtr val) | |||
| 87 | 87 | return -1; | |
| 88 | 88 | } | |
| 89 | 89 | ||
| 90 | - | ||
| 91 | - /// <summary> | ||
| 92 | - /// Default __set__ implementation - this prevents descriptor instances | ||
| 93 | - /// being silently replaced in a type __dict__ by default __setattr__. | ||
| 94 | - /// </summary> | ||
| 95 | - public static int tp_descr_set(IntPtr ds, IntPtr ob, IntPtr val) | ||
| 96 | - { | ||
| 97 | - Exceptions.SetError(Exceptions.AttributeError, "attribute is read-only"); | ||
| 98 | - return -1; | ||
| 99 | - } | ||
| 100 | - | ||
| 101 | - | ||
| 102 | 90 | public static void tp_dealloc(IntPtr ob) | |
| 103 | 91 | { | |
| 104 | 92 | // Clean up a Python instance of this extension type. This | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -14,6 +14,8 @@ public MethodTest() | |||
| 14 | 14 | { | |
| 15 | 15 | } | |
| 16 | 16 | ||
| 17 | + public string OverwritableMethod() => "overwritable"; | ||
| 18 | + | ||
| 17 | 19 | public string PublicMethod() | |
| 18 | 20 | { | |
| 19 | 21 | return "public"; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -6,37 +6,12 @@ | |||
| 6 | 6 | import pytest | |
| 7 | 7 | from Python.Test import MethodTest | |
| 8 | 8 | ||
| 9 | + def test_instance_method_overwritable(): | ||
| 10 | + """Test instance method overwriting.""" | ||
| 9 | 11 | ||
| 10 | - def test_instance_method_descriptor(): | ||
| 11 | - """Test instance method descriptor behavior.""" | ||
| 12 | - | ||
| 13 | - with pytest.raises(AttributeError): | ||
| 14 | - MethodTest().PublicMethod = 0 | ||
| 15 | - | ||
| 16 | - with pytest.raises(AttributeError): | ||
| 17 | - MethodTest.PublicMethod = 0 | ||
| 18 | - | ||
| 19 | - with pytest.raises(AttributeError): | ||
| 20 | - del MethodTest().PublicMethod | ||
| 21 | - | ||
| 22 | - with pytest.raises(AttributeError): | ||
| 23 | - del MethodTest.PublicMethod | ||
| 24 | - | ||
| 25 | - | ||
| 26 | - def test_static_method_descriptor(): | ||
| 27 | - """Test static method descriptor behavior.""" | ||
| 28 | - | ||
| 29 | - with pytest.raises(AttributeError): | ||
| 30 | - MethodTest().PublicStaticMethod = 0 | ||
| 31 | - | ||
| 32 | - with pytest.raises(AttributeError): | ||
| 33 | - MethodTest.PublicStaticMethod = 0 | ||
| 34 | - | ||
| 35 | - with pytest.raises(AttributeError): | ||
| 36 | - del MethodTest().PublicStaticMethod | ||
| 37 | - | ||
| 38 | - with pytest.raises(AttributeError): | ||
| 39 | - del MethodTest.PublicStaticMethod | ||
| 12 | + ob = MethodTest() | ||
| 13 | + ob.OverwritableMethod = lambda: "overwritten" | ||
| 14 | + assert ob.OverwritableMethod() == "overwritten" | ||
| 40 | 15 | ||
| 41 | 16 | ||
| 42 | 17 | def test_public_instance_method(): | |
| Back | FazBrowse Home | New Git URL |
0 commit comments