configfile: Improve support for python3.12

It seems python3.12 has removed support for readfp() - use read_file()
instead.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
Kevin O'Connor 2023-11-01 20:38:15 -04:00
parent 3c8f202dfa
commit 187cc2f1b8
1 changed files with 4 additions and 1 deletions

View File

@ -217,7 +217,10 @@ class PrinterConfig:
data = '\n'.join(buffer)
del buffer[:]
sbuffer = io.StringIO(data)
fileconfig.readfp(sbuffer, filename)
if sys.version_info.major >= 3:
fileconfig.read_file(sbuffer, filename)
else:
fileconfig.readfp(sbuffer, filename)
def _resolve_include(self, source_filename, include_spec, fileconfig,
visited):
dirname = os.path.dirname(source_filename)