Steps to reproduce
- Create scripts/userscripts/watchlists_core.py with the following content:
import pywikibot commons = pywikibot.Site(url='https://commons.wikimedia.org') print('Commons base_url: %s' % commons.base_url('/w/api.php')) meta = pywikibot.Site(url='https://meta.wikimedia.org') print('Meta base_url: %s' % meta.base_url('/w/api.php'))
- Run the script (e.g. ./pwb.py base_url_repro).
Actual result
Commons base_url: https://commons.wikimedia.org/w/api.php Meta base_url: https://commons.wikimedia.org/w/api.php
Expected result
Commons base_url: https://commons.wikimedia.org/w/api.php Meta base_url: https://meta.wikimedia.org/w/api.php
Software version
Latest master of Pywikibot (aa816795099f6eb6d7b381b0b8081c87c20507b9).
Other information
Notice the Meta base_url: in the actual result, it points to Commons. If I swap the two pairs of lines, both start to point to Meta. Clearly some caching is in the play, which may be triggered by the instantiation from URLs rather than from family/code pairs (in the real script I’m working on, I have access only to URLs and database names like commonswiki, so using family/code pairs is not an option).