Skip to content

Error: 'NoneType' object is not iterable [__main__] #1768

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

Open
buzmeg opened this issue May 6, 2025 · 0 comments
Open

Error: 'NoneType' object is not iterable [__main__] #1768

buzmeg opened this issue May 6, 2025 · 0 comments

Comments

@buzmeg
Copy link

buzmeg commented May 6, 2025

In tcp_client_probe.py the following code exists:

    _PROPERTY_CONVERTERS = {
            'capabilities':                 lambda value: [DebugProbe.Capability[v] for v in value],
            'supported_wire_protocols':     lambda value: [DebugProbe.Protocol[v] for v in value],
            'wire_protocol':                lambda value: DebugProbe.Protocol[value] if (value is not None) else None,
        }

Presumably, that None shield needs to be present for all of them right?

I'm also more used to seeing something like: for ii in value or [] rather than that if statement, but I don't know if they are precisely equivalent.

Side note: the logging didn't give me a very useful traceback and I had to add a bunch of code to main.py to get a useful traceback. All it gave was the useless:
0000575 C Error: 'NoneType' object is not iterable [__main__]

Full traceback after I added code:

pyOCD % pyocd erase -L pyocd.probe.tcp_client_probe.trace=debug --uid=remote:192.168.13.17:3333 --chip --target stm32g0b1retx
0000401 D Request: {"id": 0, "request": "hello", "arguments": [1]} [tcp_client_probe]
0000420 D decoded_response = {'id': 0, 'status': 0} [tcp_client_probe]
0000420 D Request: {"id": 1, "request": "open"} [tcp_client_probe]
0000437 D decoded_response = {'id': 0, 'status': 0} [tcp_client_probe]
0000437 D Request: {"id": 2, "request": "set_clock", "arguments": [1000000]} [tcp_client_probe]
0000459 D decoded_response = {'id': 0, 'status': 0} [tcp_client_probe]
0000497 D Request: {"id": 3, "request": "lock"} [tcp_client_probe]
0000521 D decoded_response = {'id': 0, 'status': 0} [tcp_client_probe]
0000526 D Request: {"id": 4, "request": "readprop", "arguments": ["capabilities"]} [tcp_client_probe]
0000549 D decoded_response = {'id': 0, 'status': 0} [tcp_client_probe]
0000549 D Request: {"id": 5, "request": "disconnect"} [tcp_client_probe]
0000567 D decoded_response = {'id': 0, 'status': 0} [tcp_client_probe]
0000568 D Request: {"id": 6, "request": "close"} [tcp_client_probe]
0000585 D decoded_response = {'id': 0, 'status': 0} [tcp_client_probe]
0000585 C FAULT 2! [__main__]
0000586 C Error: 'NoneType' object is not iterable [__main__]
Traceback (most recent call last):
  File "/var/home/foo/stdev/pyOCD/pyocd/__main__.py", line 161, in run
    status = cmd.invoke()
  File "/var/home/foo/stdev/pyOCD/pyocd/subcommands/erase_cmd.py", line 94, in invoke
    with session:
         ^^^^^^^
  File "/var/home/foo/stdev/pyOCD/pyocd/core/session.py", line 415, in __enter__
    self.open()
    ~~~~~~~~~^^
  File "/var/home/foo/stdev/pyOCD/pyocd/core/session.py", line 553, in open
    self._board.init()
    ~~~~~~~~~~~~~~~~^^
  File "/var/home/foo/stdev/pyOCD/pyocd/board/board.py", line 143, in init
    self.target.init()
    ~~~~~~~~~~~~~~~~^^
  File "/var/home/foo/stdev/pyOCD/pyocd/coresight/coresight_target.py", line 123, in init
    super().init()
    ~~~~~~~~~~~~^^
  File "/var/home/foo/stdev/pyOCD/pyocd/core/soc_target.py", line 174, in init
    seq.invoke()
    ~~~~~~~~~~^^
  File "/var/home/foo/stdev/pyOCD/pyocd/utility/sequencer.py", line 213, in invoke
    resultSequence.invoke()
    ~~~~~~~~~~~~~~~~~~~~~^^
  File "/var/home/foo/stdev/pyOCD/pyocd/utility/sequencer.py", line 208, in invoke
    resultSequence = call()
  File "/var/home/foo/stdev/pyOCD/pyocd/coresight/dap.py", line 435, in _get_probe_capabilities
    caps = self._probe.capabilities
           ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/var/home/foo/stdev/pyOCD/pyocd/probe/tcp_client_probe.py", line 141, in capabilities
    return self._read_property('capabilities')
           ~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^
  File "/var/home/foo/stdev/pyOCD/pyocd/probe/tcp_client_probe.py", line 217, in _read_property
    result = self._PROPERTY_CONVERTERS[name](result)
  File "/var/home/foo/stdev/pyOCD/pyocd/probe/tcp_client_probe.py", line 207, in <lambda>
    'capabilities':                 lambda value: [DebugProbe.Capability[v] for v in value],
                                                                                     ^^^^^
TypeError: 'NoneType' object is not iterable

> /var/home/foo/stdev/pyOCD/pyocd/probe/tcp_client_probe.py(207)<lambda>()
-> 'capabilities':                 lambda value: [DebugProbe.Capability[v] for v in value],
(Pdb)
@buzmeg buzmeg changed the title NoneType fails to iterate Error: 'NoneType' object is not iterable [__main__] May 6, 2025
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