Page MenuHomePhabricator

config default editor on Windows detection fails
Closed, ResolvedPublic

Description

Steps to reproduce (core):

  1. Set up an editor for .txt
  2. Run python pwb.py pywikibot/config2.py

Expected results:
The 'editor' config variable should be set to the editor set up for .txt. i.e.
editor='C:\\Path\\to\\editor.exe'

Actual results:
editor=None

pywikibot configuration tries to automatically detect a text editor to use, using the Windows registry key Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.txt\OpenWithProgids

That exists for WinXP and later versions, and documentation can be found here:
http://msdn.microsoft.com/en-us/library/bb166549.aspx
http://msdn.microsoft.com/en-us/library/bb165967.aspx

As can be seen in that documentation, the key name is relevant, and the key value is always REG_NONE (zero-length binary value)

However to find the appropriate progid within that key, pywikbot uses _winreg.EnumValue(key, 1)

As can be seen at https://docs.python.org/2/library/_winreg.html#_winreg.EnumValue , the '1' in the second parameter returns "An object that holds the value data, and whose type depends on the underlying registry type".

Changing it to _winreg.EnumValue(key, 0) causes _winreg to return "A string that identifies the value name" and suddenly the detection works correctly.

This has existed since the first version in compat/ in 2007
https://git.wikimedia.org/blobdiff/pywikibot%2Fcompat/36a702559c94c0b12f5cc292492e51172ba80bf5/config.py

However, it doesnt really work as one would expect, since it hooks onto .txt, rather than .py


Version: core-(2.0)
Severity: normal

Event Timeline

bzimport raised the priority of this task from to Needs Triage.Nov 22 2014, 3:34 AM
bzimport set Reference to bz68315.

Change 160942 had a related patch set uploaded by John Vandenberg:
Fix Win32 config.editor detection

https://gerrit.wikimedia.org/r/160942

Change 160942 had a related patch set uploaded (by John Vandenberg):
Fix Win32 config.editor detection

https://gerrit.wikimedia.org/r/160942

Change 160942 merged by jenkins-bot:
Fix Win32 config.editor detection

https://gerrit.wikimedia.org/r/160942

Change 223868 had a related patch set uploaded (by Merlijn van Deen):
Fix Win32 config.editor detection

https://gerrit.wikimedia.org/r/223868

Change 223868 merged by jenkins-bot:
Fix Win32 config.editor detection

https://gerrit.wikimedia.org/r/223868