Fix open of Contributors and License Help menu options on Windows 11 #14816
Conversation
See test results for failed build of commit c64df92087 |
|
Good idea, what are we saying then, that running it twice ruins the fix in
older windows?
Brian
…--
***@***.***
Sent via blueyonder.(Virgin media)
Please address personal E-mail to:-
***@***.***, putting 'Brian Gaff'
in the display name field.
----- Original Message -----
From: "Lukasz Golonka" ***@***.***>
To: "nvaccess/nvda" ***@***.***>
Cc: "Subscribed" ***@***.***>
Sent: Monday, April 10, 2023 12:54 PM
Subject: Re: [nvaccess/nvda] Fix open of Contributors and License Help menu
options on Windows 11 (PR #14816)
@lukaszgo1 commented on this pull request.
> @@ -484,10 +484,22 @@ def __init__(self, frame: MainFrame):
self.Bind(wx.EVT_MENU, lambda evt:
os.startfile("http://www.nvda-project.org/"), item)
# Translators: The label for the menu item to view NVDA License document.
item = menu_help.Append(wx.ID_ANY, _("L&icense"))
- self.Bind(wx.EVT_MENU, lambda evt:
os.startfile(getDocFilePath("copying.txt", False)), item)
+ # Using operation="edit" to os.startfile below, to work around a Windows
11 related
+ # bug in Python 3.7's os.startfile. (#14725) Test reverting to original
behavior after Python upgrade.
Can this comment and the logic responsible for opening text files be moved
to a separate function in `systemUtils`? This ensures that both code and
the accompanying comment is not duplicated, and provides add-on developers
with a tested way for opening text files under all versions of Windows.
--
Reply to this email directly or view it on GitHub:
#14816 (review)
You are receiving this because you are subscribed to this thread.
Message ID: ***@***.***>
|
|
@seanbudd PR description updated; new function created; a couple little unrelated odds and ends fixed. Ready for re-review. |
|
@lukaszgo1 Regarding your request to put this in a public function so that add-ons can use it: It turns out, according to this mailing list post, that it would not have worked anyway. Evidently, the |
|
This seems strange to me. If a routine is being called one might expect it
to be used by all such file open attempts using the same function, unless
there is another, similar one we do not know about, or course.
Brian
…--
***@***.***
Sent via blueyonder.(Virgin media)
Please address personal E-mail to:-
***@***.***, putting 'Brian Gaff'
in the display name field.
----- Original Message -----
From: "Luke Davis" ***@***.***>
To: "nvaccess/nvda" ***@***.***>
Cc: "Brian Gaff" ***@***.***>; "Comment"
***@***.***>
Sent: Tuesday, April 11, 2023 9:06 AM
Subject: Re: [nvaccess/nvda] Fix open of Contributors and License Help menu
options on Windows 11 (PR #14816)
@lukaszgo1 Regarding your request to put this in a public function so that
add-ons can use it:
It turns out, according to [this mailing list
post](https://nvda.groups.io/g/nvda/message/105816), that it would not
have worked anyway. Evidently, the `operation="edit"` fix, only works for
files under "`Program Files`" directories.
--
Reply to this email directly or view it on GitHub:
#14816 (comment)
You are receiving this because you commented.
Message ID: ***@***.***>
|
There was a problem hiding this comment.
I've noticed more discussion in the mailing list thread
Does this fix still work correctly? What if NVDA is running as a portable copy outside program files?
Copy file "copying.txt" to "c:"
and in the console, execute the command "os.startfile(r"C:\copying.txt", operation="edit").
The error occurs.
Now copy the same file to "c:\Program files (x86)" and run the command:
os.startfile(r"C:\Program Files (x86)\copying.txt", operation="edit").
…systems. (#14816) Per #14725, Windows 11 can't open text files in Notepad with os.startfile's default operation. - Added the _displayTextFileWorkaround function to the systemUtils module. - Called it wherever os.startfile was opening a .txt file in gui/__init__.py. - The function uses os.startfile's "edit" operation to open the text file, which still uses Notepad, at least on most systems. Additionally: gui.MainFrame was importing systemUtils late, in __init__, and onRunCOMRegistrationFixesCommand. - Moved to a single import in top section.
|
@seanbudd The tests you requested have been done by @britechguy, and I have updated the description with the results. The original problem didn't exist for portable copies as far as anyone reported, so we hadn't tested that exhaustively before. Other than that, I have moved the comments inside the def (because PEP-8 said so); the commit text should be good as-is; and the questionable side-lints have been withdrawn. |
|
@seanbudd GTG |
|
Thanks @XLTechie |
Link to issue number:
Fixes #14725
Summary of the issue:
Under Windows 11, attempting to open the NVDA Help menu items "Contributors" or "License", results in Notepad trying to open nonsense filenames while using installed, normal user level, copies of NVDA
Through testing, this has been narrowed to a bug in
os.startfilein Python 3.7 as invoked on Windows 11, though the actual bug may be in a lower level library. The bug does not seem to occur when using the commandline "start" command.It also does not occur in portable or admin level copies of NVDA.
Description of user facing changes
Restores the ability to open the Contributors List or License file from the NVDA Help menu.
Description of development approach
Through testing, I and @britechguy were able to narrow the source of the errors, and determine that attempting to open the file for editing, rather than by trusting the Windows open file association for .txt files, would open these files in Notepad correctly.
Taken from the text of the commit:
_displayTextFileWorkaroundfunction to thesystemUtilsmodule.os.startfilewas opening a .txt file ingui/__init__.py.os.startfile's "edit" operation to open the text file, which still uses Notepad, at least on most systems.Additionally:
Testing strategy:
os.startfileas described, opens these files correctly under Windows 11. While calling it the standard way from the Python console, results in nonsense filenames being delivered to Notepad, and the subsequent failure of the task.copying.txtat the root of the system drive, using the Python console.copying.txtplaced at the root of the USB drive.Additionally, to confirm that consolidating and moving the imports of
systemUtilsdidn't break anything, I tested that NVDA launched, and the COM Registration Fixing Tool still works, under Windows 10, which is sufficient.Tested on:
Known issues with pull request:
operation="edit"under Windows 10. Since this seemed (1) rather harmless, and (2) a low impact bug, I didn't think it was necessary to test for Windows version before deciding which call structure to use for the new function.Change log entries:
Bug fixes
In Windows 11, it is (once again) possible to open the Contributors and License items on the NVDA Help menu.
Code Review Checklist: