Bug 614

Summary: LSB: Change of default encoding of python cause python-runtime test failure(test_builtin.py, test_getargs.py)
Product: [Build System, Metadata & Runtime] OE-Core Reporter: Jingdong Lu <jingdong.lu>
Component: devtools / tool chainAssignee: Jingdong Lu <jingdong.lu>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: Medium CC: jingdong.lu, ke.yu, kevin.tian, mark.hatle, meta.mr.watcher, meta.watcher, richard.purdie, sgw
Version: 1.0   
Target Milestone: 1.0 M4   
Hardware: x86   
OS: x86   
Whiteboard:
OS type for building Yocto: --- Type of Regression: ---
Verified: Documentation change: ---

Description Jingdong Lu 2010-12-23 00:50:16 UTC
A part of python-runtime test report
...
<09:28:08> test_builtin
<09:28:11> test test_builtin failed -- errors occurred; run in verbose mode for details
...
<09:34:58> test test_getargs crashed -- <type 'exceptions.ValueError'>: bad marshal data

Using command line to try to get more information:
eg. test_getargs.py
Failure result is like this,
>>> import marshal
>>> marshal.loads(u'\x92')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ValueError: bad marshal data
>>>

Correct result should be:
>>> import marshal
>>> marshal.loads(u'\x92')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
UnicodeEncodeError: 'ascii' codec can't encode character u'\x92' in position 0: ordinal not in range(128)
>>> 

I recompiled python without -O2/-O3 option and debug it using gdb. I found that the default encoding has been changed at beginning.
site.py
|-- execsitecustomize() 
    |-- import sitecustomize
sitecustomize.py
|-- sys.setdefaultencoding( "utf8" )

So, because of setting default encoding from "ascii" to "utf8" and LSB require the default encoding is "ascii", the test failed. I delete "sitecustomize.py" or make relevant lines and we can get the above two tests passed.

I find this file "sitecustomize.py" in OE recipe and I wonder whether it is possible to delete it.

Any suggestion?
Comment 1 Jingdong Lu 2011-02-16 00:58:42 UTC
Remove sitecustomize.py for lsb image.