Skip to content

Support COM identifiers with national characters#2632

Merged
mhammond merged 1 commit intomhammond:mainfrom
native-api-work:class_name_national
Jun 26, 2025
Merged

Support COM identifiers with national characters#2632
mhammond merged 1 commit intomhammond:mainfrom
native-api-work:class_name_national

Conversation

@native-api-work
Copy link
Copy Markdown
Contributor

Some classes have them, e.g. 1C:Enterprise

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():
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is just trying to be isidentifier() - so maybe also kill the whole valid_identifier_chars thing?

Copy link
Copy Markdown
Contributor Author

@native-api-work native-api-work Jun 26, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Owner

@mhammond mhammond left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oops, yeah, sorry, I was jet-lagged :)

@mhammond mhammond merged commit 0c7297b into mhammond:main Jun 26, 2025
30 checks passed
@native-api-work native-api-work deleted the class_name_national branch June 26, 2025 15:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants