Merge pull request #1748 from youknowone/syntax-error

Fix SyntaxError initial value
This commit is contained in:
Jeong YunWon
2020-02-06 18:59:27 +09:00
committed by GitHub
2 changed files with 13 additions and 0 deletions

View File

@@ -65,3 +65,11 @@ try:
raise NewException("test")
except NewException as e:
assert e.value == "test"
exc = SyntaxError('msg', 1, 2, 3, 4, 5)
assert exc.msg == 'msg'
assert exc.filename is None
assert exc.lineno is None
assert exc.offset is None
assert exc.text is None

View File

@@ -645,6 +645,11 @@ pub fn init(ctx: &PyContext) {
extend_class!(ctx, &excs.syntax_error, {
"msg" => ctx.new_readonly_getset("msg", make_arg_getter(0)),
// TODO: members
"filename" => ctx.none(),
"lineno" => ctx.none(),
"offset" => ctx.none(),
"text" => ctx.none(),
});
extend_class!(ctx, &excs.import_error, {