Issue #32 new

Binary strings with MO data can't be read

Frank Smit
created an issue

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?

Comments (7)

  1. Frank Smit reporter

    Which Python vesion do you want to support? Personally I only support 2.7 and 3.2+.

    And I think the change is going to be bigger than I thought. All file writing/reading and file path checks need to be changed.

  2. David Jean Louis repo owner

    Which Python vesion do you want to support?

    Polib supports python 2.5 to 3.3, I don't care too much if we drop 2.5, but I'd like to keep 2.6 support.

    And I think the change is going to be bigger than I thought

    Indeed, it's not that simple. But I think it's feasible because path checkes are mostly done in save() methods, that are not relevant for StringIO.

  3. Frank Smit reporter

    Loading file-like objects and strings works now. Saving, cleanups and documentation are left. I'm continuing when I need it in the project I'm working on, which is in a week or two.

  4. Frank Smit reporter

    Sorry, it just got really busy at my internship and then I kinda forgot. I'll be able to provide the pull request. Are you planning a release or got a date in mind?

  5. Log in to comment