Skip to content

Commit

Permalink
Drop special macOS handling for output streams
Browse files Browse the repository at this point in the history
we had something somewhat similar in e-antic where we strangely needed
to add an explicit ends() to prevent a segfault. However, str() should
create a copy of the string buffer so there should not be any issues
here. (And I don't understand anymore why the problem was fixed by the
ends in e-antic.)
  • Loading branch information
saraedum committed Dec 28, 2023
1 parent 01d38e6 commit eb5d7a8
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 13 deletions.
9 changes: 2 additions & 7 deletions pyexactreal/src/pyexactreal/cppyy_exactreal.py
Original file line number Diff line number Diff line change
Expand Up @@ -381,15 +381,10 @@ def __repr__(self):
term<exactreal::Arb ... &>[=1.00000]
"""
# With cppyy 2.4.2 from conda-forge, the YAP printing below sometimes
# segfaults on macOS. We therefore disable a test for it, see arf.py.
import cppyy
cppyy.include("boost/yap/print.hpp")
os = cppyy.gbl.std.stringstream()
try:
cppyy.gbl.boost.yap.print(os, self.value)
except:
return repr(self.value)
os = cppyy.gbl.std.ostringstream()
cppyy.gbl.boost.yap.print(os, self.value)
return os.str().strip()

def makeModule(traits, gens, ring=None):
Expand Down
8 changes: 2 additions & 6 deletions pyexactreal/test/arf.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,8 @@ def test_arithmetic():
a = Arf(1)
b = Arf(2)

# The following test segfaults on macOS with cppyy 2.4.2 (we don't
# understand why at the moment so we disable the test.)
import platform
if platform.system() != "Darwin":
# Expressions do not get evaluated without specifying a precision/rounding
assert str(a + a).startswith("expr<+>")
# Expressions do not get evaluated without specifying a precision/rounding
assert str(a + a).startswith("expr<+>")

assert (a + a)(64, Arf.Round.DOWN) == b

Expand Down

0 comments on commit eb5d7a8

Please sign in to comment.