jseutter / ofxparse

Ofx file format parser for Python
http://sites.google.com/site/ofxparse/
MIT License
204 stars 121 forks source link

Support text file handler #119

Closed tonnydourado closed 7 years ago

tonnydourado commented 7 years ago

If I pass a file opened in text mode (mode='r' as oppose to mode='rb'), OfxParser.parse fails, in Python 3 (3.5, to be more exact) because it ends up trying to mix bytes and str when reading the headers, here. Even after fixing it, though, it still fails in OfxPreprocessedFile, when it tries to read from self.fh. It happens because self.fh, at that point, is a codecs.StreamReader, which will only work with bytes streams (again, at least on Python 3). This pull request fixes this, at least in Python 3.5 and 2.7.

jseutter commented 7 years ago

This behavior has existed for a long time and I never thought of a good solution for it. Thanks!