Skip to content

IBMMQ to_string() does not strip NULL as it claims #10

@andrewkirillov-ibm

Description

@andrewkirillov-ibm

The problem was spotted when doing PCF inquiries of Queue Status.

First, lets see the dump from PCF Queue inquiry:

14:11:16,862 DUMP     : PCF Response:
-------------------------------------
[{2016: b'Q1                                              ', 20: 1, 134: -3, 2027: b'2025-11-02  ', 2028: b'12.11.04', 2019: b'                                                ', 22: 0, 276: -1, 2030: b'                                                ', 2029: b'                                                ', 2124: b'                                                ', 96: 0, 95: 0, 98: -3, 2004: b'2025-07-30  ', 2005: b'06.11.07', 

From the above, we can see that queue attributes like ibmmq.CMQC.MQCA_ALTERATION_DATE (2027) and ibmmq.CMQC.MQCA_CREATION_DATE (2004) are space padded.

However, lets see dump from Queue Status inquiry:

14:16:00,224 DUMP     : PCF Response:
-------------------------------------
[{2016: b'VASQUEUE1                                       ', 1103: 1105, 3: 6, 1437: 1, 1438: 2088960, 17: 0, 3130: b'2025-11-04\x00\x00', 3131: b'04.37.14', 3128: b'2025-11-04\x00\x00', 3129: b'04.39.05', 3073: b'', 123: 65, 1227: 92326, 18: 0, 1226: [195395574, 195395574], 1027: 0}]

Here we see that attributes like ibmmq.CMQCFC.MQCACF_LAST_GET_DATE (3130) and ibmmq.CMQCFC.MQCACF_LAST_PUT_DATE (3128) are NULL padded.

Doing ibmmq.to_string() on those NULL terminated byte arrays produces strings like this:

 'LGETDATE': '2025-11-04\x00\x00', 'LPUTDATE': '2025-11-04\x00\x00'

The implementation of to_string() does this: v.decode(encoding).strip(). As decode() converts 0 bytes to \x00 strings, the strip() has nothing really to strip.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions