summary refs log tree commit diff
diff options
context:
space:
mode:
authorErik Johnston <erik@matrix.org>2018-01-12 14:44:02 +0000
committerErik Johnston <erik@matrix.org>2018-01-12 14:44:02 +0000
commite21370ba54607c9eb78869bc7ce5ab3d6f896fdd (patch)
treef71f69a44de58e188f2d331941ef6b0531d2e366
parentMake Responder a context manager (diff)
downloadsynapse-e21370ba54607c9eb78869bc7ce5ab3d6f896fdd.tar.xz
Correctly reraise exception
-rw-r--r--synapse/rest/media/v1/media_storage.py6
1 files changed, 4 insertions, 2 deletions
diff --git a/synapse/rest/media/v1/media_storage.py b/synapse/rest/media/v1/media_storage.py
index b6e7a19e12..001e84578e 100644
--- a/synapse/rest/media/v1/media_storage.py
+++ b/synapse/rest/media/v1/media_storage.py
@@ -24,6 +24,7 @@ import contextlib
 import os
 import logging
 import shutil
+import sys
 
 logger = logging.getLogger(__name__)
 
@@ -114,12 +115,13 @@ class MediaStorage(object):
         try:
             with open(fname, "wb") as f:
                 yield f, fname, finish
-        except Exception as e:
+        except Exception:
+            t, v, tb = sys.exc_info()
             try:
                 os.remove(fname)
             except Exception:
                 pass
-            raise e
+            raise t, v, tb
 
         if not finished_called:
             raise Exception("Finished callback not called")