Skip to content
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

sys.executable returns garbage on some non-english systems #129

Open
apple1417 opened this issue Dec 18, 2022 · 1 comment
Open

sys.executable returns garbage on some non-english systems #129

apple1417 opened this issue Dec 18, 2022 · 1 comment
Labels
bug Something isn't working

Comments

@apple1417
Copy link
Contributor

We've occasionally seen some people having issues running the bl2 mod menu, which boil down to sys.executable holding a garbage value. Often this contains another random filename, but sometimes it's just random garbage data. Interestingly, os.path.dirname(sys.executable) returns a few garbage bytes, followed by the actual path. This does not apply to the executable path we extract within the sdk, that always returns correctly.

In a few recent cases where we managed a bit more debugging, a common thread was that everyone originally had their system language set to Russian. Presumably, python is sourcing some cp1251-encoded value, but interpreting it incorrectly?

@apple1417 apple1417 added the bug Something isn't working label Dec 18, 2022
@apple1417
Copy link
Contributor Author

Just had another user with the same issue, this time on a French system, which should be using cp1252. Additionally, after testing workarounds on a number of users, we've seen the issue happens multiple times even when paths are all ASCII. This means encoding issues are probably not the cause.

From this testing, a workaround appears to be:

os.path.dirname(re.split(r"\\[A-Z]:\\", os.path.abspath(sys.executable))[0])

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant