jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/579756 )
Change subject: [cleanup] Remove outdated secure connection overrides ......................................................................
[cleanup] Remove outdated secure connection overrides
- Remove secure connection override settings from config2.py and show a related warning - remove EnableSSLSiteWrapper from api.py which is no longer needed
Bug: T247668 Change-Id: I570d822dc810331bb9cb9cbae2a9bd27960180cd --- M pywikibot/config2.py M pywikibot/data/api.py 2 files changed, 18 insertions(+), 49 deletions(-)
Approvals: Xqt: Looks good to me, approved jenkins-bot: Verified
diff --git a/pywikibot/config2.py b/pywikibot/config2.py index 08de9c4..0b7b20a 100644 --- a/pywikibot/config2.py +++ b/pywikibot/config2.py @@ -51,6 +51,7 @@ from distutils.version import StrictVersion from locale import getdefaultlocale from os import getenv, environ +from textwrap import fill from warnings import warn
from requests import __version__ as requests_version @@ -215,17 +216,6 @@ # Note: the target wiki site must install OAuth extension authenticate = {}
-# -# Secure connection overrides -# -# These settings are deprecated. They existed to support the Wikimedia -# family which only served HTTPS on https://secure.wikimedia.org/<site>/<uri> -# Use Family.protocol() -use_SSL_onlogin = False # if available, use SSL when logging in -use_SSL_always = False # if available, use SSL for all API queries -# Available secure projects should be listed here. -available_ssl_project = [] - # By default you are asked for a password on the terminal. # A password file may be used, e.g. password_file = '.passwd' # The path to the password file is relative to that of the user_config file. @@ -1080,6 +1070,12 @@ raise _DifferentTypeError(name, type(value), types)
+DEPRECATED_VARIABLE = ( + '"{}" present in our user-config.py is no longer a supported ' + 'configuration variable and should be removed. Please inform the ' + 'maintainers if you depend on it.') + + def _check_user_config_types(user_config, default_values, skipped): """Check the types compared to the default values.""" for name, value in user_config.items(): @@ -1095,15 +1091,19 @@ else: user_config[name] = value elif not name.startswith('_') and name not in skipped: - warn('Configuration variable "{0}" is defined in your ' - 'user-config.py but unknown. It can be a misspelled one or a ' - 'variable that is no longer supported.' - .format(name), UserWarning) + if name in _deprecated_variables: + warn('\n' + fill(DEPRECATED_VARIABLE.format(name)), + _ConfigurationDeprecationWarning) + else: + warn('\n' + + fill('Configuration variable "{0}" is defined in your ' + 'user-config.py but unknown. It can be a ' + 'misspelled one or a variable that is no longer ' + 'supported.'.format(name)), UserWarning)
_check_user_config_types(_exec_globals, _public_globals, _imports)
- # Copy the user config settings into globals _modified = {_key for _key in _public_globals.keys() if _exec_globals[_key] != globals()[_key]} @@ -1122,9 +1122,8 @@ globals()[_key] = _exec_globals[_key]
if _key in _deprecated_variables: - warn('"{0}" present in our user-config.py is no longer a supported ' - 'configuration variable. Please inform the maintainers if you ' - 'depend on it.'.format(_key), _ConfigurationDeprecationWarning) + warn(DEPRECATED_VARIABLE.format(_key), + _ConfigurationDeprecationWarning)
# If we cannot auto-detect the console encoding (e.g. when piping data) # assume utf-8. On Linux, this will typically be correct; on windows, diff --git a/pywikibot/data/api.py b/pywikibot/data/api.py index 381e21a..5a9922f 100644 --- a/pywikibot/data/api.py +++ b/pywikibot/data/api.py @@ -1044,31 +1044,6 @@ return len(self._enabled) + len(self._disabled)
-class EnableSSLSiteWrapper(object): - - """Wrapper to change the site protocol to https.""" - - def __init__(self, site): - """Initializer.""" - self._site = site - - def __repr__(self): - """Return internal representation.""" - return repr(self._site) - - def __eq__(self, other): - """Compare two objects.""" - return self._site == other - - def __getattr__(self, attr): - """Access object's site attributes.""" - return getattr(self._site, attr) - - def protocol(self): - """Return protocol.""" - return 'https' - - class Request(MutableMapping):
"""A request to a Site's api.php interface. @@ -1276,11 +1251,6 @@ pywikibot.debug('Adding user assertion', _logger) self['assert'] = 'user' # make sure user is logged in
- if (self.site.protocol() == 'http' and (config.use_SSL_always or ( - self.action == 'login' and config.use_SSL_onlogin)) - and self.site.family.name in config.available_ssl_project): - self.site = EnableSSLSiteWrapper(self.site) - @classmethod def create_simple(cls, site, **kwargs): """Create a new instance using all args except site for the API."""