Krakatau icon indicating copy to clipboard operation
Krakatau copied to clipboard

UnicodeEncodeError

Open i0xHeX opened this issue 6 years ago • 14 comments

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.

i0xHeX avatar Apr 18 '18 16:04 i0xHeX

Could you send the link to [email protected]?

Storyyeller avatar Apr 18 '18 16:04 Storyyeller

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

i0xHeX avatar Apr 18 '18 16:04 i0xHeX

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.

Storyyeller avatar Apr 19 '18 05:04 Storyyeller

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?

i0xHeX avatar Aug 01 '18 09:08 i0xHeX

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

Storyyeller avatar Aug 01 '18 14:08 Storyyeller

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

Storyyeller avatar Aug 10 '18 18:08 Storyyeller

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

i0xHeX avatar Aug 10 '18 22:08 i0xHeX

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

Storyyeller avatar Aug 13 '18 07:08 Storyyeller

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?

Storyyeller avatar Aug 14 '18 04:08 Storyyeller

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

i0xHeX avatar Aug 14 '18 16:08 i0xHeX

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?

Owyn avatar Nov 02 '23 17:11 Owyn

rust version only has (dis)assembly so far.

Janmm14 avatar Nov 02 '23 17:11 Janmm14

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 avatar Nov 05 '23 04:11 Storyyeller

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

Storyyeller avatar Nov 05 '23 04:11 Storyyeller