From: Laurentiu Palcu <laurentiu.palcu@intel.com>
To: Konrad Scherer <konrad.scherer@windriver.com>
Cc: openembedded-core@lists.openembedded.org
Subject: Re: [PATCH] relocate_sdk.py: Allow script to work with Python 2.4 and 3.
Date: Thu, 17 Oct 2013 10:01:46 +0300 [thread overview]
Message-ID: <20131017070145.GB11504@lpalcu-linux> (raw)
In-Reply-To: <20131017065410.GA11504@lpalcu-linux>
On Thu, Oct 17, 2013 at 09:54:11AM +0300, Laurentiu Palcu wrote:
> On Wed, Oct 16, 2013 at 11:44:59AM -0400, Konrad Scherer wrote:
> > From: Konrad Scherer <Konrad.Scherer@windriver.com>
> >
> > Python 2.4 does not support the 'b' string literal or the
> > keyword 'as' in exception handling. Python 3 does not accept
> > the old method of exception handling and defaults to unicode.
> > The b() function converts strings to bytes on Python 3 and
> > using sys.exc_info() avoids the exception handling syntax.
> >
> > Signed-off-by: Konrad Scherer <Konrad.Scherer@windriver.com>
> > ---
> > scripts/relocate_sdk.py | 43 ++++++++++++++++++++++++++-----------------
> > 1 file changed, 26 insertions(+), 17 deletions(-)
> >
> > diff --git a/scripts/relocate_sdk.py b/scripts/relocate_sdk.py
> > index fe6e4e0..a15302d 100755
> > --- a/scripts/relocate_sdk.py
> > +++ b/scripts/relocate_sdk.py
> > @@ -31,7 +31,15 @@ import os
> > import re
> > import errno
> >
> > -old_prefix = re.compile(b"##DEFAULT_INSTALL_DIR##")
> > +if sys.version < '3':
> > + def b(x):
> > + return x
> > +else:
> > + import codecs
> I meant, you can drop this import. Too early in the morning! :)
>
> Thanks,
> Laurentiu
>
> > + def b(x):
> > + return x.encode(sys.getfilesystemencoding())
> > +
> > +old_prefix = re.compile(b("##DEFAULT_INSTALL_DIR##"))
> >
>
> _______________________________________________
> Openembedded-core mailing list
> Openembedded-core@lists.openembedded.org
> http://lists.openembedded.org/mailman/listinfo/openembedded-core
next prev parent reply other threads:[~2013-10-17 7:02 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-10-16 15:44 [Patch 0/1 V2] Update relocate_sdk.py to work with Python 2.4 Konrad Scherer
2013-10-16 15:44 ` [PATCH] relocate_sdk.py: Allow script to work with Python 2.4 and 3 Konrad Scherer
2013-10-17 6:54 ` Laurentiu Palcu
2013-10-17 7:01 ` Laurentiu Palcu [this message]
-- strict thread matches above, loose matches on Subject: below --
2013-10-17 14:17 [Patch 0/1 V3] Update relocate_sdk.py to work with Python 2.4 Konrad Scherer
2013-10-17 14:17 ` [PATCH] relocate_sdk.py: Allow script to work with Python 2.4 and 3 Konrad Scherer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20131017070145.GB11504@lpalcu-linux \
--to=laurentiu.palcu@intel.com \
--cc=konrad.scherer@windriver.com \
--cc=openembedded-core@lists.openembedded.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox