CumulusNetworks / ifupdown2

GNU General Public License v2.0
161 stars 75 forks source link

ifupdown2 - python 3.12 compability #296

Closed d4nys3k closed 3 months ago

d4nys3k commented 7 months ago

I noticed ifupdown2 stopped working after upgrading to Python3.12. It fails to bring up all interfaces with: error: main exception: 'RawConfigParser' object has no attribute 'readfp'

According to the documentation, readfp can be replaced by read_file since Python 3.2. Python 3.12 removes this object. After local modification of ifupdown/main.py (see diff below) I managed ifupdown2 to resume operation as expected in my envinronment.

--- ifupdown/main.py.orig   2020-08-28 16:01:19.000000000 +0200
+++ ifupdown/main.py    2024-04-04 19:15:45.575869366 +0200
@@ -139,7 +139,7 @@
         configStr = '[ifupdown2]\n' + config
         configFP = io.StringIO(configStr)
         parser = configparser.RawConfigParser()
-        parser.readfp(configFP)
+        parser.read_file(configFP)
         configmap_g = dict(parser.items('ifupdown2'))
julienfortin commented 7 months ago

@d4nys3k can you submit the patch as a PR? So you get credit for finding the issue and i click merge it :)

KoffieNu commented 3 months ago

Patch provided as PR by me, as original reported failed to do so since 4-4-2024 and my systems break due to this issue.