Bug 811202 - OVIRT-SDK: sdk fails to serialize non-ascii
Summary: OVIRT-SDK: sdk fails to serialize non-ascii
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: oVirt
Classification: Retired
Component: ovirt-engine-sdk
Version: unspecified
Hardware: All
OS: Linux
high
high
Target Milestone: ---
: 3.1
Assignee: Michael Pasternak
QA Contact:
URL:
Whiteboard: infra
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2012-04-10 12:10 UTC by Jaroslav Henner
Modified: 2014-01-13 00:37 UTC (History)
6 users (show)

Fixed In Version: 3.1.0.5
Clone Of:
Environment:
Last Closed: 2012-08-09 08:05:33 UTC
oVirt Team: ---
Embargoed:


Attachments (Terms of Use)

Description Jaroslav Henner 2012-04-10 12:10:54 UTC
Description of problem:
non-ascii chars is a problem for ovirt-engine-sdk.

Version-Release number of selected component (if applicable):
ovirt-engine-sdk-1.6.4-1.fc16.noarch

How reproducible:
always

Steps to Reproduce:
1.
# -*- encoding: utf-8 -*-
FUNNY_CHARS = "!@#$%^&*{}<>? <!-- ]]> <?PCDATA[[ <?CDATA[[ \" \"\'\" °ěščřžýáíéůü Việt Nam עִבְרִית"

    def test_funny_chars_in_PUT_xml_error(self):
        cl = APICKO.clusters.get(name="Default")
        cl.description = FUNNY_CHARS
        cl.update()
  
Actual results:
======================================================================
ERROR: test_funny_chars_in_PUT_xml_error (general_tests.MockedServerTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "general_tests.py", line 239, in test_funny_chars_in_PUT_xml_error
    cl.update()
  File "/usr/lib/python2.7/site-packages/ovirtsdk/infrastructure/brokers.py", line 123, in update
    body=ParseHelper.toXml(self.superclass))
  File "/usr/lib/python2.7/site-packages/ovirtsdk/utils/parsehelper.py", line 35, in toXml
    entity.export(output, 0, name_=ParseHelper.getXmlTypeInstance(type_name))
  File "/usr/lib/python2.7/site-packages/ovirtsdk/xml/params.py", line 5260, in export
    self.exportChildren(outfile, level + 1, namespace_, name_)
  File "/usr/lib/python2.7/site-packages/ovirtsdk/xml/params.py", line 5268, in exportChildren
    super(Cluster, self).exportChildren(outfile, level, namespace_, name_, True)
  File "/usr/lib/python2.7/site-packages/ovirtsdk/xml/params.py", line 4210, in exportChildren
    outfile.write('<%sdescription>%s</%sdescription>\n' % (namespace_, self.gds_format_string(quote_xml(self.description).encode(ExternalEncoding), input_name='description'), namespace_))
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc2 in position 72: ordinal not in range(128)

if I change the funny chars to unicode string like this:
FUNNY_CHARS = u"!@#$%^&*{}<>? <!-- ]]> <?PCDATA[[ <?CDATA[[ \" \"\'\" °ěščřžýáíéůü Việt Nam עִבְרִית"
I'll get:

Traceback (most recent call last):
  File "/usr/lib64/python2.7/runpy.py", line 162, in _run_module_as_main
    "__main__", fname, loader, pkg_name)
  File "/usr/lib64/python2.7/runpy.py", line 72, in _run_code
    exec code in run_globals
  File "/usr/lib64/python2.7/unittest/__main__.py", line 12, in <module>
    main(module=None)
  File "/usr/lib64/python2.7/unittest/main.py", line 94, in __init__
    self.parseArgs(argv)
  File "/usr/lib64/python2.7/unittest/main.py", line 149, in parseArgs
    self.createTests()
  File "/usr/lib64/python2.7/unittest/main.py", line 158, in createTests
    self.module)
  File "/usr/lib64/python2.7/unittest/loader.py", line 128, in loadTestsFromNames
    suites = [self.loadTestsFromName(name, module) for name in names]
  File "/usr/lib64/python2.7/unittest/loader.py", line 91, in loadTestsFromName
    module = __import__('.'.join(parts_copy))
  File "general_tests.py", line 161, in <module>
    """.format(FUNNY_CHARS)),
UnicodeEncodeError: 'ascii' codec can't encode characters in position 50-61: ordinal not in range(128)

Expected results:
No problem to use unicode chars, because it seems to be accepted by other means - webadmin as well as WPF gui.


Additional info:

Comment 1 Michael Pasternak 2012-07-10 06:56:49 UTC
make sure you have # -*- coding: utf-8 -*- when verifying this bug.

Comment 2 Itamar Heim 2012-08-09 08:05:33 UTC
closing ON_QA bugs as oVirt 3.1 was released:
http://www.ovirt.org/get-ovirt/


Note You need to log in before you can comment on or make changes to this bug.