[Python-Dev] Overriding stdlib http package

Tres Seaver tseaver at palladion.com
Wed Jan 14 18:04:22 CET 2015


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 01/14/2015 11:54 AM, Antoine Pitrou wrote:
> On Wed, 14 Jan 2015 08:32:23 -0800 Demian Brecht
> <demianbrecht at gmail.com> wrote:
>> Hi all,
>> 
>> As part of the work I'm doing on httplib3 (now that I've actually
>> gotten a bit of time), one of the things I'm trying to get done is
>> injection of httplib3 over http in order to not have to modify all
>> import paths in modules and such. Here's the gist of what I have so
>> far: https://gist.github.com/demianbrecht/bc6530a40718e4fcbf90.
> 
> What don't you simply monkeypatch sys.modules, e.g.:
> 
> import myhttplib
> 
> sys.modules['http'] = myhttplib
> 
> or doesn't it work as desired?

Doesn't that leave any prior imports broken (using the original module)?


Tres.
- -- 
===================================================================
Tres Seaver          +1 540-429-0999          tseaver at palladion.com
Palladion Software   "Excellence by Design"    http://palladion.com
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)

iEYEARECAAYFAlS2oZYACgkQ+gerLs4ltQ457gCfTSuwfOUHOivoQAUncq6VbxdQ
YOkAoLec1hghar8IULuaz5W0MTXOtQm/
=tvv7
-----END PGP SIGNATURE-----



More information about the Python-Dev mailing list