@@ -220,11 +220,14 @@ def square_root_mod_prime(a, p):
220220 raise RuntimeError ("No b found." )
221221
222222
223+ # because all the inverse_mod code is arch/environment specific, and coveralls
224+ # expects it to execute equal number of times, we need to waive it by
225+ # adding the "no branch" pragma to all branches
223226if GMPY2 : # pragma: no branch
224227
225228 def inverse_mod (a , m ):
226229 """Inverse of a mod m."""
227- if a == 0 :
230+ if a == 0 : # pragma: no branch
228231 return 0
229232 return powmod (a , - 1 , m )
230233
@@ -237,14 +240,14 @@ def inverse_mod(a, m):
237240 # only using the native `pow()` function, and `pow()` in gmpy sanity
238241 # checks the parameters before passing them on to underlying
239242 # implementation
240- if a == 0 :
243+ if a == 0 : # pragma: no branch
241244 return 0
242245 a = mpz (a )
243246 m = mpz (m )
244247
245248 lm , hm = mpz (1 ), mpz (0 )
246249 low , high = a % m , m
247- while low > 1 :
250+ while low > 1 : # pragma: no branch
248251 r = high // low
249252 lm , low , hm , high = hm - lm * r , high - low * r , lm , low
250253
@@ -255,7 +258,7 @@ def inverse_mod(a, m):
255258
256259 def inverse_mod (a , m ):
257260 """Inverse of a mod m."""
258- if a == 0 :
261+ if a == 0 : # pragma: no branch
259262 return 0
260263 return pow (a , - 1 , m )
261264
@@ -265,12 +268,12 @@ def inverse_mod(a, m):
265268 def inverse_mod (a , m ):
266269 """Inverse of a mod m."""
267270
268- if a == 0 :
271+ if a == 0 : # pragma: no branch
269272 return 0
270273
271274 lm , hm = 1 , 0
272275 low , high = a % m , m
273- while low > 1 :
276+ while low > 1 : # pragma: no branch
274277 r = high // low
275278 lm , low , hm , high = hm - lm * r , high - low * r , lm , low
276279
0 commit comments