XZise has uploaded a new change for review.
https://gerrit.wikimedia.org/r/246853
Change subject: [FIX] config: Don't crash on later get_base_dir calls
......................................................................
[FIX] config: Don't crash on later get_base_dir calls
All module variables starting with only one underscore get deleted after the
module's instantiation and with 2b07db2a the variable to store whether no user
config should be loaded was stored in such a variable and thus deleted so that
when `get_base_dir` was called afterwards it would crash because it is missing.
This patch renames the variable into using two underscores to still hide it's
presence but prevent it from deletion after the instantiation.
Change-Id: I538a73ff37da27a34ab732becafbf5a58b72a464
---
M pywikibot/config2.py
1 file changed, 8 insertions(+), 8 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/pywikibot/core
refs/changes/53/246853/1
diff --git a/pywikibot/config2.py b/pywikibot/config2.py
index 4cac315..8fd624e 100644
--- a/pywikibot/config2.py
+++ b/pywikibot/config2.py
@@ -70,9 +70,9 @@
# names and some magic variables (like __name__)
_imports = frozenset(name for name in globals() if not name.startswith('_'))
-_no_user_config = os.environ.get('PYWIKIBOT2_NO_USER_CONFIG')
-if _no_user_config == '0':
- _no_user_config = None
+__no_user_config = os.environ.get('PYWIKIBOT2_NO_USER_CONFIG')
+if __no_user_config == '0':
+ __no_user_config = None
class _ConfigurationDeprecationWarning(UserWarning):
@@ -323,8 +323,8 @@
# check if user-config.py is in base_dir
if not exists(base_dir):
exc_text = "No user-config.py found in directory '%s'.\n" % base_dir
- if _no_user_config:
- if _no_user_config != '2':
+ if __no_user_config:
+ if __no_user_config != '2':
output(exc_text)
else:
exc_text += " Please check that user-config.py is stored in the
correct location.\n"
@@ -935,8 +935,8 @@
# Get the user files
_thislevel = 0
-if _no_user_config:
- if _no_user_config != '2':
+if __no_user_config:
+ if __no_user_config != '2':
warning('Skipping loading of user-config.py.')
_fns = []
else:
@@ -1072,7 +1072,7 @@
# Fix up default site
if family == 'wikipedia' and mylang == 'language':
- if _no_user_config != '2':
+ if __no_user_config != '2':
warning('family and mylang are not set.\n'
"Defaulting to family='test' and mylang='test'.")
family = mylang = 'test'
--
To view, visit https://gerrit.wikimedia.org/r/246853
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I538a73ff37da27a34ab732becafbf5a58b72a464
Gerrit-PatchSet: 1
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: XZise <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits