From 24e07ced73aa6046ef5f68ba193608b63a1a06fe Mon Sep 17 00:00:00 2001 From: Rocco Moretti Date: Mon, 8 Jun 2026 11:53:47 -0500 Subject: [PATCH] molfile_to_params: fix support for gzipped files. In Python3, gzip returns a bytes-based object, rather than a string one (which is what open() returns), which results in errors later. We can use TextIOWrapper to fix the issue. --- source/scripts/python/public/rosetta_py/io/mdl_molfile.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source/scripts/python/public/rosetta_py/io/mdl_molfile.py b/source/scripts/python/public/rosetta_py/io/mdl_molfile.py index b9fd8bb4eb9..75691687ed3 100644 --- a/source/scripts/python/public/rosetta_py/io/mdl_molfile.py +++ b/source/scripts/python/public/rosetta_py/io/mdl_molfile.py @@ -22,7 +22,7 @@ ''' from __future__ import print_function -import os, sys, math, copy, gzip +import os, sys, math, copy, gzip, io try: set except: from sets import Set as set @@ -31,7 +31,7 @@ def gz_open(file,mode): filename, extension = os.path.splitext( file ) if extension == ".gz": - return gzip.open(file,mode) + return io.TextIOWrapper(gzip.open(file,mode), encoding='utf-8') else: return open(file,mode)