From 6aadd677946177cb623744f23c25d99568025dde Mon Sep 17 00:00:00 2001 From: fundead Date: Mon, 16 Jan 2017 09:48:19 +1300 Subject: [PATCH 1/6] Fix django unit test --- python2/tests/middleware/test_django.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python2/tests/middleware/test_django.py b/python2/tests/middleware/test_django.py index b23bd76..cd424c5 100644 --- a/python2/tests/middleware/test_django.py +++ b/python2/tests/middleware/test_django.py @@ -5,7 +5,7 @@ from django.test import SimpleTestCase from raygun4py.middleware.django import Provider -settings.configure(DEBUG=True, RAYGUN4PY_API_KEY='foo') +settings.configure(DEBUG=True, RAYGUN4PY_API_KEY='foo', ALLOWED_HOSTS=['testserver']) django.setup() From 894b1d9540b830a163e9c59be428218864ab09fc Mon Sep 17 00:00:00 2001 From: fundead Date: Mon, 16 Jan 2017 09:51:36 +1300 Subject: [PATCH 2/6] Port django fix to py3 --- python3/tests/middleware/test_django.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python3/tests/middleware/test_django.py b/python3/tests/middleware/test_django.py index b23bd76..cd424c5 100644 --- a/python3/tests/middleware/test_django.py +++ b/python3/tests/middleware/test_django.py @@ -5,7 +5,7 @@ from django.test import SimpleTestCase from raygun4py.middleware.django import Provider -settings.configure(DEBUG=True, RAYGUN4PY_API_KEY='foo') +settings.configure(DEBUG=True, RAYGUN4PY_API_KEY='foo', ALLOWED_HOSTS=['testserver']) django.setup() From fe2b9a981d06b2181371e95afe3467e96a698807 Mon Sep 17 00:00:00 2001 From: Tobias Fielitz Date: Wed, 11 Jan 2017 14:51:36 +1100 Subject: [PATCH 3/6] frame_is_a_dict: python is not JS --- python2/raygun4py/raygunmsgs.py | 4 ++-- python3/raygun4py/raygunmsgs.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/python2/raygun4py/raygunmsgs.py b/python2/raygun4py/raygunmsgs.py index e576368..3925500 100644 --- a/python2/raygun4py/raygunmsgs.py +++ b/python2/raygun4py/raygunmsgs.py @@ -172,7 +172,7 @@ def __init__(self, exc_type, exc_value, exc_traceback, options): except Exception as e: for frame in self.stackTrace: if 'localVariables' in frame: - frame.localVariables = None + frame['localVariables'] = None def get_classname(self): return self.className @@ -195,4 +195,4 @@ def _get_locals(self, frame): except Exception as re: r = "Couldn't convert to repr due to {0}".format(re) result[key] = "!!! Couldn't convert {0!r} (repr: {1}) due to {2!r} !!!".format(key, r, e) - return result \ No newline at end of file + return result diff --git a/python3/raygun4py/raygunmsgs.py b/python3/raygun4py/raygunmsgs.py index 6074e38..057e123 100644 --- a/python3/raygun4py/raygunmsgs.py +++ b/python3/raygun4py/raygunmsgs.py @@ -183,7 +183,7 @@ def __init__(self, exc_type, exc_value, exc_traceback, options): except Exception as e: for frame in self.stackTrace: if 'localVariables' in frame: - frame.localVariables = None + frame['localVariables'] = None def get_classname(self): return self.className @@ -203,4 +203,4 @@ def _get_locals(self, frame): except Exception as re: r = "Couldn't convert to repr due to {0}".format(re) result[key] = "!!! Couldn't convert {0!r} (repr: {1}) due to {2!r} !!!".format(key, r, e) - return result \ No newline at end of file + return result From 323fcf7b9f6d2cfd4689af2900c78d8faa3e02a0 Mon Sep 17 00:00:00 2001 From: Tobias Fielitz Date: Wed, 11 Jan 2017 14:47:17 +1100 Subject: [PATCH 4/6] new_style_classes: new style classes --- python2/raygun4py/raygunmsgs.py | 6 +++--- python3/raygun4py/raygunmsgs.py | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/python2/raygun4py/raygunmsgs.py b/python2/raygun4py/raygunmsgs.py index 3925500..71257ac 100644 --- a/python2/raygun4py/raygunmsgs.py +++ b/python2/raygun4py/raygunmsgs.py @@ -13,7 +13,7 @@ from datetime import datetime -class RaygunMessageBuilder: +class RaygunMessageBuilder(object): def __init__(self): self.raygunMessage = RaygunMessage() @@ -117,7 +117,7 @@ def set_user(self, user): return self -class RaygunMessage: +class RaygunMessage(object): def __init__(self): self.occurredOn = datetime.utcnow() @@ -130,7 +130,7 @@ def get_details(self): return self.details -class RaygunErrorMessage: +class RaygunErrorMessage(object): def __init__(self, exc_type, exc_value, exc_traceback, options): self.className = exc_type.__name__ diff --git a/python3/raygun4py/raygunmsgs.py b/python3/raygun4py/raygunmsgs.py index 057e123..0e44699 100644 --- a/python3/raygun4py/raygunmsgs.py +++ b/python3/raygun4py/raygunmsgs.py @@ -13,7 +13,7 @@ from datetime import datetime -class RaygunMessageBuilder: +class RaygunMessageBuilder(object): def __init__(self): self.raygunMessage = RaygunMessage() @@ -117,7 +117,7 @@ def set_user(self, user): return self -class RaygunMessage: +class RaygunMessage(object): def __init__(self): self.occurredOn = datetime.utcnow() @@ -130,7 +130,7 @@ def get_details(self): return self.details -class RaygunErrorMessage: +class RaygunErrorMessage(object): def __init__(self, exc_type, exc_value, exc_traceback, options): self.className = exc_type.__name__ From 5b59888ed2a34ef28d1750568f4943287793b773 Mon Sep 17 00:00:00 2001 From: fundead Date: Mon, 16 Jan 2017 11:40:47 +1300 Subject: [PATCH 5/6] Add safe dict access for environ fields in wsgi middleware with get; py2/3; fixes #46 --- python2/raygun4py/middleware/wsgi.py | 14 +++++++++----- python3/raygun4py/middleware/wsgi.py | 14 +++++++++----- 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/python2/raygun4py/middleware/wsgi.py b/python2/raygun4py/middleware/wsgi.py index 98952ef..c6c9787 100644 --- a/python2/raygun4py/middleware/wsgi.py +++ b/python2/raygun4py/middleware/wsgi.py @@ -40,13 +40,17 @@ def __call__(self, environ, start_response): def build_request(self, environ): request = {} + http_host = environ.get('HTTP_HOST'], None) + if http_host is not None: + http_host = http_host.replace(' ', '') + try: request = { - 'httpMethod': environ['REQUEST_METHOD'], - 'url': environ['PATH_INFO'], - 'ipAddress': environ['REMOTE_ADDR'], - 'hostName': environ['HTTP_HOST'].replace(' ', ''), - 'queryString': environ['QUERY_STRING'], + 'httpMethod': environ.get('REQUEST_METHOD', None), + 'url': environ.get('PATH_INFO', None), + 'ipAddress': environ.get('REMOTE_ADDR', None), + 'hostName': http_host + 'queryString': environ.get('QUERY_STRING', None), 'headers': {}, 'form': {}, 'rawData': {} diff --git a/python3/raygun4py/middleware/wsgi.py b/python3/raygun4py/middleware/wsgi.py index 9f534e5..3ca4e74 100644 --- a/python3/raygun4py/middleware/wsgi.py +++ b/python3/raygun4py/middleware/wsgi.py @@ -38,13 +38,17 @@ def __call__(self, environ, start_response): def build_request(self, environ): request = {} + http_host = environ.get('HTTP_HOST'], None) + if http_host is not None: + http_host = http_host.replace(' ', '') + try: request = { - 'httpMethod': environ['REQUEST_METHOD'], - 'url': environ['PATH_INFO'], - 'ipAddress': environ['REMOTE_ADDR'], - 'hostName': environ['HTTP_HOST'].replace(' ', ''), - 'queryString': environ['QUERY_STRING'], + 'httpMethod': environ.get('REQUEST_METHOD', None), + 'url': environ.get('PATH_INFO', None), + 'ipAddress': environ.get('REMOTE_ADDR', None), + 'hostName': http_host + 'queryString': environ.get('QUERY_STRING', None), 'headers': {}, 'form': {}, 'rawData': {} From bd38695c592c275717c61ed6ccfa6ccc8872cc92 Mon Sep 17 00:00:00 2001 From: fundead Date: Mon, 16 Jan 2017 12:05:45 +1300 Subject: [PATCH 6/6] Changelog/version bump --- CHANGELOG.rst | 4 ++++ setup.py | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index e3f32a8..3f6cd33 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -1,3 +1,7 @@ +3.1.4 + +- Fix runtime bugs involving the WSGI pipeline, a local variable accessor edge case, and a pickling old-style classes exception + 3.1.3 - Guard against environment variable access exceptions as seen in Google App Engine, gevent and Jython 2.6 diff --git a/setup.py b/setup.py index 6104ceb..7ed3a71 100644 --- a/setup.py +++ b/setup.py @@ -10,7 +10,7 @@ setup( name='raygun4py', - version='3.1.3', + version='3.1.4', packages=packages, package_dir= { "raygun4py": base_dir + "/raygun4py"