| zhuyifei1999 added a subscriber: Dalba. zhuyifei1999 added a comment. |
I did this diff:
zhuyifei1999@zhuyifei1999-ThinkPad-X260:~/mw-dev/pywikibot-core$ git diff diff --git a/pywikibot/pagegenerators.py b/pywikibot/pagegenerators.py index ec06f313..95cf67dd 100644 --- a/pywikibot/pagegenerators.py +++ b/pywikibot/pagegenerators.py @@ -1176,6 +1176,7 @@ class GeneratorFactory(object): if value == '': value = None + print(repr('_handle_', arg[1:], '_handle_' + arg[1:])) handler = getattr(self, '_handle_' + arg[1:], None) if handler: handler_result = handler(value)
Confirming everything is unicode:
zhuyifei1999@zhuyifei1999-ThinkPad-X260:~/mw-dev/pywikibot-core$ python pwb.py replace .ì family and mylang are not set. Defaulting to family='test' and mylang='test'. (u'_handle_', u'\xec', u'_handle_\xec') Traceback (most recent call last): File "pwb.py", line 251, in <module> if not main(): File "pwb.py", line 244, in main run_python_file(filename, [filename] + args, argvu, file_package) File "pwb.py", line 115, in run_python_file main_mod.__dict__) File "./scripts/replace.py", line 1198, in <module> main() File "./scripts/replace.py", line 924, in main if genFactory.handleArg(arg): File "/home/zhuyifei1999/mw-dev/pywikibot-core/pywikibot/pagegenerators.py", line 1180, in handleArg handler = getattr(self, '_handle_' + arg[1:], None) UnicodeEncodeError: 'ascii' codec can't encode character u'\xec' in position 8: ordinal not in range(128) <type 'exceptions.UnicodeEncodeError'> CRITICAL: Closing network session.So the error is getattr cannot process a non-ascii unicode, and I can confirm this:
zhuyifei1999@zhuyifei1999-ThinkPad-X260:~/mw-dev/pywikibot-core$ python Python 2.7.15rc1 (default, Apr 15 2018, 21:51:34) [GCC 7.3.0] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> type(b'footype', (object,), {})() <__main__.footype object at 0x7efc8e62c110> >>> getattr(type(b'footype', (object,), {})(), 'ì') Traceback (most recent call last): File "<stdin>", line 1, in <module> AttributeError: 'footype' object has no attribute 'ì' >>> getattr(type(b'footype', (object,), {})(), u'ì') Traceback (most recent call last): File "<stdin>", line 1, in <module> UnicodeEncodeError: 'ascii' codec can't encode character u'\xec' in position 0: ordinal not in range(128)So, #regression from d8ffde8. CC @Dalba
TASK DETAIL
EMAIL PREFERENCES
To: zhuyifei1999
Cc: Dalba, zhuyifei1999, Aklapper, Multichill, pywikibot-bugs-list, .avgas, Andrewjhill, Jrbranaa, Magul, Tbscho, MayS, Mdupont, JJMC89, Avicennasis, Wong128hk, mys_721tx, jayvdb, Masti, Alchimista, Rxy
Cc: Dalba, zhuyifei1999, Aklapper, Multichill, pywikibot-bugs-list, .avgas, Andrewjhill, Jrbranaa, Magul, Tbscho, MayS, Mdupont, JJMC89, Avicennasis, Wong128hk, mys_721tx, jayvdb, Masti, Alchimista, Rxy
_______________________________________________ pywikibot-bugs mailing list [email protected] https://lists.wikimedia.org/mailman/listinfo/pywikibot-bugs
