Consider a $U(1)$-bundle $P$ over the two-dimensional torus $T^2$. Given a local curvature $F$, We can compute the first Chern number $c_1(P)$ by considering a rectangle $R_{\epsilon}$ in the center of the torus whose edges are a distance $2\epsilon$ from touching each other:
Then we may also define a restricted bundle $P|_{R_{\epsilon}}:=\pi^{-1}(R_{\epsilon})$. Note that this is a principal $U(1)$-bundle in its own right, over a manifold with non-trivial boundary.
The Calculation: Since the first chern-form is non-singular (by virtue of being a characteristic class), its integral over the complement of $R_{\epsilon}$ vanishes as $\epsilon$ goes to zero and we can write the first chern number of $P$ as the limit $$c_1(P)=\int_{T^2}C_1(F)=\lim_{\epsilon\to 0}\int_{R_{\epsilon}}C_1(F)=\lim_{\epsilon\to 0}c_1(P|_{R_{\epsilon}})$$ However, since $R_{\epsilon}$ is contractible, $P|_{R_{\epsilon}}$ is a trivial bundle, and so $c_1(P|_{R_{\epsilon}})=0$ for all values of $\epsilon$ greater than zero. So $$c_1(P)=\lim_{\epsilon\to 0}c_1(P|_{R_{\epsilon}})=\lim_{\epsilon\to 0}0=0.$$ So the first chern number of any $U(1)$ bundle over the two-torus must vanish. What am I misunderstanding?
The problem is that you're trying to evaluate/integrate a cohomology class (the first Chern class of your bundle) over a manifold with boundary. This is not a well-defined thing to do. In particular, Chern numbers don't make sense over manifolds with boundary.
Explicitly, you're saying that the bundle over $R_\epsilon$ is trivial, so its first Chern class $[iF/2\pi]$ is zero (in cohomology), and hence the integral of $iF/2\pi$ is zero. But this is not correct: all we know is that $iF/2\pi = \mathrm{d}\alpha$ for some $1$-form $\alpha$, and thus
$$ \int_{R_\epsilon} \frac{i}{2\pi}F = \int_{R_\epsilon} \mathrm{d}\alpha = \int_{\partial R_{\epsilon}} \alpha. $$
The latter is not necessarily zero, because the boundary $\partial R_{\epsilon}$ is non-empty.