-
-
Notifications
You must be signed in to change notification settings - Fork 41
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
Add vdf_safe_load function #455
Conversation
Is this a bug upstream out of interest? Why exactly is this needed? Just wondering as I have never ran into this issue, and have some games with emojis etc in their names. I remember a similar issue was related to incorrectly configured system locales. In the past I have also fallen victim to application issues caused by locale problems. I saw the discussion in the linked issue but I still don't really understand why this is needed. |
There was a similar issue upstream where defective UTF-8 characters would cause the problem. The fix didn't help with vdf.load though. I don't think there is an upstream issue for that yet.
It's most likely caused by a misconfigured system and not directly the vdf dependency. The problem is that the vdf file contains invalid UTF-8 characters that cannot be parsed for some reason. The vdf parser will throw an error and crash ProtonUp-Qt. This patch will replace the invalid characters with a valid character (I think �). There are multiple people who reported the issue, so it seems like a good idea to ensure that it won't crash ProtonUp-Qt. |
Okay, I think I understand. So this isn't strictly a problem caused by us or the VDF library, but is probably some system issue. That's okay then, I just wanted to make sure there wasn't a deeper problem. Is this something we should report upstream? Other applications using the VDF library are probably going to bump into this. |
I don't think upstream can do much about it because the unicode-error handling takes place in the UPDATE: Upstream discussion/issue solsticegamestudios/vdf#2 |
Ohh you're right, I was thinking that this was called when the VDF library was trying to open it, but I guess this is actually to do with how Python tries to A number of years ago I encountered locale issues with Protontricks, and some years ago I also encountered locale issues with SteamTinkerLaunch. I think the solution in this PR makes sense, and opening an issue upstream could lead to some discussion around the cause of the problem and some solutions. |
I saw the upstream discussion and agree that this is a result of the How likely is it that Valve changed something that has suddenly made systems with incorrect locales run into this issue, I wonder. I think this PR covers all of the VDF loads where we would need this from what I can tell. Will take a look at #407 closer to the time to see how it would integrate with this. :-) |
Fix #424
Adds a new function
vdf_safe_load(vdf_file: str) -> dict
tosteamutil.py
It opens and parses vdf files using the vdf library. Defective UTF-8 characters are replaced with a unicode question mark symbol. The error is printed in case of other Exceptions and an empty dict is returned.