Page MenuHomePhabricator

Pywikibot made unmentioned breaking change in 8.3.0
Closed, InvalidPublicBUG REPORT

Description

Steps to replicate the issue (include links if applicable):

  • Run code in pywikibot 8.2.0
  • Run code in pywikibot 8.3.0
import pywikibot
print(pywikibot.DataSite)

What happens?:

On 8.3.0, the code chunk throws an exception that it did not in 8.2.0

What should have happened instead?:

Behavior should have remained consistent

Software version (skip for WMF-hosted wikis like Wikipedia): Pywikibot 8.3.0

Other information (browser name/version, screenshots, etc.):

https://github.com/wikimedia/pywikibot/commit/858fc1e1bcc65a7ce987d7b6a8be8a61c540af2e removed DataSite from pywikibot/__init__,py and did not make it available again. Any old code that used pywikibot.DataSite now broke.

Event Timeline

Objects imported into a module are not guaranteed to be stable across versions. The stable interface for creating site objects is pywikibot.Site().

I was using DataSite to enhance type information, since pywikibot.Site() only returns methods shared by all types of sites, and I needed some Wikidata-specific methods.

From the pywikibot.Site documentation:

WARNING: Never create a site object via interface class directly. Always use this factory method.

Change 994187 had a related patch set uploaded (by Xqt; author: Xqt):

[pywikibot/core@master] [cleanup] Drop pywikibot.BaseSite and pywikibotAPISite

https://gerrit.wikimedia.org/r/994187

@RPI2026F1: You can import the classes from pywikibot.site to compare them or (for duck typing) check for having the methods or finally test the type(site).__name__ where site is the object returned by pywikibot.Site() constuctor.

Change 994187 merged by jenkins-bot:

[pywikibot/core@master] [cleanup] Drop pywikibot.BaseSite and pywikibotAPISite

https://gerrit.wikimedia.org/r/994187