XZise created this task. XZise added subscribers: gerritbot, Ricordisamoa, jayvdb, pywikipedia-bugs, Aklapper, XZise, Wesalius. XZise added a project: pywikibot-core.
TASK DESCRIPTION As described in T95671, `pywikibot.config2` does issue a warning that the types have changed. The reason for the warning of `transliteration_target` looks straight forward. It is probably manually set in the user-config as a `str` (aka `bytes`) while the original value in the config2 module is `unicode`.
But I'm not sure why the warning of `console_encoding` appears. It is read from `sys.stdout.encoding` which is `str` (even with `unicode_literals`) which would explain why it was `str` but if it changed type and the warning appears that would mean @Wesalius has set the encoding using `u'…'` which seems unlikely.
Now to fix that we could do something similar like `int`/`float` handling so that if the type was `str` or `unicode` that it also expects the other type.
TASK DETAIL https://phabricator.wikimedia.org/T95810
REPLY HANDLER ACTIONS Reply to comment or attach files, or !close, !claim, !unsubscribe or !assign <username>.
EMAIL PREFERENCES https://phabricator.wikimedia.org/settings/panel/emailpreferences/
To: XZise Cc: Wesalius, XZise, Aklapper, jayvdb, Ricordisamoa, gerritbot, pywikipedia-bugs
Wesalius added a comment.
I have used the u' prefix, my user-config contains "usernames['wikipedia']['cs'] = u'HypoBOT'"
My console endcoding is set to 'utf-8' and transliteration_target to console_encoding.
TASK DETAIL https://phabricator.wikimedia.org/T95810
REPLY HANDLER ACTIONS Reply to comment or attach files, or !close, !claim, !unsubscribe or !assign <username>.
EMAIL PREFERENCES https://phabricator.wikimedia.org/settings/panel/emailpreferences/
To: Wesalius Cc: Wesalius, XZise, Aklapper, jayvdb, Ricordisamoa, gerritbot, pywikipedia-bugs
XZise added a comment.
That your username is in unicode doesn't have anything to do with the other warnings. And if you use `'utf-8'` it should be str, but maybe `unicode_literals` is inherited from the `config2` module. But if you set `transliteration_target` to the value of `console_encoding` it should be the same type. I'll try some tests on my own. Could you maybe show the lines where you define both?
TASK DETAIL https://phabricator.wikimedia.org/T95810
REPLY HANDLER ACTIONS Reply to comment or attach files, or !close, !claim, !unsubscribe or !assign <username>.
EMAIL PREFERENCES https://phabricator.wikimedia.org/settings/panel/emailpreferences/
To: XZise Cc: Wesalius, XZise, Aklapper, jayvdb, Ricordisamoa, gerritbot, pywikipedia-bugs
XZise added a comment.
Okay I've checked and “user-config.py” is read with `unicode_literals` so it doesn't matter if you define anything using `'foo'` or `u'foo'` because both are now unicode. But I couldn't get the `transliteration_target` warning. This is a snippet from my “user-config.py”:
password_file = '.passwd' print(type(password_file)) console_encoding = 'utf-8' transliteration_target = console_encoding
And it's not importing anything but this is the result:
import pywikibot
<type 'unicode'> WARNING: Type of 'console_encoding' changed Was: <type 'str'> Now: <type 'unicode'>
TASK DETAIL https://phabricator.wikimedia.org/T95810
REPLY HANDLER ACTIONS Reply to comment or attach files, or !close, !claim, !unsubscribe or !assign <username>.
EMAIL PREFERENCES https://phabricator.wikimedia.org/settings/panel/emailpreferences/
To: XZise Cc: Wesalius, XZise, Aklapper, jayvdb, Ricordisamoa, gerritbot, pywikipedia-bugs
Wesalius added a comment.
My user-config.py
password_file= 'passfile.txt'
transliteration_target = console_encoding cosmetic_changes = True console_encoding = 'utf-8'
TASK DETAIL https://phabricator.wikimedia.org/T95810
REPLY HANDLER ACTIONS Reply to comment or attach files, or !close, !claim, !unsubscribe or !assign <username>.
EMAIL PREFERENCES https://phabricator.wikimedia.org/settings/panel/emailpreferences/
To: Wesalius Cc: Wesalius, XZise, Aklapper, jayvdb, Ricordisamoa, gerritbot, pywikipedia-bugs
XZise added a comment.
AH you set the `transliteration_target` before `console_encoding`. Then it makes sense :) `console_encoding` is by default `str` and `transliteration_target` is set to `'not set'` which is `unicode`. Then you set `transliteration_target` to the value of `console_encoding` so to a `str` and then you change `console_encoding` to `'utf-8'` which is also `unicode`. So the result is as the warning presents:
- `transliteration_target` changed from `unicode` (`'not set'`) to `str` (`console_encoding` → `sys.stdout.encoding`) - `console_encoding` changed from `str` (`sys.stdout.encoding`) to `unicode` (`'utf-8'`)
Good that is this mystery solved :)
TASK DETAIL https://phabricator.wikimedia.org/T95810
REPLY HANDLER ACTIONS Reply to comment or attach files, or !close, !claim, !unsubscribe or !assign <username>.
EMAIL PREFERENCES https://phabricator.wikimedia.org/settings/panel/emailpreferences/
To: XZise Cc: Wesalius, XZise, Aklapper, jayvdb, Ricordisamoa, gerritbot, pywikipedia-bugs
Wesalius added a comment.
Ok, I changed the transliteration target back to none. But I cant test if the WARNING dissapeared since replace.py doesnt proceed with non-ascii chars (as in https://phabricator.wikimedia.org/T95803)
TASK DETAIL https://phabricator.wikimedia.org/T95810
REPLY HANDLER ACTIONS Reply to comment or attach files, or !close, !claim, !unsubscribe or !assign <username>.
EMAIL PREFERENCES https://phabricator.wikimedia.org/settings/panel/emailpreferences/
To: Wesalius Cc: Wesalius, XZise, Aklapper, jayvdb, Ricordisamoa, gerritbot, pywikipedia-bugs
pywikipedia-bugs@lists.wikimedia.org