ufw ftbfs with Python 3.12 as default

Bug #2051540 reported by Matthias Klose
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
ufw
Fix Committed
Undecided
Jamie Strandboge
ufw (Debian)
Fix Released
Unknown
ufw (Ubuntu)
Fix Released
High
Jamie Strandboge

Bug Description

======================================================================
ERROR: test_ufwcommand_parse (tests.unit.test_parser.ParserTestCase.test_ufwcommand_parse)
Test UFWCommand.parse()
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/<<PKGBUILDDIR>>/tests/unit/test_parser.py", line 88, in test_ufwcommand_parse
    self.assertEquals('status', pr.action, "%s != 'status'" % (pr.action))
    ^^^^^^^^^^^^^^^^^
AttributeError: 'ParserTestCase' object has no attribute 'assertEquals'. Did you mean: 'assertEqual'?

======================================================================
ERROR: test_ufwcommand_rule_get_command (tests.unit.test_parser.ParserTestCase.test_ufwcommand_rule_get_command)
Test UFWCommand(Route)Rule.get_command()
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/<<PKGBUILDDIR>>/tests/unit/test_parser.py", line 375, in test_ufwcommand_rule_get_command
    self.assertEquals(len(errors), 0,
    ^^^^^^^^^^^^^^^^^
AttributeError: 'ParserTestCase' object has no attribute 'assertEquals'. Did you mean: 'assertEqual'?

----------------------------------------------------------------------
Ran 24 tests in 7.584s

FAILED (errors=9)
test_skeleton
test_example (tests.unit.test_skeleton.SkeletonTestCase.test_example)
Test example dummy test ... ok

----------------------------------------------------------------------
Ran 1 test in 0.000s

OK

Related branches

Matthias Klose (doko)
Changed in ufw (Ubuntu):
status: New → Confirmed
importance: Undecided → High
tags: added: ftbfs rls-nn-incoming
Changed in ufw:
status: New → Fix Committed
assignee: nobody → Jamie Strandboge (jdstrand)
Changed in ufw (Ubuntu):
status: Confirmed → In Progress
assignee: nobody → Jamie Strandboge (jdstrand)
Changed in ufw (Debian):
status: Unknown → Fix Released
Revision history for this message
Jamie Strandboge (jdstrand) wrote :

Another fix is needed for python 3.12:

Performing tests 'good/reports'
- installing
- result:
    FAIL:
4a5,8
> /<<PKGBUILDDIR>>/tests/testarea/lib/python/ufw/util.py:483: SyntaxWarning: invalid escape sequence '\.'
> quads = re.split('\.', nm)
> /<<PKGBUILDDIR>>/tests/testarea/lib/python/ufw/util.py:745: SyntaxWarning: invalid escape sequence '\s'
> tmp = re.split('\s', out)

Revision history for this message
Jamie Strandboge (jdstrand) wrote :

I'll upload a fix for that tomorrow.

Matthias Klose (doko)
Changed in ufw (Ubuntu):
status: In Progress → Confirmed
Changed in ufw (Debian):
status: Fix Released → New
Revision history for this message
Jamie Strandboge (jdstrand) wrote :
Changed in ufw (Ubuntu):
status: Confirmed → Fix Released
Changed in ufw (Debian):
status: New → Fix Released
Revision history for this message
Matthias Klose (doko) wrote :

better, but still not complete:

1186s autopkgtest [04:54:38]: test root-unittest: [-----------------------
1186s Interpreter: python3
1186s
1186s rm -rf ./build
1186s rm -rf ./staging
1186s rm -rf ./tests/testarea ./tests/unit/tmp
1186s rm -rf ./tmp
1186s rm -rf ./snap-build
1186s rm -rf ./parts ./stage ./prime
1186s rm -f ./locales/mo/*.mo
1186s rm -f ./tests/unit/*.pyc ./tests/*.pyc ./src/*.pyc
1186s rm -rf ./tests/unit/__pycache__ ./tests/__pycache__ ./src/__pycache__
1186s rm -rf ./.coverage
1186s rm -f ./ufw # unittest symlink
1186s = Functional Tests =
1186s net.ipv4.ip_forward = 0
1186s net.ipv6.conf.default.forwarding = 0
1186s net.ipv6.conf.all.forwarding = 0
1186s
1186s Performing tests 'root/bugs'
1186s - installing
1187s Traceback (most recent call last):
1187s File "/tmp/autopkgtest.qdhyuB/build.T34/src/./setup.py", line 28, in <module>
1187s from distutils.command.install import install as _install
1187s ModuleNotFoundError: No module named 'distutils'

Changed in ufw (Ubuntu):
status: Fix Released → Confirmed
Revision history for this message
Alex Murray (alexmurray) wrote :

Both deb8 tests already declares a Depends on python3-distutils - and we can see that the current test runs all used the 3.11 based python3-distutils - do we need a no-change-rebuild of python3-stdlib-extensions so that it builds against python 3.12?

Revision history for this message
Jamie Strandboge (jdstrand) wrote :

fyi, I plan to fix this but probably not til next week. My plan is to adjst the import to conditionally (or fall back to) import setuptools.distutil and then adjust the Build-Depends/autopkgtests to specify python3-setuptools.

I may do something else longer term, but that should get things going again.

Revision history for this message
Jamie Strandboge (jdstrand) wrote (last edit ):

Mathias,

So, this is a little hard to fix with the archive packages now and I'm not sure where people are going with the 3.12 updates. I can get python3.12 reasonably easily enough but debian/tests/control has:

# root unittests under python3
Tests: root-unittest
Depends: iptables,
         netbase,
         procps,
         sed,
         python3,
         python3-distutils
Restrictions: needs-root, allow-stderr, isolation-machine, build-needed, rw-build-tree

# unittests under python3
Tests: unittest
Depends: iptables,
         netbase,
         procps,
         sed,
         python3,
         python3-distutils,
         dh-python,

Both of these are installing python3-distutils, but only one is installing dh-python. dh-python depends on both python3-distutils and python3-setuptools. Presumably dh-python is going to stop installing python3-distutils? However, python3-setuptools *also* depends on python3-distutils (which the setuptools package provides).

As it stands, ufw 0.36.2-3 builds fine with what is in noble now and should in what is in noble-proposed now (indeed, it passed its autopkgtests and migrated recently).

Where was this test result coming from? What is the goal of that build? Since the autopkgtests are declaring that python3-distutils be installed, we shouldn't be getting the the error since it should be there.

I can create an artificial situation and do 'sudo dpkg --force-depends --purge python3-distutils' (but is this even valid?) but even in that situation, python3-setuptools in the archive being installed still allows the import to work. Only if I do 'sudo dpkg --force-depends --purge python3-distutils python3-setuptools' can I reproduce the import error, but the fix is to use python3-setuptools....

Revision history for this message
Jamie Strandboge (jdstrand) wrote :

From my reading (https://github.com/pypa/setuptools/issues/3661), installing python3-setuptools instead of python3-distutils should be sufficient, with a new enough setuptools, which we have in noble.

Revision history for this message
Jamie Strandboge (jdstrand) wrote :

> From my reading (https://github.com/pypa/setuptools/issues/3661), installing python3-setuptools instead of python3-distutils should be sufficient, with a new enough setuptools, which we have in noble.

Uploaded 0.36.2-4 to unstable, it migrated to noble-proposed and awaiting autopkgtests.

Revision history for this message
Jamie Strandboge (jdstrand) wrote :

Ok, https://autopkgtest.ubuntu.com/results/autopkgtest-noble/noble/amd64/u/ufw/20240211_163608_4a05d@/log.gz (the one for python3-defaults/3.12.1-0ubuntu1) passed with 0.36.2-4 so hopefully this bug will stay closed! :)

Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package ufw - 0.36.2-4

---------------
ufw (0.36.2-4) unstable; urgency=medium

  * debian/test/control: install python3-setuptools instead of
    python3-distutils (LP: #2051540)

 -- Jamie Strandboge <email address hidden> Sat, 10 Feb 2024 23:34:53 +0000

Changed in ufw (Ubuntu):
status: Confirmed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.