eddie3 / gogrepo

Python-based tool for downloading all your GOG.com game and bonus collections to your local computer for full offline enjoyment.
492 stars 119 forks source link

Fix ValueError: invalid mode: 'rUb' #69

Open mikomuto opened 1 year ago

mikomuto commented 1 year ago

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

mikomuto commented 1 year ago

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'

eddie3 commented 1 year ago

Thanks. Will fix this.

WisdomCode commented 1 year ago

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!)

kristroy commented 1 year ago

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!

pchristod commented 1 year ago

Worked for me as well on Windows, thanks!