XZise has uploaded a new change for review.
https://gerrit.wikimedia.org/r/246942
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.
Conflicts:
pywikibot/config2.py
Change-Id: I538a73ff37da27a34ab732becafbf5a58b72a464
(cherry picked from commit bd44970f06c56626bb68c45a556bcb931f5480c6)
---
M pywikibot/config2.py
1 file changed, 8 insertions(+), 8 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/pywikibot/core
refs/changes/42/246942/1
diff --git a/pywikibot/config2.py b/pywikibot/config2.py
index f9dcab8..f2d644f 100644
--- a/pywikibot/config2.py
+++ b/pywikibot/config2.py
@@ -60,9 +60,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):
@@ -297,8 +297,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':
print(exc_text)
else:
exc_text += " Please check that user-config.py is stored in the
correct location.\n"
@@ -905,8 +905,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':
print("WARNING: Skipping loading of user-config.py.")
_fns = []
else:
@@ -1004,7 +1004,7 @@
# Fix up default site
-if family == 'wikipedia' and mylang == 'language' and _no_user_config != '2':
+if family == 'wikipedia' and mylang == 'language' and __no_user_config != '2':
print("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/246942
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: 2.0
Gerrit-Owner: XZise <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits