In attempt to evaluate $$\text P\int^\infty_{-\infty}\frac1{x^2}dx$$ we consider $$\oint_C\frac{1}{z^2}dz$$ where $C$ is an infinitely large semicircle on the upper half plane centered at the origin, with a small indent at the origin.
Obviously, the indent integral and the large arc integral tends to zero. By Cauchy’s integral theorem, the contour integral is also zero. Thus, $$\text P\int^\infty_{-\infty}\frac1{x^2}dx=0$$
But the integrand is always positive. How could the integral equal zero? How can this counter-intuitive result be explained?
The issue is first in your obvious step, which then makes it wrong to take the limit after applying Cauchy's theorem. The (counterclockwise) integral over the small semicircle is $$ \int_{\partial B(0,\epsilon)\cap \{\Im z>0\}} \frac {dz}{z^2} = \int_0^\pi \frac{i \epsilon e^{i\theta}}{\epsilon^2 e^{i2\theta}} \ d\theta = \frac 1\epsilon \int_0^\pi ie^{-i\theta} d\theta = \frac{2}\epsilon \to \infty $$
However you might note that the (counterclockwise) integral over the larger semicircle is similarly $\int_{\partial B(0,R)\cap \{\Im z>0\}} = \frac2R$, and on the line segments we have $$ \int_{[-R,R]\setminus[-\epsilon,\epsilon]} \frac{dz}{z^2} = 2\int_{\epsilon}^R \frac{dx}{x^2} = \frac2{\epsilon}- \frac2{R}$$
which verifies Cauchy's theorem, before you take the limits.