Skip to content

More explicit interposition with urllib and urllib2 #28

@trishankkarthik

Description

@trishankkarthik

The current specification of tuf.interposition interposes as urllib and urllib2 in an implicit fashion:

tuf.interposition.interpose()
# Now you have TUF...
url = 'http://example.com/path/to/document'
urllib.urlopen( url )
urllib.urlretrieve( url )
urllib2.urlopen( url )
tuf.interposition.go_away()
# ...and now you don't!

Justin's argument is that it is not obvious that tuf.interposition.interpose() modifies urllib and urllib2. What else might the function modify unseen?

Following Python's guideline of "explicit is better than implicit", and the principle of least astonishment, we should change this interposition mechanism to look more like:

from tuf.interposition import urllib, urllib2
urllib.urlopen( url )
urllib2.urlopen( url )

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions