Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 4 commits into
base: v0.6
Choose a base branch
from

Conversation

g1itch
Copy link
Collaborator

@g1itch g1itch commented Apr 22, 2020

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

@PeterSurda PeterSurda self-requested a review April 23, 2020 00:14
@PeterSurda PeterSurda added the bug Something isn't working as it's supposed to label Apr 23, 2020
@PeterSurda
Copy link
Member

PeterSurda commented Apr 23, 2020

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.

@g1itch
Copy link
Collaborator Author

g1itch commented Apr 23, 2020

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?

@PeterSurda
Copy link
Member

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

@PeterSurda
Copy link
Member

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.

@g1itch
Copy link
Collaborator Author

g1itch commented Apr 24, 2020

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

@PeterSurda
Copy link
Member

Can you tell me how to trigger it?

@g1itch
Copy link
Collaborator Author

g1itch commented Apr 27, 2020

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 g1itch changed the title Fix exception in class_sqlThread on Windows Fix the issues with non-ASCII characters in path on Windows Apr 28, 2020
@g1itch g1itch force-pushed the windows branch 3 times, most recently from 73aca94 to 1e56f50 Compare April 30, 2020 12:21
Copy link
Member

@PeterSurda PeterSurda left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok.

@g1itch g1itch marked this pull request as draft July 1, 2021 16:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working as it's supposed to
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants