Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
mayakrunal opened this issue May 25, 2023 · 4 comments · May be fixed by #59
Open

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

mayakrunal opened this issue May 25, 2023 · 4 comments · May be fixed by #59

Comments

@mayakrunal
Copy link

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
Copy link
Author

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
Copy link

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
Copy link
Author

created pull request for the same

#59

@mayakrunal mayakrunal linked a pull request May 25, 2023 that will close this issue
@dreirund
Copy link

created pull request for the same

#59

I can confirm that this fixes this issue for me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants