I have a test program:
from sympy import symbols, Rational
m = symbols('m')
temp = Rational(0)
temp = temp.subs(m, m)
temp = 0
temp = temp.subs(m, m)
#Result in test program:
#'int' object has no attribute 'subs'
#Result in my program:
#UnicodeDecodeError: 'utf-8' codec can't decode byte 0xa7 in position 416: invalid start byte
Of course, subs(m, m) doesn't make sense, but it is a special case that can occur and it was easier to allow it than to construct code to avoid it.
When temp is an integer 0, the error message in the test program is easy for me to understand: 'int' object has no attribute 'subs'
However, for some reason, when exactly the same code runs within my program, the error message caused my real headaches, because it was hard to find our exactly where it was happening: UnicodeDecodeError: 'utf-8' codec can't decode byte 0xa7 in position 416: invalid start byte
Now I can solve the problem easily by using Rational(0). Of course, I could also avoid the subs when the variable is 0, but that would be my second choice.
By the way, I am using Python 3.9 and Sympy 1.9 in Visual Studio 2022 on Windows 10, just in case anyone is interested in trying this out and making a comparison.