ricardomv / snapper-gui

GUI for snapper, a tool for Linux filesystem snapshot management, works with btrfs, ext4 and thin-provisioned LVM volumes
GNU General Public License v2.0
222 stars 32 forks source link

Python 3.11 open(path,"U") -->invalid mode. #58

Open mayakrunal opened 1 year ago

mayakrunal commented 1 year ago

Not being able to see the diff in the changes section on python 3.11 due to "U" mode being deprecated on python 3.11

File "/usr/lib/python3.11/site-packages/snappergui/changesWindow.py", line 165, in get_lines_from_file return open(path, 'U').readlines() ^^^^^^^^^^^^^^^ ValueError: invalid mode: 'U'

From python docs: https://docs.python.org/3/whatsnew/3.11.html#porting-to-python-3-11

open(), io.open(), codecs.open() and fileinput.FileInput no longer accept 'U' (“universal newline”) in the file mode. In Python 3, “universal newline” mode is used by default whenever a file is opened in text mode, and the 'U' flag has been deprecated since Python 3.3. The newline parameter to these functions controls how universal newlines work. (Contributed by Victor Stinner in bpo-37330.)

mayakrunal commented 1 year ago

Looking at the doc. https://docs.python.org/3/library/functions.html#open The default open mode is already text mode or we can use as below?

The type of file object returned by the open() function depends on the mode. When open() is used to open a file in a text mode ('w', 'r', 'wt', 'rt', etc.), it returns a subclass of io.TextIOBase (specifically io.TextIOWrapper).

rickysarraf commented 1 year ago

Looking at the doc. https://docs.python.org/3/library/functions.html#open The default open mode is already text mode or we can use as below?

The type of file object returned by the open() function depends on the mode. When open() is used to open a file in a text mode ('w', 'r', 'wt', 'rt', etc.), it returns a subclass of io.TextIOBase (specifically io.TextIOWrapper).

Just dropping the mode should be enough. Thanks for reporting of this regression.

image

mayakrunal commented 1 year ago

created pull request for the same

https://github.com/ricardomv/snapper-gui/pull/59

dreirund commented 1 year ago

created pull request for the same

#59

I can confirm that this fixes this issue for me.