When you call
popt_bad, _ = curve_fit
The _
means that you're completely disregarding the covariance matrices, which is the primary mechanism of assessing the success of the fit.
curve_fit always returns a value, even if it hasn't found a good value. You need a step which looks at this part of the return value and decides whether to trust the popt (at least check it isn't infinite).