Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

ctypes.Structure fields initialises incorrectly with \x00-containing bytes #117822

Copy link
Copy link
Open
@jorektheglitch

Description

@jorektheglitch
Issue body actions

Bug report

Bug description:

from ctypes import BigEndianStructure, c_char

class MRE(BigEndianStructure):
    _fields_ = [
        ("bugged", c_char*4)
    ]


value = b"\x11"*2 + b"\00" + b"\xFF"
mre = MRE(bugged=value)
print(mre.bugged)  # b'\x11\x11' but expected to be b'\x11\x11\x00\xff'

Looks like there is a problem with NULL-terminator somewhere.

CPython versions tested on:

3.11

Operating systems tested on:

Windows

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.