Skip to content

Commit

Permalink
Last detail to make PyCtxt save/load work
Browse files Browse the repository at this point in the history
  • Loading branch information
ibarrond committed Oct 1, 2020
1 parent 0feffbf commit 73434f1
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 13 deletions.
24 changes: 15 additions & 9 deletions Pyfhel/PyCtxt.cpp

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Pyfhel/PyCtxt.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ cdef class PyCtxt:
self._ptr_ctxt.load(deref(inputter))
finally:
del inputter
self._encoding = to_ENCODING_t(encoding)
self._encoding = to_ENCODING_t(encoding).value

cpdef void from_bytes(self, bytes content, encoding) except +:
"""from_bytes(bytes content)
Expand All @@ -172,7 +172,7 @@ cdef class PyCtxt:
cdef stringstream inputter
inputter.write(content,len(content))
self._ptr_ctxt.load(inputter)
self._encoding = to_ENCODING_t(encoding)
self._encoding = to_ENCODING_t(encoding).value


# =========================================================================
Expand Down
4 changes: 2 additions & 2 deletions Pyfhel/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,10 @@ def test_PyPtxt_creation_deletion(self):
def test_PyCtxt_creation_deletion(self):
try:
ctxt = PyCtxt()
ctxt2 = PyCtxt(other_ctxt=ctxt)
ctxt2 = PyCtxt(copy_ctxt=ctxt)
pyfhel = Pyfhel()
ctxt3 = PyCtxt(pyfhel=pyfhel)
ctxt4 = PyCtxt(other_ctxt=ctxt3)
ctxt4 = PyCtxt(copy_ctxt=ctxt3)
except Exception as err:
self.fail("PyCtxt() creation failed unexpectedly: ", err)
self.assertEqual(ctxt.size(), 2)
Expand Down

0 comments on commit 73434f1

Please sign in to comment.