Closed marewey closed 7 months ago
I think this is Minecraft itself crashing but the returned log could have some weird encoding making python think its cp1252
:
Exception in thread Minecraft Stream Thread:
Could you go into your .minecraft/logs
folder and see if the latest.log
file correlates (by checking date etc) with the crash? If so, its contents should tell you more about the crash.
I wonder why this error happens on the "print" call tbh, is it possible to change the encoding of stdout? I've never seen this problem...
I believe this might be due to a mismatch in the data returned on stdout and the inferred system encoding of Popen
(i.e. import locale; locale.getpreferredencoding()
). Though I am not sure.
Interesting, on Windows I get "cp1252", on Linux I get "UTF-8". This might be our issue, also it looks like that it's possible to do sys.stdout.reconfigure(encoding="utf-8")
since Python 3.7, but I wonder if Windows shell will be happy about that. In fact, I had an issue with a Rust tool I was working on where Windows refused to print invalid UTF-8 codes, so maybe we'll need a way to ignore, or format as hex maybe, any game's log that is not valid UTF-8.
Source: https://docs.python.org/3/library/io.html#io.TextIOWrapper.reconfigure
Interesting, I haven't changed anything on my end at all, and it worked yesterday, so i figured it must have been something to do with a cached file having strange characters (as in it downloads this file at every launch, for instance a version index or something like that). I did check my minecraft log, it did launch it for a second, this is all it had:
[20:27:17] [main/INFO]: ModLauncher running: args [--username, Redacted, --version, forge-1.19.2-43.3.5, --gameDir, C:\redacted, --assetsDir, C:\redacted\assets, --assetIndex, 1.19, --uuid, redacted, --accessToken, redacted, --clientId, , --xuid, , --userType, , --versionType, release, --launchTarget, forgeclient, --fml.forgeVersion, 43.3.5, --fml.mcVersion, 1.19.2, --fml.forgeGroup, net.minecraftforge, --fml.mcpVersion, 20220805.130853] [20:27:17] [main/INFO]: ModLauncher 10.0.8+10.0.8+main.0ef7e830 starting: java version 17.0.8 by Microsoft; OS Windows 10 arch amd64 version 10.0
I have even attempted to remove all mods, it does not change the error.
Also just to note: I am on PMC Version: 4.2.1 and Python Version: 3.8.10
Another thing to give you guys... This is what happens when i switch output to machine from human:
Exception in thread Minecraft Stream Thread:
Traceback (most recent call last):
File "c:\users\redacted\appdata\local\programs\python\python38\lib\threading.py", line 932, in _bootstrap_inner
self.run()
File "c:\users\redacted\appdata\local\programs\python\python38\lib\threading.py", line 870, in run
self._target(*self._args, **self._kwargs)
File "c:\users\redacted\appdata\local\programs\python\python38\lib\site-packages\portablemc\standard.py", line 1634, in process_stream_thread
if not parser.feed(line, self.process_stream_event):
File "c:\users\redacted\appdata\local\programs\python\python38\lib\site-packages\portablemc\standard.py", line 1677, in feed
callback(self.next_event)
File "c:\users\redacted\appdata\local\programs\python\python38\lib\site-packages\portablemc\cli__init__.py", line 887, in process_stream_event
out.print(f"[{time}] [{event.thread}] [{event.level}] {event.message}\n")
File "c:\users\redacted\appdata\local\programs\python\python38\lib\site-packages\portablemc\cli\output.py", line 279, in print
self.print_function("print", text)
File "c:\users\redacted\appdata\local\programs\python\python38\lib\site-packages\portablemc\cli\output.py", line 264, in print_function
print(name, ":", ",".join((self.print_escape(arg) for arg in [
File "c:\users\redacted\appdata\local\programs\python\python38\lib\encodings\cp1252.py", line 19, in encode
return codecs.charmap_encode(input,self.errors,encoding_table)[0]
UnicodeEncodeError: 'charmap' codec can't encode characters in position 305-312: character maps to
Hope this helps
Also in my previous experiences with PMC it never did log the console out before, however I do have PMC auto updating after every reboot.
I have figured out what breaks it... it is when you try and output to a file. Adding >>test.log causes the error, but works without outputting to log. The strange part is that it has been working, but only recently broke today.
When I do launch it from a console like normal, i did notice if you do not state an accesstoken it shows up as --accessToken, ❄❄❄❄❄❄❄❄ .... it looks like ?????? with boxes, but i guess it is snowflakes. lol.
Yes these snowflakes are shown by forge to avoid displaying the token in clear.
I have figured out what breaks it... it is when you try and output to a file. Adding >>test.log causes the error, but works without outputting to log. The strange part is that it has been working, but only recently broke today.
Thank you for this clear feedback! I can reproduce it!
Looks like sys.stdout.reconfigure
fixes the problem.
I have made no changes to anything, and was playing last night, however today when I launched, javaw.exe just hung after launching, checking logs I found this: I have tested with a new minecraft install, but this appears to be a python error.
[ .. ] Loading version forge-1.19.2-43.3.5... [ OK ] Loaded version forge-1.19.2-43.3.5
[ .. ] Loading version 1.19.2... [ OK ] Loaded version 1.19.2
[ .. ] Loading java... [ OK ] Loaded Mojang java 17.0.8
[ OK ] Checked version jar
[ .. ] Checking assets version 1.19... [ OK ] Checked 3390 assets version 1.19
[ .. ] Checking libraries... [ OK ] Checked 91 class and 0 native libraries
[ OK ] Using logger client-1.12Exception in thread Minecraft Stream Thread: Traceback (most recent call last): File "c:\users\redacted\appdata\local\programs\python\python38\lib\threading.py", line 932, in _bootstrap_inner self.run() File "c:\users\redacted\appdata\local\programs\python\python38\lib\threading.py", line 870, in run self._target(*self._args, **self._kwargs) File "c:\users\redacted\appdata\local\programs\python\python38\lib\site-packages\portablemc\standard.py", line 1634, in process_stream_thread if not parser.feed(line, self.process_stream_event): File "c:\users\redacted\appdata\local\programs\python\python38\lib\site-packages\portablemc\standard.py", line 1677, in feed callback(self.next_event) File "c:\users\redacted\appdata\local\programs\python\python38\lib\site-packages\portablemc\cli__init__.py", line 887, in process_stream_event out.print(f"[{time}] [{event.thread}] [{event.level}] {event.message}\n") File "c:\users\redacted\appdata\local\programs\python\python38\lib\site-packages\portablemc\cli\output.py", line 181, in print print(text, end="") File "c:\users\redacted\appdata\local\programs\python\python38\lib\encodings\cp1252.py", line 19, in encode return codecs.charmap_encode(input,self.errors,encoding_table)[0] UnicodeEncodeError: 'charmap' codec can't encode characters in position 292-299: character maps to
When researching the bottom line, somebody said to fix it, you need to make sure you define your encoding table, like utf-8