Background information:
- The script cosmetic_changes.py crashes when working on arz:قالب:\w
Steps to replicate the issue (include links if applicable):
python pwb.py cosmetic_changes -page:"قالب:\w" -lang:arz
What happens?:
Retrieving 1 pages from wikipedia:arz.
>>> قالب:\w <<<
1 read operation
Execution time: 0 seconds
Read operation time: 0.0 seconds
Script terminated by exception:
ERROR: bad escape \w at position 14 (line 1, column 15) (error)
Traceback (most recent call last):
File "C:\Users\Mohammed\Downloads\core\pwb.py", line 39, in <module>
sys.exit(main())
^^^^^^
File "C:\Users\Mohammed\Downloads\core\pwb.py", line 35, in main
runpy.run_path(str(path), run_name='__main__')
File "<frozen runpy>", line 291, in run_path
File "<frozen runpy>", line 98, in _run_module_code
File "<frozen runpy>", line 88, in _run_code
File "C:\Users\Mohammed\Downloads\core\pywikibot\scripts\wrapper.py", line 516, in <module>
main()
File "C:\Users\Mohammed\Downloads\core\pywikibot\scripts\wrapper.py", line 500, in main
if not execute():
^^^^^^^^^
File "C:\Users\Mohammed\Downloads\core\pywikibot\scripts\wrapper.py", line 487, in execute
run_python_file(filename, script_args, module)
File "C:\Users\Mohammed\Downloads\core\pywikibot\scripts\wrapper.py", line 147, in run_python_file
exec(compile(source, filename, 'exec', dont_inherit=True),
File "C:\Users\Mohammed\Downloads\core\scripts\cosmetic_changes.py", line 131, in <module>
main()
File "C:\Users\Mohammed\Downloads\core\scripts\cosmetic_changes.py", line 127, in main
bot.run()
File "C:\Users\Mohammed\Downloads\core\pywikibot\bot.py", line 1702, in run
self.treat(page)
File "C:\Users\Mohammed\Downloads\core\pywikibot\bot.py", line 1956, in treat
self.treat_page()
File "C:\Users\Mohammed\Downloads\core\scripts\cosmetic_changes.py", line 84, in treat_page
new_text = cc_toolkit.change(old_text)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Mohammed\Downloads\core\pywikibot\cosmetic_changes.py", line 302, in change
new_text = self._change(text)
^^^^^^^^^^^^^^^^^^
File "C:\Users\Mohammed\Downloads\core\pywikibot\cosmetic_changes.py", line 296, in _change
text = self.safe_execute(method, text)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Mohammed\Downloads\core\pywikibot\cosmetic_changes.py", line 283, in safe_execute
result = method(text)
^^^^^^^^^^^^
File "C:\Users\Mohammed\Downloads\core\pywikibot\cosmetic_changes.py", line 384, in standardizePageFooter
text = textlib.replaceLanguageLinks(text, interwiki_links,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Mohammed\Downloads\core\pywikibot\tools\_deprecate.py", line 396, in wrapper
return obj(*__args, **__kw)
^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Mohammed\Downloads\core\pywikibot\textlib.py", line 1217, in replaceLanguageLinks
newtext = regexp.sub(s + includeOff, s2)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.11_3.11.752.0_x64__qbz5n2kfra8p0\Lib\re\__init__.py", line 317, in _subx
template = _compile_repl(template, pattern)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.11_3.11.752.0_x64__qbz5n2kfra8p0\Lib\re\__init__.py", line 308, in _compile_repl
return _parser.parse_template(repl, pattern)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.11_3.11.752.0_x64__qbz5n2kfra8p0\Lib\re\_parser.py", line 1078, in parse_template
raise s.error('bad escape %s' % this, len(this)) from None
re.error: bad escape \w at position 14 (line 1, column 15)
CRITICAL: Exiting due to uncaught exception <class 're.error'>What should have happened instead?:
The script should have skipped this page (when working on a whole namespace) and continued working on other pages normally.
Software version :
Pywikibot: [https] r-pywikibot-core (3eb032e, g17569, 2023/02/16, 13:17:24, master)
Release version: 8.1.0.dev0
setuptools version: 67.3.2
mwparserfromhell version: 0.6.4
wikitextparser version: n/a
requests version: 2.28.2
certificate test: ok
Python: 3.11.2 (tags/v3.11.2:878ead1, Feb 7 2023, 16:38:35) [MSC v.1934 64 bit (AMD64)]