pcp
[Top] [All Lists]

Re: [pcp] Lots of Python failures on Centos 5.10

To: Ken McDonell <kenj@xxxxxxxxxxxxxxxx>
Subject: Re: [pcp] Lots of Python failures on Centos 5.10
From: David Arnold <davida@xxxxxxxxx>
Date: Thu, 11 Sep 2014 21:39:44 +1000
Cc: David Arnold <davida@xxxxxxxxx>, pcp@xxxxxxxxxxx
Delivered-to: pcp@xxxxxxxxxxx
Dkim-signature: v=1; a=rsa-sha1; c=relaxed; d=pobox.com; h=subject :mime-version:content-type:from:in-reply-to:date:cc:message-id :references:to; s=sasl; bh=kNO0w87Xi80KC6+gZZfdMFn13bY=; b=c+u2C 467LjUo77BzEfXiFi4/uIcl5aZGQJgveNdXZ3xoscJ/8i30iDK6BGIsE60+4F2gp Hr4wywj4B3tqeT8gjDbVtZwyw0n3AglQQ54k16zqdEZ0aFb9uXyUlBaOdyjSPJfb A1BZVI5BafEFbAiskOttmLEuhfdgSRK/NwKYSo=
Domainkey-signature: a=rsa-sha1; c=nofws; d=pobox.com; h=subject :mime-version:content-type:from:in-reply-to:date:cc:message-id :references:to; q=dns; s=sasl; b=kYL5LiRA62l++TefvzmF89msQBmGInT nM84OfBsYSLHQQuoRuC2UE8ELrpEfCO0kEuOcP8P8OlLfNxaL4oZbUMbVyin2H3N DYnjQ6wVaxIa5lqQInpJtzKxJNHYuFqT+uLBVEd8whMrQ8ZtPvLBXbCossOsIPWe cRaTSyha3v9M=
In-reply-to: <54114E71.50900@xxxxxxxxxxxxxxxx>
References: <540CDD93.1040606@xxxxxxxxxxxxxxxx> <54114E71.50900@xxxxxxxxxxxxxxxx>
On 11/09/2014, at 5:25 PM, Ken McDonell wrote:

Hi Ken,

> The problem here is the version of Python ... it is 2.4.3 on CentOS 5.10.  
> For Python 2.5 or earlier, "as" is not allowed and "," must be used.

FWIW, Python 2.4 was first released in November 2004, and was replaced by 
Python 2.5 in September 2006.  Red Hat continued to ship 2.4 with RHEL5 (GA 
march 2007), before upgrading to Python 2.6 in RHEL6.

It's my impression that versions older than 2.6 are now largely ignored within 
the Python community, with most people focusing on 2.7 and 3.x.

Of course, RHEL5 is a LTS distribution, and it's going to continue to support 
Python-2.4 until March 2020, so this is probably a problem worth solving.

> So I need Python-expert guidance here ... in PCPland should we
> 
> (a) disable all the Python bits for Python 2.5 or earlier?

I don't know enough about PCP to suggest that.

> (b) use the old-style "," everywhere (which apparently works in later 
> versions)? or

The old-style "," will work in Python 2.x, up to 2.7 (the latest, and final 
2.x).  It will *not* work with Python 3.x.
The new-style "as" will work in Python 2.6, 2.7 and 3.x.  It will not work in 
Python 2.5 and earlier.

> (c) is there some clever Python trick I'm missing?

Maybe.  See below (but it's pretty awful).

> This construct is _everywhere_ in the Python code (installed PCP bits and QA 
> bits), so answer carefully.

I imagine that the current use of "as" is written either because the author was 
unaware of the desire to support Python 2.5 and earlier, or because s/he felt 
that support for Python 3.x with the same codebase was more important.

I know of one work-around in the Python code, although it's not pretty:

   except ExceptionClass:
       junk, err, junk = sys.exc_info()
       # Use 'err' variable ...

is the same as

   except ExceptionClass as err:
       # Use 'err' variable ...

and will work across 2.x and 3.x.

The only other alternative I can think of is a post-install sed script 
(hand-wave, hand-wave) that would convert the "as" syntax to "," syntax if the 
system Python is 2.5 or earlier.  I've done similar spec file hackage in the 
past to mess about with the pyc/pyo byte-code generation, and I'm mostly 
confident that it would work.

I'm not sure which of these is worse.  For the sake of code-cleanliness and 
future-compatibility I lean towards the post-install sed approach, even though 
I think it's significantly uglier.

And at that point, I'll leave it to the PCP/Python regulars ...




d

Attachment: signature.asc
Description: Message signed with OpenPGP using GPGMail

<Prev in Thread] Current Thread [Next in Thread>