I would like to read/parse MO data from strings (when the source is the database and not a file), but after a quick test I discovered it's not possible. polib raises some exceptions, because it sees null bytes in the byte string.
Instead of accepting strings with the PO data, or a file path, accept a StringIO/BytesIO object or a string with the file path. This way the PO/MO data can be distinguished from a filepath.
I can make a pull request for this.
What do you think of this?