Support COM identifiers with national characters#2632
Conversation
Some classes have them, e.g. 1C:Enterprise
| if ret == className: # didn't change - force all uppercase. | ||
| ret = ret.upper() | ||
| return ret | ||
| elif className.isidentifier(): |
There was a problem hiding this comment.
this is just trying to be isidentifier() - so maybe also kill the whole valid_identifier_chars thing?
There was a problem hiding this comment.
isidentifier() doesn't allow names that are partially valid. I don't know how likely such names are.
https://learn.microsoft.com/en-us/windows/win32/api/oaidl/nf-oaidl-idispatch-gettypeinfo#parameters explicitly mentions that "localized member names" are allowed -- but doesn't list any constraints.
Since IDispatch only ever deals with member names as strings, it seems that theoretically, any string whatsoever is valid.
If that is the case, an ideal solution would be to filter out any characters that are invalid according to Python identifier rules -- but CPython doesn't provide any facilities to check if a character has XID_Start or XID_Continue Unicode property other than via isidentifier(). So the proposed change is a stopgap solution.
There are 3rd-party modules that can check Unicode properties, e.g. https://pypi.org/project/regex/ , if that's an option.
mhammond
left a comment
There was a problem hiding this comment.
oops, yeah, sorry, I was jet-lagged :)
Some classes have them, e.g. 1C:Enterprise