python 3.12 - object has no attribute 'readfp, causes network to fail

- - ALL UNSTABLE / TESTING THREADS SHOULD BE POSTED HERE - -
This sub-forum is the dedicated area for the ongoing Unstable/Testing releases of Debian. Advanced, or Experienced User support only. Use the software, give, and take advice with caution.
Post Reply
Message
Author
User avatar
lbm
Posts: 497
Joined: 2009-05-16 09:24
Location: Denmark

python 3.12 - object has no attribute 'readfp, causes network to fail

#1 Post by lbm »

running trixie, with python 3.12, I get below error when the network interfaces (ALL of them) should be brought up.
Sep 8 15:11:40 server1 systemd[1]: Stopping networking.service - Network initialization...
Sep 8 15:11:40 server1 networking[3464]: networking: Deconfiguring network interfaces
Sep 8 15:11:40 server1 networking[3469]: error: main exception: 'RawConfigParser' object has no attribute 'readfp'
Sep 8 15:11:40 server1 systemd[1]: networking.service: Deactivated successfully.
Sep 8 15:11:40 server1 systemd[1]: Stopped networking.service - Network initialization.
Sep 8 15:11:40 server1 systemd[1]: Starting networking.service - Network initialization...
Sep 8 15:11:40 server1 networking[3471]: networking: Configuring network interfaces
Sep 8 15:11:41 server1 networking[3477]: error: main exception: 'RawConfigParser' object has no attribute 'readfp'
Sep 8 15:11:41 server1 systemd[1]: Finished networking.service - Network initialization.
I've located the issue to be an issue with Python 3.12, apperently because in 3.12 the function/method was renamed or completely removed.

To workaround the issue, i've downgraded some python packages, and libs to 3.11 manually.
Below packages seem to be enough (at least for me).
dpkg -l |grep python |grep 3.11
ii libpython3-stdlib:amd64 3.11.2-1+b1 amd64 interactive high-level object-oriented language (default python3 version)
ii libpython3.11:amd64 3.11.2-6+deb12u3 amd64 Shared Python runtime library (version 3.11)
ii libpython3.11-minimal:amd64 3.11.2-6+deb12u3 amd64 Minimal subset of the Python language (version 3.11)
ii libpython3.11-stdlib:amd64 3.11.2-6+deb12u3 amd64 Interactive high-level object-oriented language (standard library, version 3.11)
ii python3-minimal 3.11.2-1+b1 amd64 minimal subset of the Python language (default python3 version)
iU python3-tk:amd64 3.11.2-3 amd64 Tkinter - Writing Tk applications with Python 3.x
ii python3.11 3.11.2-6+deb12u3 amd64 Interactive high-level object-oriented language (version 3.11)
ii python3.11-minimal 3.11.2-6+deb12u3 amd64 Minimal subset of the Python language (version 3.11
But are there an better solution, because this is bad, that I have to manually downgrade these packages. :)

User avatar
fabien
Forum Helper
Forum Helper
Posts: 1158
Joined: 2019-12-03 12:51
Location: Anarres (Toulouse, France actually)
Has thanked: 101 times
Been thanked: 265 times

Re: python 3.12 - object has no attribute 'readfp, causes network to fail

#2 Post by fabien »

lbm wrote: 2024-09-09 07:00 I've located the issue to be an issue with Python 3.12, apperently because in 3.12 the function/method was renamed or completely removed.
There is currently an unrelated bug open against python3.12 that affects fail2ban. Python maintainers do not seem to want to support the maintenance of affected packages:
> Python 3.12 removes asynchat module, deprecated since Python 3.6. This
> breaks the bookworm version of fail2ban, and should be declared in the
> dependencies as Breaks:

I don't think, that having breaks for every package relying on a removed
module in the standard libraray, is really feasible. Normally we only
identify some of those packages during development, and we fix them. But
not adding a breaks for every single package.
How did you find the dependency on python3.12? What package is affected? You could open a bug on this package with the idea that it should be compliant with the latest Python.

Note: moved to the "Testing And Unstable" subforum.
ImageShare your Debian SCRIPTS
There will be neither barrier nor walls, neither official nor guard, there will be no more desert and the entire world will become a garden. — Anacharsis Cloots

Aki
Global Moderator
Global Moderator
Posts: 4038
Joined: 2014-07-20 18:12
Location: Europe
Has thanked: 112 times
Been thanked: 533 times

Re: python 3.12 - object has no attribute 'readfp, causes network to fail

#3 Post by Aki »

Hello,

It appears that you are using the ifupdown2 package [1].

This package has been removed from Debian testing (Trixe) since 2024-08-06 due to the bug you reported (see Debian Bug Tracking System): According to the report above, a one-liner patch is available here ("replaced readfp function for new version of configparser"): While waiting for the package upgrade, you can consider an in-place update for the file named /usr/share/ifupdown2/ifupdown/main.py.

Otherwise, you can install the ifupdown package to replace ifupdown2.

Hope this helps.

--
[1] ifupdown2 - Network Interface Management tool similar to ifupdown
⢀⣴⠾⠻⢶⣦⠀
⣾⠁⢠⠒⠀⣿⡁ Debian - The universal operating system
⢿⡄⠘⠷⠚⠋⠀ https://www.debian.org
⠈⠳⣄⠀

User avatar
lbm
Posts: 497
Joined: 2009-05-16 09:24
Location: Denmark

Re: python 3.12 - object has no attribute 'readfp, causes network to fail

#4 Post by lbm »

Hi Aki

Sorry, with the lack or reply, I havent seen your message.
But yes, it for sure looks like the package is the version, and I can also see the same in the main.py file.
I will give it a go later this week maybe, and report back.
pt policy ifupdown2
ifupdown2:
Installed: 3.0.0-1.2
Candidate: 3.0.0-1.2
Version table:
*** 3.0.0-1.2 100
100 /var/lib/dpkg/status

User avatar
lbm
Posts: 497
Joined: 2009-05-16 09:24
Location: Denmark

Re: python 3.12 - object has no attribute 'readfp, causes network to fail

#5 Post by lbm »

Sorry. This took a while, but it works fine again, after the file was modified manually :)

Here the main.py file has the required change.

Code: Select all

diff main.py main.py.bak
diff /usr/share/ifupdown2/ifupdown/main.py /usr/share/ifupdown2/ifupdown/main.py.bak
142,143c142
<         #parser.readfp(configFP)
<         parser.read_file(configFP)
---
>         parser.readfp(configFP)

Post Reply