Page MenuHomePhabricator

do not deprecate getversion_svn and svn_rev_info in version.py
Closed, ResolvedPublic

Description

Bot getversion_svn and svn_rev_info are still in use. They should not be deprecated until the other method always works and this fallback is no longer needed. See https://integration.wikimedia.org/ci/job/tox-jessie/6817/console for example, which contains...

07:18:32   /home/jenkins/workspace/tox-jessie$ /home/jenkins/workspace/tox-jessie/.tox/py34/bin/python -m unittest discover -p *tests.py 
07:18:33 Processing 0 images...
07:18:33 Could not load cache: UnicodeDecodeError('ascii', b'\x07\xe0\x04\n\x07\x12\x15\x07g\xe5', 1, 2, 'ordinal not in range(128)')
07:18:33 WARNING: /home/jenkins/workspace/tox-jessie/.tox/py34/lib/python3.4/site-packages/pywikibot/version.py:101: DeprecationWarning: pywikibot.version.getversion_svn is deprecated; use getversion_svn_setuptools instead.
07:18:33   (tag, rev, date, hsh) = vcs_func(_program_dir)
07:18:33 
07:18:33 WARNING: /home/jenkins/workspace/tox-jessie/.tox/py34/lib/python3.4/site-packages/pywikibot/version.py:252: DeprecationWarning: pywikibot.version.svn_rev_info is deprecated; use getversion_svn_setuptools instead.
07:18:33   tag, rev, date = svn_rev_info(_program_dir)
07:18:33 
07:18:33 Could not load cache: UnicodeDecodeError('ascii', b'\x07\xe0\x04\n\x07\x12\x15\x08+a', 1, 2, 'ordinal not in range(128)')

Event Timeline

Change 282524 had a related patch set uploaded (by Xqt):
[fix] remove deprecated decorator for getversion_svn and svn_rev_info

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

getversion_svn should be last in the list, and not executed if any of the other functions work. It is a fallback, but it a deprecated solution. We have a better solution getversion_svn_setuptools , and we are keeping the old solution while we iron out any bugs in getversion_svn_setuptools and https://pypi.python.org/pypi/setuptools_svn ?

Can you link to bugs in getversion_svn_setuptools ?

What is interesting is that in the log you refer to, the VCS is git, so the loop should stop after getversion_git and both getversion_svn_setuptools and getversion_svn shouldnt be run at all...?

I've linked it in the description above. I found it in jenkins' test of my repository.

You are right. That svn should not be triggered by Jenkins at all. Anyway sth is going wrong here.

Ah, this DeprecatedWarning only occurs for py3 and there is an UnicodeDecodeError just before. I guess that this bug occurred in getversion_git and it falls back to the other methods. Unfortunately there is no hint where that bug comes up.

The UnicodeDecodeError appearing in the tox logs are unrelated to this.

Xqt triaged this task as Low priority.Oct 30 2016, 11:45 AM

I personally agree here with @jayvdb , that we should resolve issues and do not revert DeprecatedWarning, especially in master branch, and that it doesn't break anything, just logs something.

This bug is still there when running version under svn:

C:\pwb\SVN\core>pwb.py version
WARNING: C:\pwb\SVN\core\pywikibot\version.py:101: DeprecationWarning: pywikibot.version.getversion_svn is deprecated; use getversion_svn_setuptools instead.
  (tag, rev, date, hsh) = vcs_func(_program_dir)

WARNING: C:\pwb\SVN\core\pywikibot\version.py:252: DeprecationWarning: pywikibot.version.svn_rev_info is deprecated; use getversion_svn_setuptools instead.
  tag, rev, date = svn_rev_info(_program_dir)

Pywikibot: pywikibot/__init__.py (, -1 (unknown), 2017/05/02, 11:53:35, n/a)
Release version: 3.0-dev
requests version: 2.13.0
  cacerts: C:\Program Files (x86)\Python36-32\lib\site-packages\requests\cacert.pem
    certificate test: ok
Python: 3.6.1 (v3.6.1:69c0db5, Mar 21 2017, 17:54:52) [MSC v.1900 32 bit (Intel)]
PYWIKIBOT2_DIR: Not set
PYWIKIBOT2_DIR_PWB: C:\pwb\SVN\core
PYWIKIBOT2_NO_USER_CONFIG: Not set
Config base dir: C:\pwb\SVN\core
Usernames for family "commons":
        commons: Xqbot (no sysop configured)
Usernames for family "wikidata":
        repo: Xqt (no sysop configured)
Usernames for family "wikipedia":
        ab: Xqbot (no sysop configured)

C:\pwb\SVN\core>

The same for py2:

C:\pwb\SVN\core>py -2 pwb.py version -v
WARNING: C:\pwb\SVN\core\pywikibot\tools\ip.py:74: ImportWarning: Importing ipaddr.IPAddress failed: No module named ipaddr
Importing ipaddress.ip_address failed: No module named ipaddress
Please install ipaddr 2.1.10+ or ipaddress.
WARNING: C:\pwb\SVN\core\pywikibot\version.py:101: DeprecationWarning: pywikibot.version.getversion_svn is deprecated; use getversion_svn_setuptools instead.
  (tag, rev, date, hsh) = vcs_func(_program_dir)

WARNING: C:\pwb\SVN\core\pywikibot\version.py:252: DeprecationWarning: pywikibot.version.svn_rev_info is deprecated; use getversion_svn_setuptools instead.
  tag, rev, date = svn_rev_info(_program_dir)

Pywikibot SVN repository
Python 2.7.13 (v2.7.13:a06454b1afa1, Dec 17 2016, 20:42:59) [MSC v.1500 32 bit (Intel)]
Pywikibot: pywikibot/__init__.py (, -1 (unknown), 2017/05/02, 11:53:35, n/a)
Release version: 3.0-dev
requests version: 2.7.0
  cacerts: C:\Python27\lib\site-packages\requests\cacert.pem
    certificate test: ok
Python: 2.7.13 (v2.7.13:a06454b1afa1, Dec 17 2016, 20:42:59) [MSC v.1500 32 bit
(Intel)]
PYWIKIBOT2_DIR: Not set
PYWIKIBOT2_DIR_PWB:
PYWIKIBOT2_NO_USER_CONFIG: Not set
Config base dir: C:\pwb\SVN\core
Usernames for family "wikipedia":
        gv: Xqbot (no sysop configured)
Usernames for family "commons":
        commons: Xqbot (no sysop configured)
Usernames for family "wikidata":
        repo: Xqt (no sysop configured)
Closing network session.
Network session closed.

C:\pwb\SVN\core>

setuptools does not contain svn_utils for me:

>>> import setuptools
>>> from setuptools import svn_utils

Traceback (most recent call last):
  File "<pyshell#2>", line 1, in <module>
    from setuptools import svn_utils
ImportError: cannot import name svn_utils
>>> importsetuptools_svn

Traceback (most recent call last):
  File "<pyshell#3>", line 1, in <module>
    importsetuptools_svn
NameError: name 'importsetuptools_svn' is not defined
>>> import setuptools_svn

with setuptools-28.8.0.dist-info (both py2.7 and py3.6) on windows

That noisy deprecation also occurres if pwb wrapper script is executed from side package which is neither a git nor a svn repository:

C:\pwb\GIT\core>pwb.exe touch
### Running from package
WARNING: c:\python38\lib\site-packages\pywikibot\version.py:119: DeprecationWarning: pywikibot.version.getversion_svn is deprecated for 5 years and 1 month; use getversion_svn_setuptools instead.
  (tag, rev, date, hsh) = vcs_func(_program_dir)

WARNING: c:\python38\lib\site-packages\pywikibot\version.py:270: DeprecationWarning: pywikibot.version.svn_rev_info is deprecated for 5 years and 1 month; use getversion_svn_setuptools instead.
  tag, rev, date = svn_rev_info(_program_dir)

ERROR: Unable to execute script because no generator was defined.
Use -help for further information.

Change 282524 merged by jenkins-bot:
[pywikibot/core@master] [bugfix] fix getversion_svn for Python 3.6+

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