Univention Bugzilla – Bug 51368
Fix python3 API - transition from ipaddr to ipaddress
Last modified: 2020-09-15 15:30:31 CEST
"ipaddr" is the legacy Python 2 module; Python 3 has the native "ipaddress" module in stdlib <https://docs.python.org/3/library/ipaddress.html>. They are incompatible in details. UCS-4 based on Debian-9-Stretch - it contains a backport of "python-ipaddress" <https://packages.debian.org/source/stretch/python-ipaddress> - it has "python-ipaddr" <https://packages.debian.org/source/stretch/python-ipaddr> - it has "python3-ipaddr" from Debian-7-Wheezy (!) UCS-5 based on Debian-10-Buster: - it still has the backport of "python-ipaddress" <https://packages.debian.org/source/buster/python-ipaddress> - it has no "python3-ipaddr" - it has "python-ipaddr" <https://packages.debian.org/source/buster/python-ipaddr> (Interestingly enough Debian-11-Bullseye drops Python-2 completely, thus no longer has any "python-ipaddr[ess]", but re-introduces "python3-ipaddr" <https://packages.debian.org/source/bullseye/python-ipaddr>) univention.config_registry.interfaces returns instances of ipaddr, so it is part of the API. - for Python 2 we must continue using the legacy ipaddr - for Python 3 we should switch to the stdlib ipaddress There are also more issues in the Python 3 API.
[4.4-4] 31b3d28478 Bug #51368 UCR: Fix Python 3 API base/univention-config-registry/debian/changelog | 6 +++++ base/univention-config-registry/debian/control | 1 - .../python/univention/config_registry/frontend.py | 4 ++-- .../univention/config_registry/interfaces.py | 27 ++++++++++++---------- 4 files changed, 23 insertions(+), 15 deletions(-) [4.4-4] a824921d6f Bug #51368 UCR: Fix mixed str | None .../python/univention/config_registry/interfaces.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) [4.4-4] cb9706ced9 Bug #51368 UCR: Fix ucr.clear() .../python/univention/config_registry/backend.py | 8 ++++++++ 1 file changed, 8 insertions(+) [4.4-4] 09509cefd5 Bug #51368 UCR: Fix unicode repr difference .../python/univention/config_registry/misc.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) [4.4-4] 2cbc4ac4a0 Bug #51368 UCR: Fix basestring base/univention-config-registry/python/univention/service_info.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) [4.4-4] e41c354ea8 Bug #51368 UCR: Convert unittest to pytest base/univention-config-registry/debian/control | 3 +- base/univention-config-registry/debian/rules | 10 +- .../debian/ucslint.overrides | 6 + .../python/univention/config_registry/backend.py | 4 +- .../univention/config_registry/interfaces.py | 385 ------------------- .../tests/test_backend.py | 421 +++++++++------------ .../tests/test_backend_threading.py | 30 +- base/univention-config-registry/tests/test_cli.py | 78 ++++ base/univention-config-registry/tests/test_cli.sh | 61 --- .../tests/test_info_tools.py | 232 ++++++------ ... 11 files changed, 793 insertions(+), 839 deletions(-) Package: univention-config-registry Version: 14.0.0-16A~4.4.0.202005281800 Branch: ucs_4.4-0 Scope: errata4.4-4 [4.4-4] ad3b88d7b7 Bug #51368: univention-config-registry 14.0.0-16A~4.4.0.202005281800 doc/errata/staging/univention-config-registry.yaml | 12 ++++++++++++ 1 file changed, 12 insertions(+)
With the new API we need to differentiate the python version in: base/univention-base-files/conffiles/etc/network/interfaces.d/10-default: AttributeError: 'IPv4Interface' object has no attribute 'prefixlen' services/univention-squid/conffiles/etc/squid/squid.conf: AttributeError: 'IPv4Interface' object has no attribute 'prefixlen' → addr.network.prefixlen services/univention-printserver/conffiles/etc/cups/cupsd.conf.d/01cupsd-base: AttributeError: 'IPv4Interface' object has no attribute 'masked' services/univention-samba4/96univention-samba4.inst: AttributeError: 'IPv4Interface' object has no attribute 'masked'
The fix so far is great. I am wondering if we can integrate the patch git:506da07bb93043ea17c47b0b2dbe421cceaff6ae now, too? Or should we instead obosolete ipaddr in UCS 5? I would like to have a reliable interface for Py2+3 somewhere. One warning, which could also be addressed: /usr/lib/python3/dist-packages/univention/config_registry/backend.py:39 /usr/lib/python3/dist-packages/univention/config_registry/backend.py:39: DeprecationWarning: Using or importing the ABCs from 'collections' instead of from 'collections.abc' is deprecated, and in 3.8 it will stop working from collections import MutableMapping
OK: after the daily we[Sönke,Arvid,me] decided to change the UCR Interfaces API for Python2 and Python 3 in UCS 5.0 and leave this as is.
<http://errata.software-univention.de/ucs/4.4/638.html>
Created attachment 10492 [details] backup