console_output_of_code_fail:
Python 3.4.2 (default, Oct 16 2014, 20:18:04)
[GCC 4.8.2] on linux
Type "help", "copyright", "credits" or "license" for more information.
pobj(info_container_bad)
Traceback (most recent call last):
File "", line 1, in
File "/usr/local/lib/python3.4/site-packages/xdict-0.00-py3.4.egg/xdict/jprint.py", line 1493, in pobj
File "/usr/local/lib/python3.4/site-packages/xdict-0.00-py3.4.egg/xdict/jprint.py", line 1360, in print_j_str
File "/usr/local/lib/python3.4/site-packages/xdict-0.00-py3.4.egg/xdict/jprint.py", line 1097, in get_line_color_sec
TypeError: 'NoneType' object is not subscriptable
exit()
console_output_of_code_successfull:
Python 3.4.2 (default, Oct 16 2014, 20:18:04)
[GCC 4.8.2] on linux
Type "help", "copyright", "credits" or "license" for more information.
code_fail: try: from xdict.jprint import pobj except: print("you cant use some debug functions") else: pass
code_successful: from xdict.jprint import pobj info_container_bad = {'req_body': b'{"redirectUri": "/overview", "token": "b8eb0acc-6067-4cf1-88af-c014fb81a22c", "utcOffset": "480"}', 'step': 2, 'req_head_updated': 1, 'resp_body_bytes': b'{"d":{"Value":"/overview","Error":null}}', 'resp_head': "http.client.HTTPResponse object at 0x7f7ed6aa5438", 'conn': "http.client.HTTPSConnection object at 0x7f7ed6aa55f8", 'url': 'https://www.movescount.com/services/UserAuthenticated', 'method': 'POST', 'req_head': {'Referer': 'https://www.movescount.com/auth?redirect_uri=%2foverview', 'Content-Type': 'application/json; charset=utf-8', 'Accept-Encoding': 'gzip,deflate,sdch', 'User-Agent': 'Mozilla/5.0 (Windows NT 6.3; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/37.0.2062.94 Safari/537.36', 'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,/;q=0.8', 'Cookie': 'AWSELB=6BA385EF167F548755DA9475B5E2E58BE6A3496C1BF0760CC15AE59301430F4F26AB4074C646D70C24333B282A6F1E543BE54A50AE7A4F3D98B4314F531AF15C34D9355531; Movescount_lang=9; MovesCountCookie=9D65063B680AD03ECC6D203F0D124EA76A24FB72073D938D6A2F5D4B6820FC1BAE27DDB74E6D6B14DB32026210A9995C14B5581EECC34D30C1EAE9EFAAD111D3C9DC234EA619EBBC1143CB3A2F5E8D5A9F75AB64092B776655E8D04C7470057DA79855AB74D4E726257615213305609A8EC00A69C5BFD00D26410BFF8135A094A30A38D4BF85A322B7B00697A52FB7EC040D24A9544609C2873D4AC2D147CDCF904E0F58113CD0DC591CBA7E8944B03D75FBE4037FA566382CADDDB5AC3F84A78C35AF4CFB79B6125681FA1EB9A8A425480737D42D8F5BB82EDEC46B0A834977761D583F; ASP.NET_SessionId=xvobhic0obb3t5lajuasi0ib', 'Connection': 'close', 'Accept-Language': 'en;q=1.0, zh-CN;q=0.8'}} pobj(info_container_bad)
console_output_of_code_fail: Python 3.4.2 (default, Oct 16 2014, 20:18:04) [GCC 4.8.2] on linux Type "help", "copyright", "credits" or "license" for more information.
console_output_of_code_successfull: Python 3.4.2 (default, Oct 16 2014, 20:18:04) [GCC 4.8.2] on linux Type "help", "copyright", "credits" or "license" for more information.
solution: 原因是这个看似无关的因素引起了字典hash顺序的变化,从而改变了字典遍历的逻辑:{'a':x,'b':y} 而程序本身有个隐藏的BUG:先遍历处理'a',再处理'b'是OK的 先处理'b',再处理'a'就不是OK的
when fail:
'req_body': b'{"redirectUri": "/overview", "token": "b8eb0acc-6067-4cf1-88af-c014fb81a22c", "utcOffset": "480"}', b 14 ' None