PyBitmessage icon indicating copy to clipboard operation
PyBitmessage copied to clipboard

Fix the issues with non-ASCII characters in path on Windows

Open g1itch opened this issue 5 years ago • 7 comments

Hello!

This is the fix for the bug on Windows which was recently reported back in chan. When the messages.dat file path contains unicode characters the exception sqlite3.OperationalError: unable to open database file is raised and PyBitmessage stops loading.

I'm not sure about necessity of the change in class_sqlThread (os.path.join() instead of strings concatenation). The main problem is in encoding of the state.appdata string. I used the solution from https://stackoverflow.com/questions/35833037.

Related issues are: #165, #978

g1itch avatar Apr 22 '20 11:04 g1itch

Thank you, I think it is a step in the right direction. My testing shows that it still doesn't work. I found two issues.

  • an additional fix is needed if the directory with the executable / source contains unicode (as opposed to merely %APPDATA% being localised): pybitmessage-encoding2

  • there are at least some cases where it doesn't convert correctly: pybitmessage-encoding1

The tests are done on a 64bit Win10 with current updates.

PeterSurda avatar Apr 23 '20 01:04 PeterSurda

OK, thanks for hint. I've being able to reproduce it only in portable mode with many debug messages added. Can you please tell me how to get such detailed log in console?

g1itch avatar Apr 23 '20 08:04 g1itch

In the spec file set debug=True and console=True

PeterSurda avatar Apr 23 '20 09:04 PeterSurda

It looks like in my case there is an additional problem, I use a US locale in the OS but created a username with non-US characters. Python doesn't like it and I'm not sure how to fix that other than changing the user locale to something compatible, and relogin. After changing the locale it works even without this PR. Unless someone can report that this actually helped him I'm inclined to reject this PR.

PeterSurda avatar Apr 24 '20 03:04 PeterSurda

Hmm, I really cannot reproduce the issue with non-ASCII characters in username. What I see is the exception raised when you start PyBitmessage in portable mode from the directory containing non-ASCII characters:

[7372] LOADER: Post-init sys.path is C:\Users\DEBD1~1.BOG\AppData\Local\Temp\_MEI113682
[7372] LOADER: Setting sys.argv
[7372] LOADER: setting sys._MEIPASS
[7372] LOADER: importing modules from CArchive
[7372] LOADER: extracted struct
[7372] LOADER: callfunction returned...
[7372] LOADER: extracted pyimod01_os_path
[7372] LOADER: callfunction returned...
[7372] LOADER: extracted pyimod02_archive
[7372] LOADER: callfunction returned...
[7372] LOADER: extracted pyimod03_importers
[7372] LOADER: callfunction returned...
[7372] LOADER: Installing PYZ archive with Python modules.
[7372] LOADER: PYZ archive: PYZ-00.pyz
[7372] LOADER: Running pyiboot01_bootstrap.py
[7372] LOADER: Running pyi_rth__tkinter.py
[7372] LOADER: Running pyi_rth_pkgres.py
[7372] LOADER: Running pyi_rth_qt4plugins.py
[7372] LOADER: Running pyi_rth_multiprocessing.py
[7372] LOADER: Running bitmessagemain.py
INFO: PyQt Version: 4.11.4
INFO: Qt Version: 4.8.7
Number of threads: 2
Exception in thread SQL:
Traceback (most recent call last):
  File "threading.py", line 801, in __bootstrap_inner
  File "class_sqlThread.py", line 31, in run
OperationalError: unable to open database file

g1itch avatar Apr 24 '20 11:04 g1itch

Can you tell me how to trigger it?

PeterSurda avatar Apr 27 '20 07:04 PeterSurda

Can you tell me how to trigger it?

Put executable into the directory with non-ASCII character in it's name. Run it. Go into Settings and set "User Interface -> Run in Portable mode". Restart PyBitmessage.

g1itch avatar Apr 27 '20 17:04 g1itch