Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #52924

Re: Conversion Issue in Converting code of 2.7 to 3

Path csiph.com!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed1.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <python@mrabarnett.plus.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.000
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'scripts': 0.03; 'syntax': 0.04; 'error:': 0.07; 'subject:code': 0.07; 'mentions': 0.09; 'method,': 0.09; 'pep': 0.09; 'subject:2.7': 0.09; 'python': 0.11; 'def': 0.12; 'arg': 0.16; 'assembler': 0.16; 'from:addr:mrabarnett.plus.com': 0.16; 'from:addr:python': 0.16; 'from:name:mrab': 0.16; 'message-id:@mrabarnett.plus.com': 0.16; 'parse,': 0.16; 'received:84.93': 0.16; 'received:84.93.230': 0.16; 'struck': 0.16; 'subject:Converting': 0.16; 'syntaxerror:': 0.16; 'tokenize,': 0.16; 'url:title': 0.16; 'url:whatsnew': 0.16; 'fix': 0.17; 'wrote:': 0.18; 'looked': 0.18; 'trying': 0.19; 'subject:Issue': 0.19; 'written': 0.21; 'import': 0.22; 'header :User-Agent:1': 0.23; 'error': 0.23; 'skip:" 40': 0.26; 'code:': 0.26; 'url:edu': 0.26; 'skip:" 20': 0.27; 'header:In-Reply-To:1': 0.27; 'code': 0.31; 'url:wiki': 0.31; 'piece': 0.31; 'file': 0.32; 'figure': 0.32; 'run': 0.32; 'url:python': 0.33; '(most': 0.33; 'convert': 0.35; 'received:84': 0.35; 'but': 0.35; 'skip:" 50': 0.36; 'hi,': 0.36; 'url:org': 0.36; 'to:addr:python-list': 0.38; 'recent': 0.39; "couldn't": 0.39; 'to:addr:python.org': 0.39; 'url:3': 0.61; 'simple': 0.61; 'here:': 0.62; 'url:index': 0.63; 'field': 0.63; 'url:0': 0.67; 'header:Reply-To:1': 0.67; 'invalid': 0.68; 'reply-to:no real name:2**0': 0.71; '2.7.': 0.84; 'or:': 0.84; 'reply-to:addr:python.org': 0.84; 'url:php': 0.85
X-CM-Score 0.00
X-CNFS-Analysis v=2.1 cv=ZMDuxxLb c=1 sm=1 tr=0 a=0nF1XD0wxitMEM03M9B4ZQ==:117 a=0nF1XD0wxitMEM03M9B4ZQ==:17 a=0Bzu9jTXAAAA:8 a=0kkAYlmtguIA:10 a=52yiBY8jmcwA:10 a=ihvODaAuJD4A:10 a=OUOv7kDek9cA:10 a=8nJEP1OIZ-IA:10 a=EBOSESyhAAAA:8 a=8AHkEIZyAAAA:8 a=9-gbczHaNE8A:10 a=HRDnOzkmAAAA:8 a=Lfih8oYfDZOLeTboJdgA:9 a=wPNLvfGTeEIA:10 a=0a0pWMpvFooA:10 a=5kkW_wilE6EA:10
X-AUTH mrabarnett:2500
Date Sat, 24 Aug 2013 03:45:19 +0100
From MRAB <python@mrabarnett.plus.com>
User-Agent Mozilla/5.0 (Windows NT 5.1; rv:17.0) Gecko/20130801 Thunderbird/17.0.8
MIME-Version 1.0
To python-list@python.org
Subject Re: Conversion Issue in Converting code of 2.7 to 3
References <CAO_L6qFAnjcDvCeA7RK8eBdK+zJsO9qGbpFQH5=QaJwnihvi9A@mail.gmail.com>
In-Reply-To <CAO_L6qFAnjcDvCeA7RK8eBdK+zJsO9qGbpFQH5=QaJwnihvi9A@mail.gmail.com>
Content-Type text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding 7bit
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
Reply-To python-list@python.org
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.187.1377312317.19984.python-list@python.org> (permalink)
Lines 63
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1377312317 news.xs4all.nl 15923 [2001:888:2000:d::a6]:43968
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:52924

Show key headers only | View raw


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


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