0
Dump Error:

Traceback (most recent call last):
  File "/base/data/home/apps/s~tagtoo-ec/1.361220954515344675/libs/handlers.py", line 69, in get
    self.beforeFilter()
  File "/base/data/home/apps/s~tagtoo-ec/1.361220954515344675/libs/handlers.py", line 51, in beforeFilter
    self.set_track()
  File "/base/data/home/apps/s~tagtoo-ec/1.361220954515344675/libs/handlers.py", line 99, in set_track
    track_id = self.request.cookies.get("tagtoo_user_track", None)
  File "/base/python_runtime/python_lib/versions/1/webob/__init__.py", line 985, in cookies
    vars = self.str_cookies
  File "/base/python_runtime/python_lib/versions/1/webob/__init__.py", line 973, in str_cookies
    cookies.load(source)
  File "/base/python_runtime/python_dist/lib/python2.5/Cookie.py", line 619, in load
    self.__ParseString(rawdata)
  File "/base/python_runtime/python_dist/lib/python2.5/Cookie.py", line 650, in __ParseString
    self.__set(K, rval, cval)
  File "/base/python_runtime/python_dist/lib/python2.5/Cookie.py", line 572, in __set
    M.set(key, real_value, coded_value)
  File "/base/python_runtime/python_dist/lib/python2.5/Cookie.py", line 451, in set
    raise CookieError("Illegal key value: %s" % key)
CookieError: Illegal key value: tagtoo_u{er_track

我多次收到此错误消息。

问题是

  1. 我使用的关键值是“tagtoo_user_track”。“tagtoo_u{er_track”来自哪里?
  2. 这个错误并不总是发生。我在每个请求中都使用了相同的方法。如果完全错误,则应在每个请求中引发此异常。但是,错误消息只引发了几次。

它是谷歌应用引擎的错误吗?

编辑1

它再次发生在另一个 cookie 键“tagtoo_user_track”上。看起来 cookie 引擎不喜欢“s”。

Traceback (most recent call last):
  File "/base/data/home/apps/s~tagtoo-ec/1.361220954515344675/libs/handlers.py", line 69, in get
    self.beforeFilter()
  File "/base/data/home/apps/s~tagtoo-ec/1.361220954515344675/libs/handlers.py", line 51, in beforeFilter
    self.set_track()
  File "/base/data/home/apps/s~tagtoo-ec/1.361220954515344675/libs/handlers.py", line 99, in set_track
    track_id = self.request.cookies.get("tagtoo_user_track", None)
  File "/base/python_runtime/python_lib/versions/1/webob/__init__.py", line 985, in cookies
    vars = self.str_cookies
  File "/base/python_runtime/python_lib/versions/1/webob/__init__.py", line 973, in str_cookies
    cookies.load(source)
  File "/base/python_runtime/python_dist/lib/python2.5/Cookie.py", line 619, in load
    self.__ParseString(rawdata)
  File "/base/python_runtime/python_dist/lib/python2.5/Cookie.py", line 650, in __ParseString
    self.__set(K, rval, cval)
  File "/base/python_runtime/python_dist/lib/python2.5/Cookie.py", line 572, in __set
    M.set(key, real_value, coded_value)
  File "/base/python_runtime/python_dist/lib/python2.5/Cookie.py", line 451, in set
    raise CookieError("Illegal key value: %s" % key)
CookieError: Illegal key value: tagtoo_user_ses{ion
4

1 回答 1

0

看起来 cookie 字符串中存在格式错误。无论用户是否使用相关的 cookie 值,python 2.5 cookie 库都会引发异常。

可以通过以下方式检测错误的 cookie 值 self.request.environ.get("HTTP_COOKIE")

因此,我在引发异常时手动解析 cookie 以避免此问题。

于 2012-08-27T06:28:19.300 回答