This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author eryksun
Recipients eryksun, giampaolo.rodola, serhiy.storchaka
Date 2018-05-26.17:12:53
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1527354773.07.0.682650639539.issue33653@psf.upfronthosting.co.za>
In-reply-to
Content
This behavior is inherited from BaseException:

https://docs.python.org/3/library/exceptions.html#BaseException

    >>> str(BaseException())
    ''
    >>> str(BaseException('spam'))
    'spam'
    >>> str(BaseException('spam', 'eggs'))
    "('spam', 'eggs')"

Python 2 OSError special cases 2-3 arguments:

    >>> str(OSError(*'123'))
    "[Errno 1] 2: '3'"

    >>> str(OSError(*'1234'))
    "('1', '2', '3', '4')"

Python 3 OSError special cases 2-5 arguments (adding winerror and filename2):

    >>> str(OSError(*'12345'))
    "[Errno 1] 2: '3' -> '5'"

    >>> str(OSError(*'123456'))
    "('1', '2', '3', '4', '5', '6')"

The base behavior is implemented by BaseException_str in Objects/exceptions.c:

    static PyObject *
    BaseException_str(PyBaseExceptionObject *self)
    {
        switch (PyTuple_GET_SIZE(self->args)) {
        case 0:
            return PyUnicode_FromString("");
        case 1:
            return PyObject_Str(PyTuple_GET_ITEM(self->args, 0));
        default:
            return PyObject_Str(self->args);
        }
    }
History
Date User Action Args
2018-05-26 17:12:53eryksunsetrecipients: + eryksun, giampaolo.rodola, serhiy.storchaka
2018-05-26 17:12:53eryksunsetmessageid: <1527354773.07.0.682650639539.issue33653@psf.upfronthosting.co.za>
2018-05-26 17:12:53eryksunlinkissue33653 messages
2018-05-26 17:12:53eryksuncreate