changeset e93584465a85 in modules/account_statement_aeb43:default
details: 
https://hg.tryton.org/modules/account_statement_aeb43?cmd=changeset&node=e93584465a85
description:
        Use TextIOWrapper instead of encode/decode bytes with StringIO

        issue10554
        review344471003
diffstat:

 statement.py |  8 +++-----
 1 files changed, 3 insertions(+), 5 deletions(-)

diffs (24 lines):

diff -r 1eec8e360a81 -r e93584465a85 statement.py
--- a/statement.py      Sun Jul 04 17:54:46 2021 +0200
+++ b/statement.py      Thu Jul 22 00:05:32 2021 +0200
@@ -1,6 +1,6 @@
 # This file is part of Tryton.  The COPYRIGHT file at the top level of
 # this repository contains the full copyright notices and license terms.
-from io import StringIO
+from io import BytesIO, TextIOWrapper
 
 from stdnum.es.ccc import calc_check_digits, to_iban
 from csb43 import csb43
@@ -25,10 +25,8 @@
     __name__ = 'account.statement.import'
 
     def parse_aeb43(self, encoding='iso-8859-1'):
-        file_ = self.start.file_
-        if not isinstance(file_, str):
-            file_ = file_.decode(encoding)
-        aeb43 = csb43.File(StringIO(file_), strict=False)
+        file_ = TextIOWrapper(BytesIO(self.start.file_), encoding=encoding)
+        aeb43 = csb43.File(file_, strict=False)
 
         for account in aeb43.accounts:
             statement = self.aeb43_statement(account)

Reply via email to