Skip to content

Commit

Permalink
Merge 69a6641 into 0096714
Browse files Browse the repository at this point in the history
  • Loading branch information
andy-maier committed Jul 20, 2018
2 parents 0096714 + 69a6641 commit 7257a45
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 1 deletion.
5 changes: 5 additions & 0 deletions docs/changes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,11 @@ Released: not yet
variables. They are no longer imported into the `pywbem` namespace.
See issue #1302.

* Fixed issue where `CIMInstance.tomof()` raised `IndexError` when it
contains an array property whose value is the empty array.
Added an according testcase.
See issue #1312.

**Enhancements:**

* Extend pywbem MOF compiler to search for dependent classes including:
Expand Down
3 changes: 2 additions & 1 deletion pywbem/cim_obj.py
Original file line number Diff line number Diff line change
Expand Up @@ -4782,7 +4782,8 @@ def tomof(
val_str, line_pos = _value_tomof(
self.value, self.type, indent + MOF_INDENT, maxline,
line_pos + 1, 1, True)
if val_str[0] != '\n':
# Empty arrays are represented as val_str=''
if val_str and val_str[0] != '\n':
# The extra space was actually needed
mof.append(u' ')
else:
Expand Down
13 changes: 13 additions & 0 deletions testsuite/test_cim_obj.py
Original file line number Diff line number Diff line change
Expand Up @@ -12062,6 +12062,19 @@ class Test_CIMProperty_tomof(object):
P1 = 42;\n""",
None, True
),
(
"instance uint32 array property, empty array",
CIMProperty(
name='P1',
value=list(),
type='uint32',
is_array=True,
),
True, 12,
u"""\
P1 = { };\n""",
None, True
),
(
"instance uint32 array property, single-line",
CIMProperty(
Expand Down

0 comments on commit 7257a45

Please sign in to comment.