Perform additional contexts restoration for NTL.
Trac #16885: random failure with factorization of polynomials over finite fields

Ticket #16681 pops up a strange error when doing factorization of
polynomials over finite fields. The problem occurs when we repeatedly
create finite fields of different degree and ask for factorization of
some random polynomial in that field as in the example below
{{{
sage: R = PolynomialRing(GF(3),'T')
sage: for _ in xrange(5000):
....:    p = R.random_element(degree=(2,8))
....:    d = p.degree()
....:    if d <= 2: continue
....:    q = p.change_ring(GF(3**d, 'z'))
....:    assert q.factor().prod() == q, "problem with p={}".format(p)
Traceback (most recent call last):
...
AssertionError: problem with p=T^4 + T^2
}}}

You can also have a look at the file [attachment:test_polynomials.py
test_polynomials.py] which contains more precise output for the same
tests.

See also this [https://groups.google.com/forum/#!topic/sage-
devel/pk36tDZIo0c sage-devel thread].

URL: http://trac.sagemath.org/16885
Reported by: vdelecroix
Ticket author(s): Jean-Pierre Flori
Reviewer(s): Volker Braun