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

        issue10554
        review344471003
diffstat:

 account.py |  7 ++-----
 1 files changed, 2 insertions(+), 5 deletions(-)

diffs (23 lines):

diff -r 7fc5c9fb815a -r 23364379d074 account.py
--- a/account.py        Sun Jul 04 17:54:46 2021 +0200
+++ b/account.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 coda import CODA
 
@@ -23,10 +23,7 @@
     __name__ = 'account.statement.import'
 
     def parse_coda(self, encoding='windows-1252'):
-        file_ = self.start.file_
-        if not isinstance(file_, str):
-            file_ = file_.decode(encoding)
-        file_ = StringIO(file_)
+        file_ = TextIOWrapper(BytesIO(self.start.file_), encoding=encoding)
         coda = CODA(file_)
         for coda_statement in coda.statements:
             statement = self.coda_statement(coda_statement)

Reply via email to