From: Nicolas Geimer Date: Tue, 1 Aug 2017 08:23:40 +0000 (+0200) Subject: Small fix for Python3 X-Git-Tag: V9_0_0~1 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=fe526e557fce19238ec61bee437c6f1323ac3b52;p=tools%2Fyacsgen.git Small fix for Python3 --- 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)