%PYTHON%\python -W error::UserWarning -m generate_user_files -family:test -lang:test -v ... COMMAND: ['C:\\projects\\pywikibot-core\\generate_user_files.py', '-family:test', '-lang:test', '-v'] ... Unknown arguments: -m generate_user_files
The array after COMMAND: is sys.argv , whereas handle_args uses pywikibot.argvu[1:]
The unicode win32 argvu is obtained using GetCommandLineW and CommandLineToArgvW , which read the literal command line rather than the sys.argv value
The unicode win32 argvu does have code in pywikibot/userinterfaces/win32_unicode.py to handle -m , but it cant handle '-W error::UserWarning' before it.
The workaround is to remove the space between -W and error:...
%PYTHON%\python -Werror::UserWarning -m generate_user_files -family:test -lang:test -v