utf8 issue #691
Labels
No Label
bug
build
dependencies
developers
documentation
duplicate
enhancement
formatting
invalid
legal
mobile
obsolete
packaging
performance
protocol
question
refactoring
regression
security
test
translation
usability
wontfix
No Milestone
No project
No Assignees
1 Participants
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: Bitmessage/PyBitmessage-2024-12-13#691
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Since the last update (few days ago) since I run Bitmessage I got this error, so the program continue to run and load message but this error don't let the GUI starts unfortunately.
There has been no change to lines 970 and 971 for at least 8 months. From the socket error message at the top I'm guessing it is a locale issue.
The documentation for time.strftime says this:
Unfortunately there are a more than a few lines that need this correction.
Okay, it's a bit weird since my locale is fr-FR.UTF8 but I'll try to fix the code on my own.
Thanks for the explanation.
I have been working on this but it is a little more complicated to get a fix working in all circumstances. The current code seems to indicate that the locale module could cause an exception simply for importing it.
locale.getlocale()
may return None as the language and/or encoding. On OSX in some caseslocale.getlocale()
andlocale.getdefaultlocale()
can cause an exception, which makes me wary oflocale.getpreferredencoding()
.Even though your locale specifies an encoding of UTF-8,
time.strftime()
is not actually returning UTF-8 encoded strings (as evidenced by the error) but ISO8859-1 encoded strings. I think is because Python relies on older non-unicode aware C functions and it is difficult to determine what encoding they use (due to the locale issues mentioned above).Now all that said, an easy fix is to avoid using the day and month names when formatting timestamps. Just change the timeformat setting in keys.dat using the directives specified in the documentation for time.strftime.
I have arrived at two simple solutions:
%Y-%m-%d %H:%M:%S
.locale.setlocale(locale.LC_ALL, '')
(see documentation for locale.setlocale and the locale module Background, details, hints, tips and caveats) in bitmessagemain.py and uselocale.getlocale()[1]
as recommended. The OSX issue is therefore avoided;locale.getdefaultlocale()
was used duelocale.getlocale()
returning(None, None)
becauselocale.setlocale()
wasn't called as above.Which solution is preferred?