Python 堆栈跟踪解释 - 'NoneType' 对象不可迭代,但没有循环

Python stack trace interpretation - 'NoneType' object is not iterable, but no loop

我在 django 应用程序的视图中有这个异常。但我认为我的问题根本与 django 无关。这是 python 的事情:

Traceback:

File "/home/ubuntu/app/.venv/lib/python3.5/site-packages/django/core/handlers/exception.py" in inner
  35.             response = get_response(request)

File "/home/ubuntu/app/.venv/lib/python3.5/site-packages/django/core/handlers/base.py" in _get_response
  128.                 response = self.process_exception_by_middleware(e, request)

File "/home/ubuntu/app/.venv/lib/python3.5/site-packages/django/core/handlers/base.py" in _get_response
  126.                 response = wrapped_callback(request, *callback_args, **callback_kwargs)

File "/home/ubuntu/app/frontend/views.py" in ajax_patient_pm
  2977.         (gstatus, gmessage) = grecaptcha_verify(request)

Exception Type: TypeError at /de/ajax/contactpatientpm/
Exception Value: 'NoneType' object is not iterable
Request information:
USER: AnonymousUser

GET: No GET data

POST: No POST data

FILES: No FILES data

COOKIES: No cookie data

这个 Traceback 让我很困惑。没有循环。我看不出 None 在任何变量中的什么地方会受到伤害。

任何人都可以阐明这一点吗?

'NoneType' object is not iterable 通常在尝试遍历 None 时遇到,但在尝试对 None 执行 sequence unpacking 时也可能发生,如下所示:

>>> x, y = None
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: 'NoneType' object is not iterable