From b2548f56312a7ad3cf90fa34b436048baf0423cb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Richard=20Bo=C3=9F?= Date: Sun, 22 Jan 2017 20:57:24 +0100 Subject: [PATCH 1/2] don't write to /dev/urandom on Windows platforms --- gluon/utils.py | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/gluon/utils.py b/gluon/utils.py index a7ffdeb6..85d7d49f 100644 --- a/gluon/utils.py +++ b/gluon/utils.py @@ -17,6 +17,7 @@ import random import inspect import time import os +import sys import re import logging import socket @@ -299,19 +300,20 @@ def initialize_urandom(): try: os.urandom(1) have_urandom = True - try: - # try to add process-specific entropy - frandom = open('/dev/urandom', 'wb') + if sys.platform != 'win32': try: - if PY2: - frandom.write(''.join(chr(t) for t in ctokens)) - else: - frandom.write(bytes([]).join(bytes([t]) for t in ctokens)) - finally: - frandom.close() - except IOError: - # works anyway - pass + # try to add process-specific entropy + frandom = open('/dev/urandom', 'wb') + try: + if PY2: + frandom.write(''.join(chr(t) for t in ctokens)) + else: + frandom.write(bytes([]).join(bytes([t]) for t in ctokens)) + finally: + frandom.close() + except IOError: + # works anyway + pass except NotImplementedError: have_urandom = False logger.warning( From b6e5e165265b708d58d03ddbb3d34b01602867b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kristj=C3=A1n=20Valur=20J=C3=B3nsson?= Date: Wed, 25 Jan 2017 20:10:03 +0000 Subject: [PATCH 2/2] Update compileapp.py The "current" may have been altered by the controller. This is the case for admin/controllers/shell.py, in callback(), where a new shell environment is created (from gluon/shell) If this happens, the incorrect "response" is being referenced and the output of the controller is lost. --- gluon/compileapp.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gluon/compileapp.py b/gluon/compileapp.py index 03529434..69a29068 100644 --- a/gluon/compileapp.py +++ b/gluon/compileapp.py @@ -640,7 +640,7 @@ def run_controller_in(controller, function, environment): ccode = getcfs(layer, filename, lambda: compile2(code, layer)) restricted(ccode, environment, layer=filename) - response = current.response + response = environment["response"] vars = response._vars if response.postprocessing: vars = reduce(lambda vars, p: p(vars), response.postprocessing, vars)