Fixes by checking if file obj is opened as str before interpreting as bytes.
@@ -151,6 +151,7 @@ import zipfile
from copy import deepcopy as copy
from numbers import Number
from itertools import product
+from io import TextIOWrapper
import numpy as npy
from numpy.linalg import inv as npy_inv
@@ -383,6 +384,9 @@ class Network(object):
# allows user to pass filename or file obj
# open file in 'binary' mode because we are going to try and
# unpickle it first
+ if isinstance(file, TextIOWrapper):
+ self.read_touchstone(file)
+ else:
fid = get_fid(file, 'rb')
try:
