mirror of
https://github.com/Mikaela/Limnoria.git
synced 2025-01-20 09:04:36 +01:00
Better error reporting.
This commit is contained in:
parent
0768ce1c85
commit
8a53eab39d
@ -471,10 +471,10 @@ def safeEval(s, namespace={'True': True, 'False': False, 'None': None}):
|
|||||||
if node.__class__ is compiler.ast.Module:
|
if node.__class__ is compiler.ast.Module:
|
||||||
return node.doc
|
return node.doc
|
||||||
else:
|
else:
|
||||||
raise ValueError, 'Unsafe string.'
|
raise ValueError, 'Unsafe string: %r' % s
|
||||||
node = nodes[0]
|
node = nodes[0]
|
||||||
if node.__class__ is not compiler.ast.Discard:
|
if node.__class__ is not compiler.ast.Discard:
|
||||||
raise ValueError, 'Invalid expression: %s'
|
raise ValueError, 'Invalid expression: %r' % s
|
||||||
node = node.getChildNodes()[0]
|
node = node.getChildNodes()[0]
|
||||||
def checkNode(node):
|
def checkNode(node):
|
||||||
if node.__class__ is compiler.ast.Const:
|
if node.__class__ is compiler.ast.Const:
|
||||||
@ -493,7 +493,7 @@ def safeEval(s, namespace={'True': True, 'False': False, 'None': None}):
|
|||||||
if checkNode(node):
|
if checkNode(node):
|
||||||
return eval(s, namespace, namespace)
|
return eval(s, namespace, namespace)
|
||||||
else:
|
else:
|
||||||
raise ValueError, 'Unsafe string.'
|
raise ValueError, 'Unsafe string: %r' % s
|
||||||
|
|
||||||
def exnToString(e):
|
def exnToString(e):
|
||||||
"""Turns a simple exception instance into a string (better than str(e))"""
|
"""Turns a simple exception instance into a string (better than str(e))"""
|
||||||
|
Loading…
Reference in New Issue
Block a user