New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

error.c: fixed doc regarding the presence of to_str #1517

wants to merge 1 commit into


1 participant

marcgg commented Jan 21, 2017

It seems like the documentation still references an old behavior where Exception would define to_str, which is not the case anymore

2.3.1 :004 > "foo" +"bar")
TypeError: no implicit conversion of Exception into String

Looking at the 1.8.7 documentation in error.c we see the current wording with a definition of exc_to_str:

 * call-seq:
 *   exception.message   =>  string
 *   exception.to_str    =>  string
 * Returns the result of invoking <code>exception.to_s</code>.
 * Normally this returns the exception's message or name. By
 * supplying a to_str method, exceptions are agreeing to
 * be used where Strings are expected.

static VALUE
	VALUE exc;
	return rb_funcall(exc, rb_intern("to_s"), 0, 0);

Nowadays in trunk there is to definition of to_str, but the wording "By supplying a to_str method, exceptions are agreeing to be used where Strings are expected." is still present and used for exc_message.

This PR fixes that.

@hsbt hsbt closed this in 9600fb3 Jan 23, 2017

hsbt pushed a commit that referenced this pull request Mar 11, 2017

merge revision(s) 57405:
	error.c: fixed doc [ci skip]

	* error.c (exc_message): fixed doc regarding the presence of
	  to_str.  [Fix GH-1517]

	Author:    Marc Gauthier <>

git-svn-id: svn+ssh:// b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment