Unit tests fail due to unsupported .removeprefix() in python 3.7

Bug #2031635 reported by Roman Krček
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
OpenStack Compute (nova)
Confirmed
Undecided
Unassigned
Yoga
New
Undecided
Unassigned
Zed
In Progress
Undecided
Unassigned

Bug Description

Description
===========
When running unit tests on python3.7 two tests fail:
nova.tests.unit.console.test_websocketproxy.NovaProxyRequestHandlerBaseTestCase.test_reject_open_redirect
nova.tests.unit.console.test_websocketproxy.NovaProxyRequestHandlerBaseTestCase.test_reject_open_redirect_3_slashes

Steps to reproduce
==================
Checkout to latest stable/train as of 17.08.2023
$ tox -e py37

Expected result
=============
All unit tests pass

Actual result
=============
`Captured traceback:
~~~~~~~~~~~~~~~~~~~
    b'Traceback (most recent call last):'
    b' File "/builds/nfv-platform/nova/nova/tests/unit/console/test_websocketproxy.py", line 678, in test_reject_open_redirect'
    b" location = location.removeprefix('Location: ').rstrip('\\r\\n')"
    b"AttributeError: 'str' object has no attribute 'removeprefix'"
    b''`

`Captured traceback:
~~~~~~~~~~~~~~~~~~~
    b'Traceback (most recent call last):'
    b' File "/builds/nfv-platform/nova/nova/tests/unit/console/test_websocketproxy.py", line 685, in test_reject_open_redirect_3_slashes'
    b" self.test_reject_open_redirect(url='///example.com/%2F..')"
    b' File "/builds/nfv-platform/nova/nova/tests/unit/console/test_websocketproxy.py", line 678, in test_reject_open_redirect'
    b" location = location.removeprefix('Location: ').rstrip('\\r\\n')"
    b"AttributeError: 'str' object has no attribute 'removeprefix'"
    b''`

Environment
===========
Python version 3.7.17

Revision history for this message
Roman Krček (r-krcek) wrote :

This issue was introduced with the following commit https://review.opendev.org/c/openstack/nova/+/866201

Revision history for this message
Takashi Kajinami (kajinamit) wrote (last edit ):

I believe this bug is invalid because Python 3.7 is no longer supported. You should use Python 3.8 or later.

https://github.com/openstack/nova/blob/master/setup.cfg#L13

See https://governance.openstack.org/tc/reference/runtimes/ to find out the python versions supported by each release.

Revision history for this message
Roman Krček (r-krcek) wrote :

Sorry if I didn't specify it correctly, but I was referencing Train release in this bug report which should use python 3.6 or 3.7 as the default version. However, even updating to Python 3.8 would not help, since .removeprefix() wasn't implemented until Python 3.9. So most releases using Python 3.8 and Python 3.7 are affected.

This bug results from a change, which was introduced as a result of the following bug report https://bugs.launchpad.net/nova/+bug/1986545

After a lot of searching, I was, in the end, able to find a commit to master that fixed this issue https://opendev.org/openstack/nova/commit/3ccf82ef9e2c87a1d33a0dda8929c05e80844087

Revision history for this message
Sylvain Bauza (sylvain-bauza) wrote :

As said, triaging as Valid as https://review.opendev.org/c/openstack/nova/+/867788 requires backports.

Changed in nova:
status: New → Confirmed
Revision history for this message
melanie witt (melwitt) wrote :
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.