From fe526e557fce19238ec61bee437c6f1323ac3b52 Mon Sep 17 00:00:00 2001 From: Nicolas Geimer Date: Tue, 1 Aug 2017 10:23:40 +0200 Subject: [PATCH] Small fix for Python3 --- module_generator/gener.py | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/module_generator/gener.py b/module_generator/gener.py index 757ebc6..e32442f 100644 --- a/module_generator/gener.py +++ b/module_generator/gener.py @@ -811,13 +811,10 @@ ENDIF(EXISTS ${MEDCOUPLING_ROOT_DIR}) """ for name, content in list(dic.items()): filename = os.path.join(basedir, name) - if isinstance(content, basestring): - if isinstance(content, unicode): - # encodage to utf-8 if unicode string - content=content.encode('utf8') - fil = open(filename, 'w') - fil.write(content) - fil.close() + if isinstance(content, str): + # encodage to utf-8 if unicode string / on python3 str are unicode + with open(filename, 'w') as fil: + fil.write(content) else: if not os.path.exists(filename): os.makedirs(filename) -- 2.39.2