Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #52924
| Date | 2013-08-24 03:45 +0100 |
|---|---|
| From | MRAB <python@mrabarnett.plus.com> |
| Subject | Re: Conversion Issue in Converting code of 2.7 to 3 |
| References | <CAO_L6qFAnjcDvCeA7RK8eBdK+zJsO9qGbpFQH5=QaJwnihvi9A@mail.gmail.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.187.1377312317.19984.python-list@python.org> (permalink) |
On 24/08/2013 03:10, shankha wrote:
> Hi,
> I am trying to run the following piece of code:
>
> https://greyhat.gatech.edu/wiki/index.php?title=Java_Bytecode_Tutorial/Getting_Started
>
> python Krakatau/assemble.py minimal.j.
>
> The scripts are written for 2.7. I want to convert them to 3.3.
>
> I am struck with the following error:
>
>
>
> []$ python Krakatau/assemble.py minimal.j
> Traceback (most recent call last):
> File "Krakatau/assemble.py", line 4, in <module>
> from Krakatau.assembler import tokenize, parse, assembler
>
>
> File "c:\tmp\ByteCode\Krakatau\Krakatau\assembler\tokenize.py", line 3, in <module>
> from ..classfile import ClassFile
> File "c:\tmp\ByteCode\Krakatau\Krakatau\classfile.py", line 1, in <module>
>
>
> from . import constant_pool, method, field
> File "c:\tmp\ByteCode\Krakatau\Krakatau\constant_pool.py", line 10
> def decodeStr((s,)):
> ^
> SyntaxError: invalid syntax
>
>
>
>
>
> The code where this error originates from:
>
> def decodeStr((s,)):
> return s.replace('\xc0\x80','\0').decode('utf8'),
>
>
>
> I looked athttp://docs.python.org/3/whatsnew/3.0.html but I couldn't figure out where
>
> I am going wrong?
>
Look here:
http://docs.python.org/3/whatsnew/3.0.html#changed-syntax
at the "Removed Syntax" section where it mentions PEP 3113.
A simple fix is:
def decodeStr(arg):
(s,) = arg
return s.replace('\xc0\x80','\0').decode('utf8'),
or:
def decodeStr(s):
return s[0].replace('\xc0\x80','\0').decode('utf8'),
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: Conversion Issue in Converting code of 2.7 to 3 MRAB <python@mrabarnett.plus.com> - 2013-08-24 03:45 +0100
csiph-web