Commit a1203ae
Improve CPython compatibility related with PyBoundMethod (#7476)
* Add GetDescriptor for PyBoundMethod (return self)
CPython's method_descr_get always returns the bound method unchanged.
This preserves the original binding when __get__ is called on an
already-bound method (e.g. a.meth.__get__(b, B) still returns a).
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* Add constructor validation for PyBoundMethod
Reject non-callable functions and None instances, matching CPython's
method_new which checks PyCallable_Check(func) and instance != Py_None.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* Fix PyBoundMethod __reduce__ to propagate errors
Previously swallowed errors from get_attr with .ok(), silently
returning None. Now propagates errors matching CPython's method_reduce.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>1 parent 5b6a479 commit a1203ae
2 files changed
+31
-7
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5130 | 5130 | | |
5131 | 5131 | | |
5132 | 5132 | | |
5133 | | - | |
5134 | 5133 | | |
5135 | 5134 | | |
5136 | 5135 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1216 | 1216 | | |
1217 | 1217 | | |
1218 | 1218 | | |
| 1219 | + | |
| 1220 | + | |
| 1221 | + | |
| 1222 | + | |
| 1223 | + | |
| 1224 | + | |
| 1225 | + | |
| 1226 | + | |
| 1227 | + | |
| 1228 | + | |
| 1229 | + | |
1219 | 1230 | | |
1220 | 1231 | | |
1221 | 1232 | | |
| |||
1230 | 1241 | | |
1231 | 1242 | | |
1232 | 1243 | | |
1233 | | - | |
| 1244 | + | |
1234 | 1245 | | |
| 1246 | + | |
| 1247 | + | |
| 1248 | + | |
| 1249 | + | |
| 1250 | + | |
| 1251 | + | |
1235 | 1252 | | |
1236 | 1253 | | |
1237 | 1254 | | |
| |||
1258 | 1275 | | |
1259 | 1276 | | |
1260 | 1277 | | |
1261 | | - | |
| 1278 | + | |
| 1279 | + | |
| 1280 | + | |
| 1281 | + | |
| 1282 | + | |
| 1283 | + | |
| 1284 | + | |
| 1285 | + | |
| 1286 | + | |
1262 | 1287 | | |
1263 | 1288 | | |
1264 | 1289 | | |
1265 | 1290 | | |
1266 | 1291 | | |
1267 | 1292 | | |
1268 | 1293 | | |
1269 | | - | |
1270 | | - | |
| 1294 | + | |
| 1295 | + | |
1271 | 1296 | | |
1272 | | - | |
1273 | | - | |
| 1297 | + | |
| 1298 | + | |
1274 | 1299 | | |
1275 | 1300 | | |
1276 | 1301 | | |
| |||
0 commit comments