Skip to content

Commit 508b69f

Browse files
codebamcarlos-jenkins
authored andcommitted
Fix(webhooks.py): Fixes JSON parsing errors in Python 3
This commit fixes some errors caused by changes to Flask and the JSON parsing libraries in Python 3. The change to .get_json() fixes an error because the Flask request.data is encoded as a bytestring in python3, and loads() only supports string as a datatype. `loads(request.data.decode('utf-8'))` would be the equivalent. Decoded the `stdout` and `stderr` to fix parsing errors with `dumps()`
1 parent 74497a0 commit 508b69f

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

webhooks.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ def index():
9999

100100
# Gather data
101101
try:
102-
payload = loads(request.data)
102+
payload = request.get_json()
103103
except:
104104
abort(400)
105105

@@ -168,6 +168,8 @@ def index():
168168
stdout=PIPE, stderr=PIPE
169169
)
170170
stdout, stderr = proc.communicate()
171+
stout = stout.decode('utf-8')
172+
stderr = stderr.decode('utf-8')
171173

172174
ran[basename(s)] = {
173175
'returncode': proc.returncode,

0 commit comments

Comments
 (0)