Storyyeller / Krakatau

Java decompiler, assembler, and disassembler
GNU General Public License v3.0
1.95k stars 219 forks source link

UnicodeEncodeError #142

Open i0xHeX opened 6 years ago

i0xHeX commented 6 years ago

Downloaded stage after latest commit, without my fixes of unicode later. So one more sample:

Nonstandard attribute b'StackMap' 438
Nonstandard attribute b'StackMap' 14
Nonstandard attribute b'StackMap' 40
Nonstandard attribute b'StackMap' 624
Nonstandard attribute b'StackMap' 28
Nonstandard attribute b'StackMap' 34
Nonstandard attribute b'StackMap' 214
Nonstandard attribute b'StackMap' 411
Nonstandard attribute b'StackMap' 15
Nonstandard attribute b'StackMap' 18
Traceback (most recent call last):
  File "..\disassemble.py", line 73, in <module>
    disassembleSub(readFunc, out, targets, roundtrip=args.roundtrip)
  File "..\disassemble.py", line 46, in disassembleSub
    filename = out.write(name, output.getvalue())
  File "C:\Users\LuckyZeeRo\Desktop\Krakatau\Krakatau\script_util.py", line 152, in write
    f.write(data)
  File "C:\Users\LuckyZeeRo\AppData\Local\Programs\Python\Python37\lib\encodings\cp1251.py", line 19, in encode
    return codecs.charmap_encode(input,self.errors,encoding_table)[0]
UnicodeEncodeError: 'charmap' codec can't encode character '\u27e8' in position 968: character maps to <undefined>
Press any key to continue . . .

As I understand, my os using cp1251 encoding, and Krakatau can't handle it. I can give you jar but give me link to pm you.

Storyyeller commented 6 years ago

Could you send the link to n210241048576@gmail.com?

i0xHeX commented 6 years ago

Works okay when applying that to script_util: https://i.imgur.com/YdQk6gW.png Yeah, one minute (Sent)

Storyyeller commented 6 years ago

The app you sent me disassembles fine on my system, although that's not surprising, since this appears to be a system specific unicode issue. I'll have to trust that your patch works without testing it.

i0xHeX commented 5 years ago

Again, tried latest release from here, issue still here and unicode only fix above still works. Am I forced to fix this for myself every time u will update Krakatau? https://privatebin.net/?87c46deacd2e3679#DRIiq9cFURjTWPRbnUyVtwivRlArtEw20MlUj/Vkovc=

Windows 10 Python 3.7.0a2 Zip contains file I tried to disassemble and working script_util. krakatau.zip

Or if I can change python default encoding to utf 8, how to change it?

Storyyeller commented 5 years ago

I do have an old Windows computer, so I'll test it on that and see if I can reproduce the issue.

Storyyeller commented 5 years ago

Sorry I forgot about this. I'll try to get to it over the weekend.

i0xHeX commented 5 years ago

Opened pull request in case you will succesfully reproduce that issue.

Storyyeller commented 5 years ago

Sorry, it will take more time than I expected. But I'll try to get to it as soon as I can.

Storyyeller commented 5 years ago

I haven't been able to reproduce the issue, so I'm just going to have to trust that your PR is correct. Did you make sure to test it on Python 2 as well?

i0xHeX commented 5 years ago

Hmm, works well on python 2.7.15. Seems it's only Python 3.7 issue.

Owyn commented 8 months ago

Year 2023 (almost 2024), the bug is still there so I'm unable to use Krakatau (through bytecode-viewer ) with the latest python,

are you gonna stay on python 2.7 forever and make everyone use it?

what's with the rust version? is it out yet? can I put it into bytecode-viewer app somehow instead of the python 2.7 one?

Janmm14 commented 8 months ago

rust version only has (dis)assembly so far.

Storyyeller commented 8 months ago

Sorry for the late response, I was on vacation. Anyway, as Janmm14 mentioned, the Rust version only supports the assembler and disassembler, but so does Python 3. The decompiler is 2.7-only. Therefore, if you have any problems with Python 3, that means you are just using the assembler and disassembler, in which case there is no reason not to upgrade to the Rust version.

I strongly recommend switching bytecode-viewer to use the new Rust version, since it is much faster and has more features than the Python version.

Storyyeller commented 8 months ago

I filed https://github.com/Konloch/bytecode-viewer/issues/477 to ask bytecode-viewer to upgrade.