# Buggy code
def raise_if_problem(self, exceptionType=Error):
    try:
        _exception_from_error_queue(exceptionType)
    except exceptionType as e:
        from_queue = e
    if self._problems:
        raise self._problems[0]
    return from_queue


# Traceback (OpenSSL.crypto.Error)
/usr/local/Cellar/python/2.7.6/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/twisted/spread/jelly.py:93: DeprecationWarning: the sets module is deprecated
import sets as _sets
/usr/local/Cellar/python/2.7.6/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/twisted/internet/endpoints.py:30: DeprecationWarning: twisted.internet.interfaces.IStreamClientEndpointStringParser was deprecated in Twisted 14.0.0: This interface has been superseded by IStreamClientEndpointStringParserWithReactor.
from twisted.internet.interfaces import (
Traceback (most recent call last):
File "/usr/local/bin/twistd", line 14, in <module>
run()
File "/usr/local/Cellar/python/2.7.6/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/twisted/scripts/twistd.py", line 27, in run
app.run(runApp, ServerOptions)
File "/usr/local/Cellar/python/2.7.6/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/twisted/application/app.py", line 642, in run
runApp(config)
File "/usr/local/Cellar/python/2.7.6/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/twisted/scripts/twistd.py", line 23, in runApp
_SomeApplicationRunner(config).run()
File "/usr/local/Cellar/python/2.7.6/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/twisted/application/app.py", line 376, in run
self.application = self.createOrGetApplication()
File "/usr/local/Cellar/python/2.7.6/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/twisted/application/app.py", line 436, in createOrGetApplication
ser = plg.makeService(self.config.subOptions)
File "/usr/local/Cellar/python/2.7.6/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/twisted/web/tap.py", line 230, in makeService
strports.service(config['port'], site).setServiceParent(s)
File "/usr/local/Cellar/python/2.7.6/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/twisted/application/strports.py", line 77, in service
endpoints._serverFromStringLegacy(reactor, description, default),
File "/usr/local/Cellar/python/2.7.6/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/twisted/internet/endpoints.py", line 1407, in _serverFromStringLegacy
nameOrPlugin, args, kw = _parseServer(description, None, default)
File "/usr/local/Cellar/python/2.7.6/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/twisted/internet/endpoints.py", line 1398, in _parseServer
return (endpointType.upper(),) + parser(factory, *args[1:], **kw)
File "/usr/local/Cellar/python/2.7.6/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/twisted/internet/endpoints.py", line 1118, in _parseSSL
privateCertificate = ssl.PrivateCertificate.loadPEM(certPEM + keyPEM)
File "/usr/local/Cellar/python/2.7.6/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/twisted/internet/_sslverify.py", line 619, in loadPEM
return Class.load(data, KeyPair.load(data, crypto.FILETYPE_PEM),
File "/usr/local/Cellar/python/2.7.6/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/twisted/internet/_sslverify.py", line 725, in load
return Class(crypto.load_privatekey(format, data))
File "/usr/local/Cellar/python/2.7.6/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/OpenSSL/crypto.py", line 2010, in load_privatekey
_raise_current_error()
File "/usr/local/Cellar/python/2.7.6/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/OpenSSL/_util.py", line 22, in exception_from_error_queue
raise exceptionType(errors)
OpenSSL.crypto.Error: []

# Fixed code
def raise_if_problem(self, exceptionType=Error):
    if self._problems:
        # Flush the OpenSSL error queue
        try:
            _exception_from_error_queue(exceptionType)
        except exceptionType:
            pass

        raise self._problems.pop(0)