homepage

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 martin.panter
Recipients Ben.Darnell, alex, christian.heimes, dstufft, giampaolo.rodola, janssen, martin.panter, pitrou
Date 2015年03月08日.06:24:40
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1425795880.84.0.993763942878.issue23588@psf.upfronthosting.co.za>
In-reply-to
Content
Okay I see your point about backwards compatibility now. Indeed, I have written code myself before Python 3.3 that used to inspect err.args[0], and it would suffer a similar problem if I had not updated it to use the new Python 3.3 exception subclasses.
Below I have written a comparison of two options that have been proposed. Both have disadvantages and would potentially require changes in user code.
A third middle-ground option might be to deprecate OSError.errno as well, and replace it with OSError.posix_errno or something. But I would still prefer the option to stop setting SSLError.errno, even though it breaks backwards compatibility. I think we can at least agree that "errno" and "args" should be deprecated for SSLError instances.
## Option 1: Add OSError.errno_scope ##
To avoid the bug in new Python versions we would still have to modify code handling a general OSError (EnvironmentError), for example:
# Buggy handler compatible with Python 3.2
try:
 return ssl_sock.read()
except EnvironmentError as e:
 if e.errno != errno.EINTR:
 raise
# Fixed handler, supporting new Python versions only
try:
 return ssl_sock.read()
except OSError as e:
 if e.errno_scope != POSIX or e.errno != errno.EINTR:
 raise
Advantages:
* Existing code still works if you don’t care about this bug
* No code changes required in SSL error handlers
## Option 2: Stop setting SSLError.errno ##
Existing SSLError handlers written for Python < 3.3 would stop catching exceptions, because "errno" defaults to None. This would probably cause an unhandled exception, and could be fixed as follows:
# Broken handler written for Python 3.2
try:
 return ssl_sock.read()
except SSLError as e:
 if e.errno != SSL_ERROR_WANT_READ:
 raise
 # Handle non-blocking read
# Fixed handler, supporting Python 3.3+ only
try:
 return ssl_sock.read()
except SSLWantReadError as e:
 # Handle non-blocking read
Advantages:
* Affected code should be easy to find due to breakage
* Only requires the user to change code that directly handles SSL errors
* No changes for code already written for Python 3.3
* Code changes only when relying on the undocumented errno behaviour, which is already asking for trouble
History
Date User Action Args
2015年03月08日 06:24:40martin.pantersetrecipients: + martin.panter, janssen, pitrou, giampaolo.rodola, christian.heimes, alex, Ben.Darnell, dstufft
2015年03月08日 06:24:40martin.pantersetmessageid: <1425795880.84.0.993763942878.issue23588@psf.upfronthosting.co.za>
2015年03月08日 06:24:40martin.panterlinkissue23588 messages
2015年03月08日 06:24:40martin.pantercreate

AltStyle によって変換されたページ (->オリジナル) /