From 16992af05cfdf66c3cb4d00c573b2f3034b71fc1 Mon Sep 17 00:00:00 2001 From: Giovanni Mascellani Date: Wed, 4 Nov 2020 12:56:12 +0100 Subject: [PATCH] Port gen_wrapper.py to Python 3 Basically the only issue left out is that Python3 is much more picky on file encoding, and some Valve headers are not UTF-8. Ignoring errors is enough to get everything fixed. --- lsteamclient/gen_wrapper.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lsteamclient/gen_wrapper.py b/lsteamclient/gen_wrapper.py index d90d33c2..8fde253e 100755 --- a/lsteamclient/gen_wrapper.py +++ b/lsteamclient/gen_wrapper.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python2 +#!/usr/bin/env python3 #NOTE: If you make modifications here, consider whether they should #be duplicated in ../vrclient/gen_wrapper.py @@ -1215,7 +1215,10 @@ prog = re.compile("^#define\s*(\w*)\s*\"(.*)\"") for sdkver in sdk_versions: iface_versions = {} for f in os.listdir("steamworks_sdk_%s" % sdkver): - x = open("steamworks_sdk_%s/%s" % (sdkver, f), "r") + # Some files from Valve have non-UTF-8 stuff in the comments + # (typically the copyright symbol); therefore we ignore UTF-8 + # encoding errors + x = open("steamworks_sdk_%s/%s" % (sdkver, f), "r", errors='replace') for l in x: if "define STEAM" in l and "_VERSION" in l: result = prog.match(l)