-
-
Notifications
You must be signed in to change notification settings - Fork 31.9k
Behaviour of pattern matching and class private names is currently ambiguous #94499
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I'm not sure "type-feature" is quite right, but it's not a bug either... |
Logically I think we should mangle the name here, because the corresponding non-pattern-matching code performs name mangling:
But changing it now would be a compatibility break, and I'm not sure that's worth it. We'd probably have to warn for a few releases if you use an underscored name in a class pattern. |
yes - that's why I originally asked about it. I can honestly see both ways being justifiable. One downside of doing the mangling is that it'd probably leave |
…#94500) The current status quo is that private attribute names are not mangled when a class is matched. I've added a test to document/legimize this behaviour. Co-authored-by: Brandt Bucher <[email protected]>
Closed by adding a test that locks in this behavior. We decided it's not worth updating the PEP (one could argue that it already specifies the current behavior). |
Feature or enhancement
Currently (Python 3.10, 3.11) this matches
x.__something
. Under most other circumstances it'd look upx._C__something
. This seems reasonable to me, but doesn't seem to be tested for (so it isn't clear that it's been "decided")I propose to keep the current behaviour, but add a test so that it's at least "fixed"
Previous discussion
I asked on Python-dev list https://mail.python.org/archives/list/[email protected]/thread/LILLO3MBTVY6ZQT3VNUVXATEPS3ASGQF/ - the one reply suggested the current behaviour was OK
The text was updated successfully, but these errors were encountered: