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

reverseVpd.py yields different results for hex data on python2 than python3 #22

Open
bobpaul opened this issue Dec 16, 2024 · 0 comments

Comments

@bobpaul
Copy link

bobpaul commented Dec 16, 2024

When running on python2, reverseVpd.py yields results like:

    <keyword name="PR">
      <kwdesc>The PR keyword</kwdesc>
      <kwlen>8</kwlen>
      <kwformat>hex</kwformat>
      <kwdata>3600000122008000</kwdata>
    </keyword>
    <keyword name="HE">
      <kwdesc>The HE keyword</kwdesc>
      <kwlen>4</kwlen>
      <kwformat>ascii</kwformat>
      <kwdata>0001</kwdata>
    </keyword>
    <keyword name="CT">
      <kwdesc>The CT keyword</kwdesc>
      <kwlen>4</kwlen>
      <kwformat>hex</kwformat>
      <kwdata>00000000</kwdata>
    </keyword>
    <keyword name="HW">
      <kwdesc>The HW keyword</kwdesc>
      <kwlen>2</kwlen>
      <kwformat>hex</kwformat>
      <kwdata>0001</kwdata>
    </keyword>
    <keyword name="B3">
      <kwdesc>The B3 keyword</kwdesc>
      <kwlen>6</kwlen>
      <kwformat>hex</kwformat>
      <kwdata>000000000000</kwdata>
    </keyword>
    <keyword name="B4">
      <kwdesc>The B4 keyword</kwdesc>
      <kwlen>1</kwlen>
      <kwformat>hex</kwformat>
      <kwdata>00</kwdata>
    </keyword>
    <keyword name="B7">
      <kwdesc>The B7 keyword</kwdesc>
      <kwlen>12</kwlen>
      <kwformat>hex</kwformat>
      <kwdata>000000000000000000000000</kwdata>
    </keyword>

but on python3, everything is truncated:

    <keyword name="PR">
      <kwdesc>The PR keyword</kwdesc>
      <kwlen>8</kwlen>
      <kwformat>hex</kwformat>
      <kwdata>36000001220080</kwdata>
    </keyword>
    <keyword name="HE">
      <kwdesc>The HE keyword</kwdesc>
      <kwlen>4</kwlen>
      <kwformat>ascii</kwformat>
      <kwdata>0001</kwdata>
    </keyword>
    <keyword name="CT">
      <kwdesc>The CT keyword</kwdesc>
      <kwlen>4</kwlen>
      <kwformat>hex</kwformat>
      <kwdata>00</kwdata>
    </keyword>
    <keyword name="HW">
      <kwdesc>The HW keyword</kwdesc>
      <kwlen>2</kwlen>
      <kwformat>hex</kwformat>
      <kwdata>0001</kwdata>
    </keyword>
    <keyword name="B3">
      <kwdesc>The B3 keyword</kwdesc>
      <kwlen>6</kwlen>
      <kwformat>hex</kwformat>
      <kwdata>00</kwdata>
    </keyword>
    <keyword name="B4">
      <kwdesc>The B4 keyword</kwdesc>
      <kwlen>1</kwlen>
      <kwformat>hex</kwformat>
      <kwdata>00</kwdata>
    </keyword>
    <keyword name="B7">
      <kwdesc>The B7 keyword</kwdesc>
      <kwlen>12</kwlen>
      <kwformat>hex</kwformat>
      <kwdata>00</kwdata>

I'm not sure which output is the desired output. Line 264's test if (keywordData[nzeroidx] != 0x00): appears to be a bug, as b'\00' == 0x00 is false in both Python2 and Python3, but the code comments due imply that 0 truncation is desired.

In my opinion the Python2 behavior looks more desirable, as the XML represents the full data for binary fields.

@bobpaul bobpaul mentioned this issue Dec 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant