Page MenuHomePhabricator

version.getfileversion does not work on py3, and should be rewritten
Closed, ResolvedPublic

Description

In verbose logging, the log is supposed to contain a list of the pywikibot modules loaded at startup, however on py3 it logs not modules.

The problem is the eval does not set local variable __version__

http://git.wikimedia.org/blob/pywikibot%2Fcore.git/9ca1b85c367b381947426c2615f4ab246e497518/pywikibot%2Fversion.py#L275

In addition, the algorithm is dodgy.

It checks every module name to see if it is a part of pywikibot, which is problematic if pywikibot has a module which has the same name as another package, and this approach also unnecessarily tries to stat many files which will not exist.

If it does find a pywikibot file, it reads the file to find __version__ even though Python has already loaded the module. it then exec's the first line which contains __version__, assuming it is an assignment to __version__.

module versions could be merged into version.package_versions(), as it already supports different types of entries (builtins, standard library)


Version: core-(2.0)
Severity: minor

Event Timeline

bzimport raised the priority of this task from to Low.Nov 22 2014, 3:54 AM
bzimport set Reference to bz71788.
bzimport added a subscriber: Unknown Object (????).

Change 192082 had a related patch set uploaded (by XZise):
[FEAT] version: actually interpret the version

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

Patch-For-Review

jayvdb set Security to None.

Change 192082 merged by jenkins-bot:
[FEAT] version: actually interpret the version

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