I try to use rewrite lately, but I encounter something difficult to reslove.
--------
import pywikibot
class TestBot:
    def run(self):
        pywikibot.output(pywikibot.input('a'))
def main():
    bot = TestBot()
    bot.run()
if __name__ == "__main__":
    try:
        main()
    finally:
        pass
----------
While test case is "pwb test"
When I type "字母频率", which "频" is not supported by cp950, it shows " 字母?率" but "字母频率" is expected. In the same time, while using the same script in Pywikipedia, it correctly shows "字母频率.
Here is something stranger, if "学校" is used, the following error is given:
D:\pywikipedia>pwb test
a 学校
Traceback (most recent call last):
  File "D:\pywikipedia\pwb.py", line 50, in <module>
    execfile(sys.argv[0])
  File "D:\pywikipedia\scripts\self\test.py", line 21, in <module>
    main()
  File "D:\pywikipedia\scripts\self\test.py", line 17, in main
    bot.run()
  File "D:\pywikipedia\scripts\self\test.py", line 13, in run
    pywikibot.output(pywikibot.input('a'))
  File "D:\pywikipedia\pywikibot\bot.py", line 450, in input
    data = ui.input(question, password)
File "D:\pywikipedia\pywikibot\userinterfaces\terminal_interface.py", line 196, in input
    text = unicode(text, config.console_encoding)
UnicodeDecodeError: 'cp950' codec can't decode bytes in position 0-1: illegal multibyte sequence

When I try to do some tests myself, print(self.encoding) of terminal_interface_base.py of pywikipedia gives utf-8, while config.console_encoding of terminal_interface.py of rewrite gives cp950.

Can somebody help?

_______________________________________________
Pywikipedia-l mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/pywikipedia-l

Reply via email to