Skip to content

Commit

Permalink
Editing a mechanize file so that the code can run on GAE.
Browse files Browse the repository at this point in the history
  • Loading branch information
BarbaraEMac committed Nov 10, 2010
1 parent 8077379 commit d79fa2c
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion mechanize/_urllib2_fork.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def sha1_digest(bytes):
def md5_digest(bytes):
return hashlib.md5(bytes).hexdigest()


"""
try:
socket._fileobject("fake socket", close=True)
except TypeError:
Expand All @@ -74,6 +74,26 @@ def md5_digest(bytes):
else:
def create_readline_wrapper(fh):
return socket._fileobject(fh, close=True)
"""

# The below code allows mechanize to work in GAE.
try:
# fixed start -- fixed for gae
class x:
pass

# the x should be an object, not a string,
# This is the key
socket._fileobject(x, close=True)
# fixed ended
except TypeError:
# python <= 2.4
create_readline_wrapper = socket._fileobject
else:
def create_readline_wrapper(fh):
return socket._fileobject(fh, close=True)

# The above code makes mechanize work in GAE.


# python 2.4 splithost has a bug in empty path component case
Expand Down

0 comments on commit d79fa2c

Please sign in to comment.