Serhiy Storchaka <storchaka+cpyt...@gmail.com> added the comment:

This is a documented behavior. If OSError is called with a single argument, it 
is interpreted as the error message (as in most other exceptions). But if it is 
called with 2 to 5 arguments, the first argument is interpreted as the errno.

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

>>> ValueError('Invalid command')
ValueError('Invalid command')
>>> str(ValueError('Invalid command'))
'Invalid command'
>>> OSError('Invalid command')
OSError('Invalid command')
>>> str(OSError('Invalid command'))
'Invalid command'
>>> import errno
>>> OSError(errno.EBADF, 'Invalid command')
OSError(9, 'Invalid command')
>>> str(OSError(errno.EBADF, 'Invalid command'))
'[Errno 9] Invalid command'

----------
nosy: +serhiy.storchaka

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue33653>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to