comparison hgext/lfs/wireprotolfsserver.py @ 43380:579672b347d2 stable

py3: define and use json.loads polyfill Python 3.5's json.loads() requires a str. Only Python 3.6+ supports passing a bytes or bytearray. This commit implements a json.loads() polyfill on Python 3.5 so that we can use bytes. The added function to detect encodings comes verbatim from Python 3.7.
author Gregory Szorc <gregory.szorc@gmail.com>
date Sat, 02 Nov 2019 12:09:35 -0700
parents 4aa72cdf616f
children 313e3a279828
comparison
equal deleted inserted replaced
43379:bb509f39d387 43380:579672b347d2
131 if req.headers[b'Accept'] != b'application/vnd.git-lfs+json': 131 if req.headers[b'Accept'] != b'application/vnd.git-lfs+json':
132 _sethttperror(res, HTTP_NOT_ACCEPTABLE) 132 _sethttperror(res, HTTP_NOT_ACCEPTABLE)
133 return True 133 return True
134 134
135 # XXX: specify an encoding? 135 # XXX: specify an encoding?
136 lfsreq = json.loads(req.bodyfh.read()) 136 lfsreq = pycompat.json_loads(req.bodyfh.read())
137 137
138 # If no transfer handlers are explicitly requested, 'basic' is assumed. 138 # If no transfer handlers are explicitly requested, 'basic' is assumed.
139 if r'basic' not in lfsreq.get(r'transfers', [r'basic']): 139 if r'basic' not in lfsreq.get(r'transfers', [r'basic']):
140 _sethttperror( 140 _sethttperror(
141 res, 141 res,