Skip to content
Browse files

Raise full Python errors in Rubyland

  • Loading branch information...
1 parent 410b981 commit 1d575a76203d75c96c30c2e0aead570ed3f90002 @tnm committed Jul 10, 2012
Showing with 12 additions and 3 deletions.
  1. +9 −2 lib/pygments/mentos.py
  2. +3 −1 lib/pygments/popen.rb
View
11 lib/pygments/mentos.py
@@ -23,6 +23,12 @@ def _convert_keys(dictionary):
return dict((str(k), _convert_keys(v))
for k, v in dictionary.items())
+def _write_error(error):
+ res = {"error": error}
+ out_header = json.dumps(res).encode('utf-8')
+ print out_header
+ return
+
def _signal_handler(signal, frame):
"""
Handle the signal given in the first argument, exiting gracefully
@@ -200,8 +206,9 @@ def start(self):
header = json.loads(line)
except:
header = None
+ _write_error("Bad header/no data")
- if header != None:
+ if header:
try:
method = header["method"]
@@ -225,7 +232,7 @@ def start(self):
except:
tb = traceback.format_exc()
- res = {"error": tb}
+ _write_error(tb)
# We return a header back to Rubyland also. If we don't have a result,
# we need to send back some 'error json' in the header.
View
4 lib/pygments/popen.rb
@@ -227,12 +227,14 @@ def mentos(method, args=[], kwargs={}, code=nil)
if header
# The header comes in as JSON
+ f = File.open('log0', 'a')
+ f.write(header + "\n")
header = Yajl.load(header)
-
bytes = header["bytes"]
# Check if the header indicates an error
if header["error"]
+ f.write("an error")
# Raise this as a Ruby exception of the MentosError class.
# Pythonland will return a traceback, or at least some information
# about the error, in the error key.

0 comments on commit 1d575a7

Please sign in to comment.
Something went wrong with that request. Please try again.