Univention Bugzilla – Bug 51156
fix python 3 compatibility of UCR interfaces
Last modified: 2020-04-29 12:32:16 CEST
We introduced in git:85c443999f96ddab1b36548bbe6f428afcf1ac2e a different use of ipaddress vs ipaddr module for the public API of univention.config_registry.interfaces: > if six.PY3: > from ipaddress import IPv4Address, IPv4Network, IPv6Address, IPv6Network > else: > from ipaddr import IPv4Address, IPv4Network, IPv6Address, IPv6Network For Code using this (like univention-printserver, univention-squid, etc.) this is an non compatible API change, e.g. when using: > list(univention.config_registry.interfaces.Interfaces(configRegistry).ipv4_interfaces)[0][1].ipv4_address().masked() resulting in: > AttributeError: 'IPv4Network' object has no attribute 'masked' For now, we should use `ipaddr` and change this maybe in UCS 5.0. Another detail, which is not yet python3 compatible is the encoding of stdin in univention.config_registry.handler.run_script(). $ python3 /usr/sbin/ucr --debug commit /etc/cups/cupsd.conf Multifile: /etc/cups/cupsd.conf Traceback (most recent call last): File "<stdin>", line 16, in <module> AttributeError: 'bool' object has no attribute 'masked' Traceback (most recent call last): File "<stdin>", line 16, in <module> AttributeError: 'bool' object has no attribute 'masked' Traceback (most recent call last): File "/usr/sbin/ucr", line 69, in <module> ub.main(convertToUtf8(sys.argv[1:])) File "/usr/lib/python3/dist-packages/univention/config_registry/frontend.py", line 777, in main result = handler_func(args, cmd_opts) File "/usr/lib/python3/dist-packages/univention/config_registry/frontend.py", line 287, in handler_commit handlers.commit(ucr, args) File "/usr/lib/python3/dist-packages/univention/config_registry/handler.py", line 1128, in commit self.call_handler(ucr, handler) File "/usr/lib/python3/dist-packages/univention/config_registry/handler.py", line 1147, in call_handler handler((ucr, values)) File "/usr/lib/python3/dist-packages/univention/config_registry/handler.py", line 451, in __call__ run_script(script_file, 'postinst', changed) File "/usr/lib/python3/dist-packages/univention/config_registry/handler.py", line 167, in run_script proc.communicate(''.join(diff)) File "/usr/lib/python3.5/subprocess.py", line 786, in communicate self._stdin_write(input) File "/usr/lib/python3.5/subprocess.py", line 741, in _stdin_write self.stdin.write(input) TypeError: a bytes-like object is required, not 'str +++ This bug was initially created as a clone of Bug #49129 +++
Both points addressed in: univention-config-registry.yaml 5ea3b72bfb3c | YAML Bug #51156 univention-config-registry (14.0.0-15) d5ad607e65f5 | Bug #51156: fix python3 compatibility in interfaces.py 4d2a5f2fb6af | Bug #51156: ucr: Fix python3 compatibility in handler.run_script()
/etc/cups/cupsd.conf compiles again. Code: OK YAML: OK
<http://errata.software-univention.de/ucs/4.4/557.html>