Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
grumpy
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
grumpy
Commits
b2e82999
Commit
b2e82999
authored
Dec 28, 2016
by
Dylan Trotter
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Propagate tracebacks from code objects that raise. Expose some fields to Python.
parent
132d03e9
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
17 additions
and
17 deletions
+17
-17
runtime/block.go
runtime/block.go
+0
-12
runtime/code.go
runtime/code.go
+13
-2
runtime/frame.go
runtime/frame.go
+1
-0
runtime/traceback.go
runtime/traceback.go
+3
-3
No files found.
runtime/block.go
View file @
b2e82999
...
...
@@ -48,18 +48,6 @@ func (b *Block) execInternal(f *Frame, sendValue *Object) (*Object, *BaseExcepti
return
ret
,
nil
}
if
len
(
f
.
checkpoints
)
==
0
{
if
f
.
back
!=
nil
{
e
,
tb
:=
f
.
ExcInfo
()
if
e
!=
raised
{
// This is likely due to a programming
// error. Prefer raised and start
// propagating from here.
tb
=
newTraceback
(
f
,
nil
)
}
else
{
tb
=
newTraceback
(
f
.
back
,
tb
)
}
f
.
RestoreExc
(
raised
,
tb
)
}
return
nil
,
raised
}
f
.
state
=
f
.
PopCheckpoint
()
...
...
runtime/code.go
View file @
b2e82999
...
...
@@ -17,8 +17,8 @@ const (
type
Code
struct
{
Object
name
string
filename
string
name
string
`attr:"co_name"`
filename
string
`attr:"co_filename"`
// argc is the number of positional arguments.
argc
int
`attr:"co_argcount"`
// minArgc is the number of positional non-keyword arguments (i.e. the
...
...
@@ -112,9 +112,20 @@ func (c *Code) Eval(f *Frame, globals *Dict, args Args, kwargs KWArgs) (*Object,
bodyArgs
[
i
]
=
arg
.
Def
}
}
oldExc
,
oldTraceback
:=
f
.
ExcInfo
()
next
:=
newFrame
(
f
)
next
.
code
=
c
next
.
globals
=
globals
ret
,
raised
:=
c
.
fn
(
next
,
bodyArgs
)
f
.
FreeArgs
(
bodyArgs
)
if
raised
==
nil
{
// Restore exc_info to what it was when we left the previous
// frame.
f
.
RestoreExc
(
oldExc
,
oldTraceback
)
}
else
{
_
,
tb
:=
f
.
ExcInfo
()
tb
=
newTraceback
(
f
,
tb
)
f
.
RestoreExc
(
raised
,
tb
)
}
return
ret
,
raised
}
runtime/frame.go
View file @
b2e82999
...
...
@@ -38,6 +38,7 @@ type Frame struct {
state
RunState
globals
*
Dict
`attr:"f_globals"`
lineno
int
`attr:"f_lineno"`
code
*
Code
`attr:"f_code"`
}
// newFrame creates a new Frame whose parent frame is back.
...
...
runtime/traceback.go
View file @
b2e82999
...
...
@@ -21,9 +21,9 @@ import (
// Traceback represents Python 'traceback' objects.
type
Traceback
struct
{
Object
frame
*
Frame
`attr:"tb_frame"`
next
*
Traceback
lineno
int
`attr:"tb_lineno"`
frame
*
Frame
`attr:"tb_frame"`
next
*
Traceback
`attr:"tb_next"`
lineno
int
`attr:"tb_lineno"`
}
func
newTraceback
(
f
*
Frame
,
next
*
Traceback
)
*
Traceback
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment