Opening a file in binary mode in python3 returns a BufferedReader which does not have an encoding attribute. Assume in this case it is functionally equivalent to None. I'm not sure when pml_stream.encoding will ever equal anything, since even on python2 the attribute exists but is None when opening files in binary mode... which we explicitly do. So I'm not sure why this ever checks the existing encoding. Possibly when the input plugin is given a file opened in text mode, not raw mode? in that case, it may be wrong to always decode it when reading.
calibre

calibre is an e-book manager. It can view, convert, edit and catalog e-books in all of the major e-book formats. It can also talk to e-book reader devices. It can go out to the internet and fetch metadata for your books. It can download newspapers and convert them into e-books for convenient reading. It is cross platform, running on Linux, Windows and macOS.
For more information, see the calibre About page
Screenshots
Usage
See the User Manual
Development
Setting up a development environment for calibre
A tarball of the source code for the current calibre release.
Bugs
Bug reports and feature requests should be made in the calibre bug tracker at launchpad. GitHub is only used for code hosting and pull requests.
Support calibre
calibre is a result of the efforts of many volunteers from all over the world. If you find it useful, please consider contributing to support its development. Donate to support calibre development.