feature_init.py issue #23989

issue MarcoFalke openend this issue on January 6, 2022
  1. MarcoFalke commented at 2:24 pm on January 6, 2022: member
  2. MarcoFalke added the label Bug on Jan 6, 2022
  3. sogoagain commented at 3:44 pm on January 11, 2022: contributor

    Hello. It seems to be solved by adding errors='ignore' parameter when opening the file. Here is a snippet of code I just tested. It works fine.

    0s = b'\xe2vires in numeris\nbitcoin'
    1
    2with open('temp_string.txt', 'wb') as f:
    3    f.write(s)
    4
    5with open('temp_string.txt', 'r', encoding='utf8', errors='ignore') as f:
    6    line = f.readline()
    7    print(line)
    

    May I create a PR if it is okay to fix the issue in this way? thank you.

  4. MarcoFalke commented at 4:03 pm on January 11, 2022: member

    I think it might be better to open the stream as a raw byte stream, if possible.

    After all the lines are dropped anyway and don’t need to be decoded.

  5. sogoagain commented at 4:24 pm on January 11, 2022: contributor

    Good idea. Opening the file as a byte stream is no problem. I’ll fix it like that.

    Thank you for answer.

  6. mzumsande commented at 4:42 pm on January 11, 2022: member
    I wonder what is the root cause, i.e. why non-unicode characters can appear in the log in the first place. Is the simultaneous writing to (by bitcoind LogPrint commands) and reading from the log (python) the issue because the writing of a given line can be non-atomic? Also, should there be a wait in the while(True) python loop?
  7. MarcoFalke commented at 5:01 pm on January 11, 2022: member

    I wonder what is the root cause, i.e. why non-unicode characters can appear in the log in the first place.

    I assume that the file was read partially while some emoji was written?

  8. mzumsande commented at 5:31 pm on January 11, 2022: member

    I assume that the file was read partially while some emoji was written?

    Ah yes, could be the “₿” from the path name, which starts with 0xe2 (the byte reported in https://cirrus-ci.com/task/6633293054476288?logs=ci#L5910 )

  9. MarcoFalke referenced this in commit db1f04fa8c on Jan 12, 2022
  10. MarcoFalke closed this on Jan 12, 2022

  11. sidhujag referenced this in commit c102d65717 on Jan 12, 2022
  12. rebroad referenced this in commit c405487379 on Feb 3, 2022
  13. Fabcien referenced this in commit 35a1c2dc38 on Nov 25, 2022
  14. DrahtBot locked this on Jan 12, 2023

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2024-12-25 18:12 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me