tonysimpson / nanomsg-python

nanomsg wrapper for python with multiple backends (CPython and ctypes) should support 2/3 and Pypy
MIT License
382 stars 85 forks source link

Should use new style exceptions on python > 3.3 #9

Open tailhook opened 10 years ago

tailhook commented 10 years ago

See PEP 3151 for details on exceptions.

In particular it would be nice to raise BlockingIOError and InterruptedError. I'm not sure whether we should subclass them or just use raw built-in classes.

tonysimpson commented 10 years ago

I'm not against this idea. I don't want to do anything yet that would break python2/3 compatibility, maybe backporting the exceptions to 2 would be possible (already done by the "six" package?). My current position is that I like the idea of having a single root exception that can be caught for any nanomsg error, it allows for very simple error handling, perhaps not what you would want to do in critical code but useful at times.

tailhook commented 10 years ago

I believe it may look like:

try:
    base_class = InterrutedError
except NameError:
    base_class = OSError

class NNInterruptedError(BaseNNError, base_class):
    pass

This way it would work in both python versions