gogrepo icon indicating copy to clipboard operation
gogrepo copied to clipboard

Fix ValueError: invalid mode: 'rUb'

Open mikomuto opened this issue 2 years ago • 5 comments

File mode U is deprecated in Python 3 https://docs.python.org/3/library/functions.html#open

mikomuto avatar Jan 02 '23 21:01 mikomuto

Full error generated with Python 3.11:

E:\GOG Games>gogrepo.py update 13:06:14 | loading local manifest... 13:06:14 | fatal... Traceback (most recent call last): File "E:\GOG Games\gogrepo.py", line 1170, in main(process_argv(sys.argv)) File "E:\GOG Games\gogrepo.py", line 1145, in main cmd_update(args.os, args.lang, args.skipknown, args.updateonly, args.id) File "E:\GOG Games\gogrepo.py", line 607, in cmd_update gamesdb = load_manifest() ^^^^^^^^^^^^^^^ File "E:\GOG Games\gogrepo.py", line 257, in load_manifest with codecs.open(MANIFEST_FILENAME, 'rU', 'utf-8') as r: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "", line 906, in open ValueError: invalid mode: 'rUb'

mikomuto avatar Jan 02 '23 21:01 mikomuto

Thanks. Will fix this.

eddie3 avatar Jan 05 '23 02:01 eddie3

Just as a quick fix for anyone having this problem, at least on linux systems, find the line and replace 'rU' with 'r' (simply remove the U), and it should work again. On other OSses, the keyword newline might be necessary (something like codecs.open(MANIFEST_FILENAME, 'r', 'utf-8', newline="\r\n") as r: may be needed in windows, untested!)

WisdomCode avatar Jul 21 '23 10:07 WisdomCode

Just tried the fix from @WisdomCode on my Windows10 system and found that removing the U was enough; adding a newline argument returned TypeError: open() got an unexpected keyword argument 'newline'. Hope this helps!

kristroy avatar Aug 07 '23 01:08 kristroy

Worked for me as well on Windows, thanks!

pchristod avatar Sep 22 '23 17:09 pchristod