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
cf431b57
Commit
cf431b57
authored
Dec 28, 2016
by
Dylan Trotter
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove exception restore logic from Block objects.
parent
b2e82999
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
35 additions
and
42 deletions
+35
-42
runtime/block.go
runtime/block.go
+2
-9
runtime/block_test.go
runtime/block_test.go
+0
-33
runtime/code_test.go
runtime/code_test.go
+33
-0
No files found.
runtime/block.go
View file @
cf431b57
...
...
@@ -37,18 +37,11 @@ func (b *Block) Exec(f *Frame, globals *Dict) (*Object, *BaseException) {
}
func
(
b
*
Block
)
execInternal
(
f
*
Frame
,
sendValue
*
Object
)
(
*
Object
,
*
BaseException
)
{
oldExc
,
oldTraceback
:=
f
.
ExcInfo
()
// Re-enter function body while we have checkpoint handlers left.
for
{
ret
,
raised
:=
b
.
fn
(
f
,
sendValue
)
if
raised
==
nil
{
// Restore exc_info to what it was when we left
// the previous frame.
f
.
RestoreExc
(
oldExc
,
oldTraceback
)
return
ret
,
nil
}
if
len
(
f
.
checkpoints
)
==
0
{
return
nil
,
raised
if
raised
==
nil
||
len
(
f
.
checkpoints
)
==
0
{
return
ret
,
raised
}
f
.
state
=
f
.
PopCheckpoint
()
}
...
...
runtime/block_test.go
View file @
cf431b57
...
...
@@ -79,36 +79,3 @@ func TestBlockExecRaises(t *testing.T) {
t
.
Errorf
(
"exception traceback was %+v, want %+v"
,
tb
,
wantTraceback
)
}
}
func
TestBlockExecRestoreExc
(
t
*
testing
.
T
)
{
e
:=
mustCreateException
(
RuntimeErrorType
,
"uh oh"
)
ranB1
,
ranB2
:=
false
,
false
globals
:=
NewDict
()
b1
:=
NewBlock
(
"<b1>"
,
"foo.py"
,
func
(
f
*
Frame
,
_
*
Object
)
(
*
Object
,
*
BaseException
)
{
if
got
,
_
:=
f
.
ExcInfo
();
got
!=
e
{
t
.
Errorf
(
"ExcInfo() = %v, want %v"
,
got
,
e
)
}
f
.
RestoreExc
(
nil
,
nil
)
ranB1
=
true
return
None
,
nil
})
b2
:=
NewBlock
(
"<b2>"
,
"foo.py"
,
func
(
f
*
Frame
,
_
*
Object
)
(
*
Object
,
*
BaseException
)
{
f
.
RestoreExc
(
e
,
newTraceback
(
f
,
nil
))
b1
.
Exec
(
f
,
globals
)
// The exception was cleared by b1 but when returning to b2, it
// should have been restored.
if
got
,
_
:=
f
.
ExcInfo
();
got
!=
e
{
t
.
Errorf
(
"ExcInfo() = %v, want <nil>"
,
got
)
}
f
.
RestoreExc
(
nil
,
nil
)
ranB2
=
true
return
None
,
nil
})
b2
.
Exec
(
newFrame
(
nil
),
globals
)
if
!
ranB1
{
t
.
Error
(
"b1 did not run"
)
}
if
!
ranB2
{
t
.
Error
(
"b2 did not run"
)
}
}
runtime/code_test.go
View file @
cf431b57
...
...
@@ -56,3 +56,36 @@ func TestNewCode(t *testing.T) {
}
}
}
func
TestCodeEvalRestoreExc
(
t
*
testing
.
T
)
{
e
:=
mustCreateException
(
RuntimeErrorType
,
"uh oh"
)
ranC1
,
ranC2
:=
false
,
false
globals
:=
NewDict
()
c1
:=
NewCode
(
"<c1>"
,
"foo.py"
,
nil
,
0
,
func
(
f
*
Frame
,
_
[]
*
Object
)
(
*
Object
,
*
BaseException
)
{
if
got
,
_
:=
f
.
ExcInfo
();
got
!=
e
{
t
.
Errorf
(
"ExcInfo() = %v, want %v"
,
got
,
e
)
}
f
.
RestoreExc
(
nil
,
nil
)
ranC1
=
true
return
None
,
nil
})
c2
:=
NewCode
(
"<c2>"
,
"foo.py"
,
nil
,
0
,
func
(
f
*
Frame
,
_
[]
*
Object
)
(
*
Object
,
*
BaseException
)
{
f
.
RestoreExc
(
e
,
newTraceback
(
f
,
nil
))
c1
.
Eval
(
f
,
globals
,
nil
,
nil
)
// The exception was cleared by c1 but when returning to c2, it
// should have been restored.
if
got
,
_
:=
f
.
ExcInfo
();
got
!=
e
{
t
.
Errorf
(
"ExcInfo() = %v, want <nil>"
,
got
)
}
f
.
RestoreExc
(
nil
,
nil
)
ranC2
=
true
return
None
,
nil
})
c2
.
Eval
(
newFrame
(
nil
),
globals
,
nil
,
nil
)
if
!
ranC1
{
t
.
Error
(
"c1 did not run"
)
}
if
!
ranC2
{
t
.
Error
(
"c2 did not run"
)
}
}
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