◐ Shell
clean mode source ↗

Qualname should be used in function's TypeErrors

Feature

Running the two code snippets below in CPython and in RustPython give different results

Example 1

def f(a, /, b=0): pass
f.__qualname__ = "g"
f(a=1, b=0)

In CPython:

TypeError: g() got some positional-only arguments passed as keyword arguments: 'a'

In RustPython:

TypeError: f() got some positional-only arguments passed as keyword arguments: 'a'

Example 2

class A:
    def f(self, a, /, b=0): pass

A().f(a=1, b=0)

In CPython:

TypeError: A.f() got some positional-only arguments passed as keyword arguments: 'a'

In RustPython:

TypeError: f() got some positional-only arguments passed as keyword arguments: 'a'

Python Documentation