From bdce93784ad0acf5ba607e074b0988a91facad72 Mon Sep 17 00:00:00 2001 From: Aren Sandersen Date: Tue, 13 Sep 2016 13:52:17 -0700 Subject: [PATCH] sys.argv does not exist in some environments where the Python interpreter is embedded. --- rollbar/__init__.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/rollbar/__init__.py b/rollbar/__init__.py index 0c439d8e..a2231a86 100644 --- a/rollbar/__init__.py +++ b/rollbar/__init__.py @@ -1056,10 +1056,14 @@ def _build_server_data(): # server environment server_data = { 'host': socket.gethostname(), - 'argv': sys.argv, 'pid': os.getpid() } + # argv does not always exist in embedded python environments + argv = getattr(sys, 'argv', None) + if argv: + server_data['argv'] = argv + for key in ['branch', 'root']: if SETTINGS.get(key): server_data[key] = SETTINGS[key]