Skip to content

Commit

Permalink
Do not rely on str method for value.
Browse files Browse the repository at this point in the history
  • Loading branch information
mcmtroffaes committed Dec 16, 2024
1 parent 3aabcf1 commit e5d3ebb
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion cython/mytype_gmp.pxi
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,6 @@ cdef _set_mytype(mytype target, value):
mpq_set_si(target, value.numerator, value.denominator)
except OverflowError:
# in case of overflow, set it using mpq_set_str
buf = str(value).encode('ascii')
buf = str(f"{value.numerator}/{value.denominator}").encode('ascii')
if mpq_set_str(target, buf, 10) == -1:
raise ValueError('could not convert %s to mpq_t' % value)

0 comments on commit e5d3ebb

Please sign in to comment.