Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ext_Extension (containerproperties.ExtensionNodeProperty) comparison is not as expected #238

Closed
1 of 2 tasks
a-kleinf opened this issue Aug 17, 2023 · 4 comments · Fixed by #239 or #250
Closed
1 of 2 tasks
Assignees
Labels
bug Something isn't working v1 Version 1 is affected v2 Version 2 is affected

Comments

@a-kleinf
Copy link
Collaborator

a-kleinf commented Aug 17, 2023

Is there an existing issue for this?

  • I have searched the existing issues

Current Behavior

The comparison of ext_Extension (instance of etree.Element) is not as expected.

When comparing two different instances of etree.Element the included data is not compared but it is checked that both instances are the same object.
This leads to a wrong comparison of ext_Extension attributes.

Expected Behavior

When comparing two different instances of ext_Extension attributes, the included data shall be evaluated.

Minimal Reproducible Example

from lxml import etree
from sdc11073.definitions_sdc import SDC_v1_Definitions
from sdc11073 import pmtypes

ident_xml = b"""
<pm:Identification xmlns:pm="http://standards.ieee.org/downloads/11073/11073-10207-2017/participant"
                   Root="urn:uuid:90beab82-f160-4e2f-b3b2-ed8cfcf5e205"
                   Extension="123.234.424">
    <ext:Extension xmlns:ext="http://standards.ieee.org/downloads/11073/11073-10207-2017/extension">
        <foo someattr="somevalue"/>
        <bar anotherattr="differentvalue"/>
    </ext:Extension>
</pm:Identification>
"""
ident_xml_normalized = SDC_v1_Definitions.normalizeXMLText(ident_xml)
inst1 = pmtypes.InstanceIdentifier.fromNode(etree.fromstring(ident_xml_normalized))
inst2 = pmtypes.InstanceIdentifier.fromNode(etree.fromstring(ident_xml_normalized))

print(f"{inst1.ext_Extension == inst1.ext_Extension = }")
print(f"{inst2.ext_Extension == inst2.ext_Extension = }")

print(f"{inst1.ext_Extension == inst2.ext_Extension = } ????????? NOT EXPECTED ?????????")
print(f"{etree.tostring(inst1.ext_Extension) == etree.tostring(inst2.ext_Extension) = } !!!!!!!!")

print("Extension 1: " + str(etree.tostring(inst1.ext_Extension)))
print("Extension 2: " + str(etree.tostring(inst2.ext_Extension)))

OUTPUT:

inst1.ext_Extension == inst1.ext_Extension = True
inst2.ext_Extension == inst2.ext_Extension = True

inst1.ext_Extension == inst2.ext_Extension = False ????????? NOT EXPECTED ?????????
etree.tostring(inst1.ext_Extension) == etree.tostring(inst2.ext_Extension) = True !!!!!!!!

Extension 1: b'<ext:Extension xmlns:ext="ExtensionPoint" xmlns:pm="BICEPS_ParticipantModel">\n \n \n </ext:Extension>\n'
Extension 2: b'<ext:Extension xmlns:ext="ExtensionPoint" xmlns:pm="BICEPS_ParticipantModel">\n \n \n </ext:Extension>\n'

Solution proposal

No response

Python Version

3.9

Operating system

Windows

Sdc11073 Version

1.1.28

Link to sdc11073 Logs

No response

Further Information

No response

Participation

  • I am willing to submit a pull request to fix this bug.
@a-kleinf a-kleinf added the bug Something isn't working label Aug 17, 2023
@a-kleinf
Copy link
Collaborator Author

similar bug was reported for the xml python library: https://bugs.python.org/issue37792

@leon1995 leon1995 added the v1 Version 1 is affected label Aug 17, 2023
@leon1995
Copy link
Member

this also affects version 2

@leon1995 leon1995 added the v2 Version 2 is affected label Aug 17, 2023
@leon1995
Copy link
Member

similar bug was reported for the xml python library: https://bugs.python.org/issue37792

yeah, this is a problem in lxml, as

etree.fromstring(ident_xml) == etree.fromstring(ident_xml)

also returns False

@leon1995
Copy link
Member

requires fix for v1

@leon1995 leon1995 reopened this Aug 24, 2023
This was linked to pull requests Aug 24, 2023
@leon1995 leon1995 removed a link to a pull request Aug 31, 2023
5 tasks
@leon1995 leon1995 linked a pull request Aug 31, 2023 that will close this issue
5 tasks
@leon1995 leon1995 closed this as completed Sep 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment