Python堆栈跟踪解释-“ NoneType”对象不可迭代,但无循环

时间:2018-07-24 06:10:46

标签: python traceback

在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会受到伤害。

有人可以阐明这一点吗?

1 个答案:

答案 0 :(得分:2)

尝试迭代*tls.Config时通常会遇到

'NoneType' object is not iterable,但尝试在None上执行sequence unpacking时也可能会出现

None,例如:

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