Commit 8f11248
committed
gh-107831: Fix inspect.getcallargs accepting positional-only args by keyword
getcallargs() built the set of acceptable keyword names from getfullargspec's
'args', which includes positional-only parameters, so a positional-only
parameter could be filled by keyword without error -- unlike an actual call
or Signature.bind(). Exclude positional-only names (derived from the code
object's co_posonlyargcount) from keyword matching and raise the same
TypeError the interpreter does.1 parent 30aeeb3 commit 8f11248
3 files changed
Lines changed: 34 additions & 1 deletion
File tree
- Lib
- test/test_inspect
- Misc/NEWS.d/next/Library
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1466 | 1466 | | |
1467 | 1467 | | |
1468 | 1468 | | |
| 1469 | + | |
| 1470 | + | |
| 1471 | + | |
| 1472 | + | |
| 1473 | + | |
| 1474 | + | |
1469 | 1475 | | |
1470 | 1476 | | |
1471 | 1477 | | |
1472 | 1478 | | |
1473 | 1479 | | |
1474 | | - | |
| 1480 | + | |
1475 | 1481 | | |
1476 | 1482 | | |
| 1483 | + | |
1477 | 1484 | | |
1478 | 1485 | | |
| 1486 | + | |
| 1487 | + | |
| 1488 | + | |
1479 | 1489 | | |
1480 | 1490 | | |
1481 | 1491 | | |
| |||
1485 | 1495 | | |
1486 | 1496 | | |
1487 | 1497 | | |
| 1498 | + | |
| 1499 | + | |
| 1500 | + | |
| 1501 | + | |
1488 | 1502 | | |
1489 | 1503 | | |
1490 | 1504 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2266 | 2266 | | |
2267 | 2267 | | |
2268 | 2268 | | |
| 2269 | + | |
| 2270 | + | |
| 2271 | + | |
| 2272 | + | |
| 2273 | + | |
| 2274 | + | |
| 2275 | + | |
| 2276 | + | |
| 2277 | + | |
| 2278 | + | |
| 2279 | + | |
| 2280 | + | |
| 2281 | + | |
| 2282 | + | |
| 2283 | + | |
| 2284 | + | |
2269 | 2285 | | |
2270 | 2286 | | |
2271 | 2287 | | |
| |||
Lines changed: 3 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
0 commit comments