Issue #19088: Fix incorrect caching of the copyreg module.

This fix does not cause any degradation in performance.