Integral of $\frac{1}{\sin z}$ along a path 
Suppose $\gamma$ is a simple, closed path, with $0$ in its interior and $\{\pi n:n\in\mathbb{Z}\setminus\{0\}\}\subset\mathbb{C}\setminus|\gamma|$. Find 
  $$
\int_{\gamma} \frac{1}{\sin z} dz 
$$

Perhaps it's a simple question of Cauchy's formula or Cauchy's theorem.
Thanks.
 A: You can write $$\frac{1}{\sin z} = \frac{g(z)}{z}$$ where $g(z) := \frac{z}{\sin z}$ is a holomorphic function inside of $\gamma$ if we set $g(0)$ to be $1$.  (L'Hopital's formula, etc.).
Cauchy's formula gives $$\int_{\gamma} \frac{dz}{\sin z} = \int_{\gamma} \frac{g(z)}{z} = 2\pi i g(0) = 2\pi i$$
A: This should be calculated using the residue theorem in order to account for the residues in the interior of $\gamma$, found at $n\pi$ (where $n\in\mathbb{Z}$).
These residues are all simple poles. Using the formula for calculating residues at simple poles and L'Hôpital's rule:
$$\operatorname{Res}\,(f,n\pi)=\lim\limits_{z \to n\pi} \frac{z-n\pi}{\sin{z}}=\lim\limits_{z \to n\pi} \frac{1}{\cos{z}}=(-1)^n$$
Consequently, the integral's solution changes depending on the location and number of poles contained in $\gamma$. Let $N$ denote the largest value for $\lvert n\rvert$ found in the interior of $\gamma$, and let $M$ denote the amount of poles contained in the interior of $\gamma$.
Since $\gamma$ is a simple, closed path and $0$ is always in its interior, the residue theorem then gives:
$$\int_{\gamma} \frac{dz}{\sin{z}}=2\pi i \sum \operatorname{Res}\,(f,n\pi)=\begin{cases} \;\;\,2\pi i & \text{if $M$ odd, $N$ even} \\ -2\pi i & \text{if $M$ odd, $N$ odd} \\ \quad\;\, 0 & \text{if $M$ even} \end{cases}$$
