I’m attempting to “hook” a top level standard library module. That is, provide an alternative implementation, however I need to invoke some of the functionality from the original module.
How can I import the “next module in line”, similar to the effect that RTLD_NEXT has on dlopen in Linux?
After much mucking about, I found the best strategy is just to monkey patch the modules directly. There’s no way to police all the references involved if the real module is shadowed. Here’s an example.