pcp
[Top] [All Lists]

Re: [pcp] python api unicode exception

To: Nathan Scott <nathans@xxxxxxxxxx>
Subject: Re: [pcp] python api unicode exception
From: Martins Innus <minnus@xxxxxxxxxxx>
Date: Fri, 25 Sep 2015 11:43:43 -0400
Cc: pcp@xxxxxxxxxxx
Delivered-to: pcp@xxxxxxxxxxx
In-reply-to: <1230140677.42710858.1443161348565.JavaMail.zimbra@xxxxxxxxxx>
References: <5601A12A.6070109@xxxxxxxxxxx> <1230140677.42710858.1443161348565.JavaMail.zimbra@xxxxxxxxxx>
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.10; rv:38.0) Gecko/20100101 Thunderbird/38.2.0
Nathan,

On 9/25/15 2:09 AM, Nathan Scott wrote:

----- Original Message -----
[...]
File "/usr/lib64/python2.7/site-packages/pcp/pmapi.py", line 1393, in
pmGetInDom
     nameL = list(map(lambda x: str(nameA_p[x].decode()), range(status)))
   File "/usr/lib64/python2.7/site-packages/pcp/pmapi.py", line 1393, in
<lambda>
     nameL = list(map(lambda x: str(nameA_p[x].decode()), range(status)))
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc9 in position
2247: ordinal not in range(128)
Our simple local fix to get things working is:
[...]

Maybe someone who understands passing unicode between C and python has a
better understanding of the correct/different fix?

Thanks Martins - I've merged something very similar, audited the other
places where we are exposed to the same failure-to-decode-instance-names
(three other spots, same fix), and added a test case.

Could you review & verify the master branch for your failing case?  Taa.

Unfortunately still fails for our test case. I'll send you the archive off list since its a bit large and may have some local user information.

[minnus@pcp3:minnu]$ ./procpid.python --archive out
Traceback (most recent call last):
  File "./procpid.python", line 57, in <module>
    manager['proc'] = PROC_METRICS
File "/data/opt/supremm/lib64/python2.7/site-packages/pcp/pmcc.py", line 545, in __setitem__
    dict.__setitem__(self, attr, MetricGroup(self, inL = value))
File "/data/opt/supremm/lib64/python2.7/site-packages/pcp/pmcc.py", line 413, in __init__
    self.mgAdd(inL)
File "/data/opt/supremm/lib64/python2.7/site-packages/pcp/pmcc.py", line 426, in mgAdd
    coreL, errL = self._ctx.mcGetCoresByName(nameL)
File "/data/opt/supremm/lib64/python2.7/site-packages/pcp/pmcc.py", line 318, in mcGetCoresByName
    newcore = self._mcCreateCore(name, pmid)
File "/data/opt/supremm/lib64/python2.7/site-packages/pcp/pmcc.py", line 335, in _mcCreateCore
    self._mcAdd(newcore)
File "/data/opt/supremm/lib64/python2.7/site-packages/pcp/pmcc.py", line 277, in _mcAdd
    instL, nameL = self.pmGetInDomArchive(core.desc)
File "/data/opt/supremm/lib64/python2.7/site-packages/pcp/pmapi.py", line 1723, in pmGetInDomArchive nameL = list(map(lambda x: str(nameA_p[x].decode('utf-8', 'ignore')), range(status))) File "/data/opt/supremm/lib64/python2.7/site-packages/pcp/pmapi.py", line 1723, in <lambda> nameL = list(map(lambda x: str(nameA_p[x].decode('utf-8', 'ignore')), range(status))) UnicodeEncodeError: 'ascii' codec can't encode character u'\u033e' in position 2428: ordinal not in range(128)



Changing the utf-8 to ascii on the offending line allows the test to pass.

Thanks

Martins

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