Skip to content

Commit d6d0068

Browse files
author
dom
committed
Fix extraction of a structure name from a swig object
1 parent 149785d commit d6d0068

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

swig/openscap_api.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,8 @@ def new(retobj):
138138
if type(retobj).__name__ in ('SwigPyObject', 'PySwigObject'):
139139
# Extract the name of structure from the representation of the object
140140
# "<Swig Object of type 'struct xccdf_result_iterator *' at 0x7f8f65fc1390>"
141-
structure = re.findall(r"type 'struct (\b\S*\b)", retobj.__repr__())[0]
141+
# or "<Swig Object of type 'oval_agent_session_t *' at 0x7f9aa2cdf360>"
142+
structure = re.findall(r"type '(struct )?(\b\S*\b)", retobj.__repr__())[0][1]
142143
return OSCAP_Object(structure, retobj)
143144
else:
144145
return retobj

0 commit comments

Comments
 (0)