Skip to content

Commit

Permalink
Replace configparser readfp with read_file (#1428)
Browse files Browse the repository at this point in the history
readfp() was [deprecated in Python 3.2][1] and [removed in Python
3.12][2]. read_file() is a drop-in replacement.

[1]: https://github.com/python/cpython/blob/dd0e8a62df8be2a09ef6035b4c92bd9a68a7b918/Lib/configparser.py#L757-L764
[2]: python/cpython@1fc41ae

Fixes this error with Python 3.12:
```
Traceback (most recent call last):
  File "/usr/bin/pronterface.py", line 62, in <module>
    app = PronterApp(False)
          ^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/site-packages/printrun/pronterface.py", line 2596, in __init__
    self.mainwindow = PronterWindow(self)
                      ^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/site-packages/printrun/pronterface.py", line 220, in __init__
    self.reload_ui()
  File "/usr/lib/python3.12/site-packages/printrun/pronterface.py", line 288, in reload_ui
    self.create_menu()
  File "/usr/lib/python3.12/site-packages/printrun/pronterface.py", line 862, in create_menu
    self.load_slic3r_configs(menus)
  File "/usr/lib/python3.12/site-packages/printrun/pronterface.py", line 2517, in load_slic3r_configs
    config = self.read_slic3r_config(configfile)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/site-packages/printrun/pronterface.py", line 2562, in read_slic3r_config
    parser.readfp(add_header(open(configfile)), configfile)
    ^^^^^^^^^^^^^
AttributeError: 'RawConfigParser' object has no attribute 'readfp'. Did you mean: 'read'?
```
  • Loading branch information
ejona86 authored Jun 19, 2024
1 parent 17729de commit 7b199ed
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion printrun/pronterface.py
Original file line number Diff line number Diff line change
Expand Up @@ -2559,7 +2559,7 @@ def __iter__(self):
import itertools
return itertools.chain([self.header], iter(self.f))

parser.readfp(add_header(open(configfile)), configfile)
parser.read_file(add_header(open(configfile)), configfile)
return parser

def set_slic3r_config(self, configfile, cat, file):
Expand Down

0 comments on commit 7b199ed

Please sign in to comment.