[OE-core] [PATCH] relocate_sdk.py: Allow script to work with Python 2.4 and 3.
Laurentiu Palcu
laurentiu.palcu at intel.com
Thu Oct 17 07:01:46 UTC 2013
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 at 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 at 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 at lists.openembedded.org
> http://lists.openembedded.org/mailman/listinfo/openembedded-core
More information about the Openembedded-core
mailing list