Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions OpenSSL/_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ def text(charp):

:return: :class:`str`
"""
if not charp:
return ""
return native(ffi.string(charp))


Expand Down
17 changes: 17 additions & 0 deletions OpenSSL/test/test_util.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
from OpenSSL._util import exception_from_error_queue, lib
from OpenSSL.test.util import TestCase



class ErrorTests(TestCase):
"""
Tests for handling of certain OpenSSL error cases.
"""
def test_exception_from_error_queue_nonexistent_reason(self):
"""
:py:func:`exception_from_error_queue` raises ``ValueError`` when it
encounters an OpenSSL error code which does not have a reason string.
"""
lib.ERR_put_error(lib.ERR_LIB_EVP, 0, 1112, b"", 10)
exc = self.assertRaises(ValueError, exception_from_error_queue, ValueError)
self.assertEqual(exc.args[0][0][2], "")