hardbyte / hardbyte/python-can
logging level with debug always failed with AttributeError: 'list' object has no attribute 'isalnum'
- Lingua principale
- Python
- Stelle
- 1.6k
- Fork
- 697
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Descrizione
### Describe the bug
When setting logging level to debug, each send message will gives above error. It is later found out that
From the can/Message.py line 143, -->if (self.data is not None) and (self.data.isalnum()):
Message.data is a list not a string, therefore above check on second part where it is checking self.data.isalnum() will gives error of AttributeError: 'list' object has no attribute 'isalnum'.
### To Reproduce
enable logging set logging level to debug. then try to send a can message and observe the error.
### Expected behavior
### Additional context
OS and version: window 10
Python version: 3.10
python-can version:
python-can interface/s (if applicable):
Traceback and logs
```python
def __str__(self) -> str:
field_strings = [f"Timestamp: {self.timestamp:>15.6f}"]
if self.is_extended_id:
arbitration_id_string = f"ID: {self.arbitration_id:08x}"
else:
arbitration_id_string = f"ID: {self.arbitration_id:04x}"
field_strings.append(arbitration_id_string.rjust(12, " "))
flag_string = " ".join(
[
"X" if self.is_extended_id else "S",
"Rx" if self.is_rx else "Tx",
"E" if self.is_error_frame else " ",
"R" if self.is_remote_frame else " ",
"F" if self.is_fd else " ",
"BS" if self.bitrate_switch else " ",
"EI" if self.error_state_indicator else " ",
]
)
field_strings.append(flag_string)
field_strings.append(f"DL: {self.dlc:2d}")
data_strings = []
if self.data is not None:
for index in range(0, min(self.dlc, len(self.data))):
data_strings.append(f"{self.data[index]:02x}")
if data_strings: # if not empty
field_strings.append(" ".join(data_strings).ljust(24, " "))
else:
field_strings.append(" " * 24)
if (self.data is not None) and (self.data.isalnum()): <=================== here
field_strings.append(f"'{self.data.decode('utf-8', 'replace')}'")
if self.channel is not None:
try:
field_strings.append(f"Channel: {self.channel}")
except UnicodeEncodeError:
pass
return " ".join(field_strings).strip()
```
Guida per i contributori
Apri la guida per i contributori
Valutazione
Questa issue non è ancora stata valutata.