From 51d6e71cfb0b71cf5e40e93383465443c09e80ad Mon Sep 17 00:00:00 2001 From: John Haddon Date: Mon, 13 Oct 2025 14:10:55 +0100 Subject: [PATCH] ConfigLoader : Specify encoding in calls to `open()` We did this in Gaffer back in https://github.com/GafferHQ/gaffer/pull/5127, with the reasons being documented there. The lack of encoding in ConfigLoader was causing a similar problem when loading Gaffer config files in a Chinese/GBK locale. --- Changes | 3 +++ python/IECore/ConfigLoader.py | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/Changes b/Changes index 1f86da204a..b6120e17f7 100644 --- a/Changes +++ b/Changes @@ -1,7 +1,10 @@ 10.6.x.x (relative to 10.6.0.2) ======== +Fixes +----- +- ConfigLoader : Fixed UnicodeDecodeErrors in non-UTF8 locales. 10.6.0.2 (relative to 10.6.0.1) ======== diff --git a/python/IECore/ConfigLoader.py b/python/IECore/ConfigLoader.py index 1072d59774..6729cf2f58 100644 --- a/python/IECore/ConfigLoader.py +++ b/python/IECore/ConfigLoader.py @@ -72,7 +72,7 @@ def loadConfig( searchPaths, contextDict = {}, raiseExceptions = False, subdirec fileContextDict["__file__"] = fullFileName try : - with open( fullFileName ) as f : + with open( fullFileName, encoding = "utf-8" ) as f : exec( compile( f.read(), fullFileName, "exec" ), fileContextDict, fileContextDict