Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(150)

Issue 4640043: code review 4640043: fmt: catch panics from calls to String etc. (Closed)

Can't Edit
Can't Publish+Mail
Start Review
Created:
14 years ago by r
Modified:
14 years ago
Reviewers:
CC:
dsymonds, r2, adg, gri, rsc, gri1, golang-dev
Visibility:
Public.

Description

fmt: catch panics from calls to String etc. This change causes Print et al. to catch panics generated by calls to String, GoString, and Format. The panic is formatted into the output stream as an error, but the program continues. As a special case, if the argument was a nil pointer, the result is just "<nil>", because that's almost certainly enough information and handles the very common case of String methods that don't guard against nil. Scan does not want this change. Input must work; output can be for debugging and it's nice to get output even when you make a mistake.

Patch Set 1 #

Total comments: 1

Patch Set 2 : diff -r 6c1b861053e0 https://go.googlecode.com/hg/ #

Patch Set 3 : diff -r 6c1b861053e0 https://go.googlecode.com/hg/ #

Total comments: 4

Patch Set 4 : diff -r 40a281c810e2 https://go.googlecode.com/hg/ #

Patch Set 5 : diff -r 40a281c810e2 https://go.googlecode.com/hg/ #

Total comments: 1

Patch Set 6 : diff -r 4d510d32c397 https://go.googlecode.com/hg/ #

Unified diffs Side-by-side diffs Delta from patch set Stats (+88 lines, -4 lines) Patch
M src/pkg/fmt/fmt_test.go View 1 2 3 1 chunk +53 lines, -0 lines 0 comments Download
M src/pkg/fmt/print.go View 1 2 3 4 5 7 chunks +35 lines, -4 lines 0 comments Download

Messages

Total messages: 15
r
Hello golang-dev@googlegroups.com, I'd like you to review this change to https://go.googlecode.com/hg/
14 years ago (2011-06-17 04:24:14 UTC) #1
dsymonds
LGTM Works for me.
14 years ago (2011-06-17 04:39:24 UTC) #2
r2
On 17/06/2011, at 2:39 PM, David Symonds wrote: > LGTM > > Works for me. ...
14 years ago (2011-06-17 10:20:57 UTC) #3
adg
On 17 June 2011 20:20, Rob 'Commander' Pike <r@google.com> wrote: > You're not a stern ...
14 years ago (2011-06-17 13:25:22 UTC) #4
gri
I think this looks good, pending tests and documentation updates (if necessary). So if I ...
14 years ago (2011-06-17 16:24:34 UTC) #5
rsc
LGTM s/v.Type().Kind()/v.Kind()/
14 years ago (2011-06-17 16:44:12 UTC) #6
gri
I tried this out with a slightly modified example (division by 0 in String()), for ...
14 years ago (2011-06-17 17:00:05 UTC) #7
rsc
fmt's job is to print. We already squash all kinds of other errors too. I ...
14 years ago (2011-06-17 17:23:05 UTC) #8
r2
right. that's what i decided after mulling it over yesterday. the UI is that fmt ...
14 years ago (2011-06-17 22:03:41 UTC) #9
r
Hello golang-dev@googlegroups.com, dsymonds@golang.org, r@google.com, adg@golang.org, gri@golang.org, rsc@golang.org (cc: golang-dev@googlegroups.com), Please take another look.
14 years ago (2011-06-17 23:04:12 UTC) #10
r2
can someone review this please? -rob
14 years ago (2011-06-20 21:27:18 UTC) #11
gri1
I'm ok with the idea. http://codereview.appspot.com/4640043/diff/14001/src/pkg/fmt/fmt_test.go File src/pkg/fmt/fmt_test.go (right): http://codereview.appspot.com/4640043/diff/14001/src/pkg/fmt/fmt_test.go#newcode692 src/pkg/fmt/fmt_test.go:692: var _ Stringer = ...
14 years ago (2011-06-20 21:42:23 UTC) #12
r
Hello golang-dev@googlegroups.com, dsymonds@golang.org, r@google.com, adg@golang.org, gri@golang.org, rsc@golang.org, gri@google.com (cc: golang-dev@googlegroups.com), Please take another look.
14 years ago (2011-06-20 22:02:33 UTC) #13
rsc
LGTM i think as is if you fmt.Println(d, d) it will only catch the first ...
14 years ago (2011-06-20 22:14:41 UTC) #14
r
14 years ago (2011-06-20 22:31:11 UTC) #15
*** Submitted as http://code.google.com/p/go/source/detail?r=6bf10580414a ***

fmt: catch panics from calls to String etc.

This change causes Print et al. to catch panics generated by
calls to String, GoString, and Format.  The panic is formatted
into the output stream as an error, but the program continues.
As a special case, if the argument was a nil pointer, the
result is just "<nil>", because that's almost certainly enough
information and handles the very common case of String
methods that don't guard against nil.

Scan does not want this change. Input must work; output can
be for debugging and it's nice to get output even when you
make a mistake.

R=dsymonds, r, adg, gri, rsc, gri
CC=golang-dev
http://codereview.appspot.com/4640043
Sign in to reply to this message.

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b