kliment / Printrun

Pronterface, Pronsole, and Printcore - Pure Python 3d printing host software
GNU General Public License v3.0
2.38k stars 997 forks source link

Replace configparser readfp with read_file #1428

Closed ejona86 closed 5 months ago

ejona86 commented 5 months ago

readfp() was deprecated in Python 3.2 and removed in Python 3.12. read_file() is a drop-in replacement.

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'?
DivingDuck commented 5 months ago

Nice finding and yes, we should change this.

Btw , we actually do not support Python 3.12, ~but~ but it is good to know if one have already start to test it with Pronterface.

@rockstorm101, I did a successful quick test locally for Windows with py3.10

rockstorm101 commented 5 months ago

Very good report with helpful and on-point links. Many thanks.