Skip to content

If running on the Japanese version of Windows XP or Vista, NVDA should displays the alert of OS version requirements#8771

Merged
michaelDCurran merged 4 commits into
nvaccess:masterfrom
nishimotz:winvercheck
Sep 25, 2018
Merged

If running on the Japanese version of Windows XP or Vista, NVDA should displays the alert of OS version requirements#8771
michaelDCurran merged 4 commits into
nvaccess:masterfrom
nishimotz:winvercheck

Conversation

@nishimotz

@nishimotz nishimotz commented Sep 22, 2018

Copy link
Copy Markdown
Contributor

Link to issue number:

Closes #7586

Summary of the issue:

If running on the Japanese version of Windows XP or Vista, NVDA raises error as follows.

See the logfile 'C:\Users\***\AppData\Local\Temp\***.tmp\app\nvda_noUIAccess.exe.log' for details
Traceback (most recent call last):
  File "nvda.pyw", line 77, in <module>
UnicodeDecodeError: 'ascii' codec can't decode byte 0x8e in position 0: ordinal not in range(128)

It makes difficult for supporters to solve the problem of the users.

Description of how this pull request fixes the issue:

  • if ctypes.FormatError() returns mbcs string, it should be decoded.
  • the code is expected to work with both Python 2.7 and Python 3.7.

Testing performed:

  • this workaround is already done for NVDA Japanese version 2018.3.1jp.

Known issues with pull request:

  • similar workaround may be necessary for other parts of NVDA, so we should avoid the duplication.

Change log entry:

Section: Bug fixes

If running on the Japanese version of Windows XP or Vista, NVDA now displays the alert of OS version requirements as expected.

…d display ERROR_OLD_WIN_VERSION message, rather than raising UnicodeDecodeError.
@nishimotz

Copy link
Copy Markdown
Contributor Author

The appveyor build nvda_snapshot_pr8771-16089,8e12d46c.exe is tested on Windows Vista Japanese and worked as expected.

@LeonarddeR LeonarddeR left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Personally, I'd rather have this addressed at the winUser.MessageBox level. You can add:

if isinstance(text, bytes)
    text = text.decode("mbcs")

Also, you could do the same to caption.

Than in NVDA.pyw, you can revert your change and change the MessageBox call as follows:

winUser.MessageBox(0, ctypes.FormatError(winUser.ERROR_OLD_WIN_VERSION), None, winUser.MB_ICONERROR)

…d display ERROR_OLD_WIN_VERSION message, rather than raising UnicodeDecodeError.
@nishimotz

Copy link
Copy Markdown
Contributor Author

@LeonarddeR Thank you for the review.
nvda_snapshot_pr8771-16090,2938b4c1.exe is tested and worked as well.

@LeonarddeR LeonarddeR left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

The use of isinstance instead of hasattr in my previous comment was intentional, see below.

Comment thread source/winUser.py Outdated
IDCANCEL=3

def MessageBox(hwnd, text, caption, type):
if hasattr(text, 'decode'):

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Please use isinstance(text, bytes) instead. Otherwise, this will lead to unnecessary decoding on python 2 unicode strings.

Comment thread source/winUser.py Outdated
def MessageBox(hwnd, text, caption, type):
if hasattr(text, 'decode'):
text = text.decode('mbcs')
if caption and hasattr(caption, 'decode'):

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

You can safely use hasattr on a None, so the if caption check is not required. Furthermore, also avoid using hasattr here and use an instance check instead.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Actually, at least on python 3, I'm pretty sure that you must ommit the if caption check. If you don't and you provide an empty byte string, ctypes might throw an error, telling you that you can't throw an empty byte string into a function that expects a wide character string.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

nvda_snapshot_pr8771-16091,73deebfe.exe is tested as well.

…d display ERROR_OLD_WIN_VERSION message, rather than raising UnicodeDecodeError.
LeonarddeR
LeonarddeR previously approved these changes Sep 22, 2018

@LeonarddeR LeonarddeR left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thanks for addressing the review comments. Looks all good now.

@michaelDCurran michaelDCurran merged commit 7b133e6 into nvaccess:master Sep 25, 2018
@nvaccessAuto nvaccessAuto added this to the 2018.4 milestone Sep 25, 2018
@ghost

ghost commented Oct 2, 2018

Copy link
Copy Markdown

Strangely, this problem was described a year ago, but then it was suggested to close it:
#7586

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

UnicodeDecodeError when NVDA running on non-English outdated systems

4 participants