Skip to content

decoders.status() inserts None into Status object dictionary#305

Open
gregoryng wants to merge 1 commit into
brendan-w:masterfrom
gregoryng:status_nones
Open

decoders.status() inserts None into Status object dictionary#305
gregoryng wants to merge 1 commit into
brendan-w:masterfrom
gregoryng:status_nones

Conversation

@gregoryng
Copy link
Copy Markdown

The decoders.status() function unintentionally inserts attributes into the Status object for tests that aren't named. When you run dir(status_object) on status objects that came from this function, the code throws an exception.

This snippet demonstrates the problem:

import obd

messages = [obd.protocols.protocol.Message(frames=[])]
my_status = obd.decoders.status(messages)

print("type(my_status) =", type(my_status))
# <class 'obd.OBDResponse.Status'>

try:
    dir(my_status)
    exit(1)
except TypeError as excp:
    # '<' not supported between instances of 'NoneType' and 'str'
    print(excp)

# This will contain an entry 'None', which it's not supposed to
print(my_status.__dict__.keys())

The comments in the commit are copied from here:

for name in BASE_TESTS + SPARK_TESTS + COMPRESSION_TESTS:
if name: # filter out None/reserved tests
self.__dict__[name] = null_test

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

Successfully merging this pull request may close these issues.

1 participant