Bug 811202 - OVIRT-SDK: sdk fails to serialize non-ascii
OVIRT-SDK: sdk fails to serialize non-ascii
Status: CLOSED CURRENTRELEASE
Product: oVirt
Classification: Community
Component: ovirt-engine-sdk (Show other bugs)
unspecified
All Linux
high Severity high
: ---
: 3.1
Assigned To: Michael Pasternak
infra
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2012-04-10 08:10 EDT by Jaroslav Henner
Modified: 2014-01-12 19:37 EST (History)
6 users (show)

See Also:
Fixed In Version: 3.1.0.5
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2012-08-09 04:05:33 EDT
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description Jaroslav Henner 2012-04-10 08:10:54 EDT
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 02:56:49 EDT
make sure you have # -*- coding: utf-8 -*- when verifying this bug.
Comment 2 Itamar Heim 2012-08-09 04:05:33 EDT
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.