The issue is in the caching:
sage: R = Qp(7, print_mode='val-unit')
sage: S = Qp(7)
sage: R(7^2 + 1)
7^2 * 1 + O(7^22)
sage: S(7^2)
7^2 + O(7^22)
sage: R(7^2 + 1)
50 + O(7^20)
sage: S(7^2 + 1)
1 + 7^2 + O(7^20)
sage: R is S
False
sage: R['x'] is S['x']
True
The issue manifests itself in polynomial_ring_constructor, which fails because the cache is keyed by ==, not identity, and
Component: commutative algebra
Keywords: polynomial p-adic print mode cache caching
Issue created by migration from https://trac.sagemath.org/ticket/1210