R.O.S.S
R.O.S.S

Reputation: 625

Strange exception behaviour

I want to implement an exception displayer and it doesn't work, but I have something different:

Traceback (most recent call last):
    File "/Users/honzik/PycharmProjects/Toy/test.py", line 21, in main
    raise IOError('Foo bar bazooka!')
OSError: Foo bar bazooka!

How can be raised an OSError when I specified IOError?

Upvotes: 2

Views: 71

Answers (1)

dlask
dlask

Reputation: 8992

IOError is only an alias for OSError in Python3, see https://docs.python.org/3/library/exceptions.html#concrete-exceptions:

Changed in version 3.3: EnvironmentError, IOError, WindowsError, VMSError, socket.error, select.error and mmap.error have been merged into OSError, and the constructor may return a subclass.

Upvotes: 5

Related Questions