Fix a shortenURL reference bug pointed out by Jacob, incremental release of latest bugfixes because Pypi's been down recently

This commit is contained in:
Ryan McGrath 2010-12-12 14:45:03 +09:00
parent ace1a87745
commit 8ecdaa5bfa
3 changed files with 70 additions and 76 deletions

View file

@ -5,7 +5,7 @@ from setuptools import setup
from setuptools import find_packages from setuptools import find_packages
__author__ = 'Ryan McGrath <ryan@venodesigns.net>' __author__ = 'Ryan McGrath <ryan@venodesigns.net>'
__version__ = '1.3.5' __version__ = '1.3.6'
setup( setup(
# Basic package information. # Basic package information.

View file

@ -9,7 +9,7 @@
""" """
__author__ = "Ryan McGrath <ryan@venodesigns.net>" __author__ = "Ryan McGrath <ryan@venodesigns.net>"
__version__ = "1.3.5" __version__ = "1.3.6"
import urllib import urllib
import urllib2 import urllib2
@ -223,10 +223,7 @@ class Twython(object):
shortener - In case you want to use a url shortening service other than is.gd. shortener - In case you want to use a url shortening service other than is.gd.
""" """
try: try:
resp, content = self.client.request( content = urllib2.urlopen(shortener + "?" + urllib.urlencode({query: Twython.unicode2utf8(url_to_shorten)})).read()
shortener + "?" + urllib.urlencode({query: Twython.unicode2utf8(url_to_shorten)}),
"GET"
)
return content return content
except HTTPError, e: except HTTPError, e:
raise TwythonError("shortenURL() failed with a %s error code." % `e.code`) raise TwythonError("shortenURL() failed with a %s error code." % `e.code`)

View file

@ -9,7 +9,7 @@
""" """
__author__ = "Ryan McGrath <ryan@venodesigns.net>" __author__ = "Ryan McGrath <ryan@venodesigns.net>"
__version__ = "1.3.5" __version__ = "1.3.6"
import urllib.request, urllib.parse, urllib.error import urllib.request, urllib.parse, urllib.error
import urllib.request, urllib.error, urllib.parse import urllib.request, urllib.error, urllib.parse
@ -166,7 +166,7 @@ class Twython(object):
# Then open and load that shiiit, yo. TODO: check HTTP method and junk, handle errors/authentication # Then open and load that shiiit, yo. TODO: check HTTP method and junk, handle errors/authentication
if fn['method'] == 'POST': if fn['method'] == 'POST':
resp, content = self.client.request(base, fn['method'], urllib.parse.urlencode(kwargs)) resp, content = self.client.request(base, fn['method'], urllib.parse.urlencode(dict([k, v.encode('utf-8')] for k, v in list(kwargs.items()))))
else: else:
url = base + "?" + "&".join(["%s=%s" %(key, value) for (key, value) in kwargs.items()]) url = base + "?" + "&".join(["%s=%s" %(key, value) for (key, value) in kwargs.items()])
resp, content = self.client.request(url, fn['method']) resp, content = self.client.request(url, fn['method'])
@ -223,10 +223,7 @@ class Twython(object):
shortener - In case you want to use a url shortening service other than is.gd. shortener - In case you want to use a url shortening service other than is.gd.
""" """
try: try:
resp, content = self.client.request( content = urllib.request.urlopen(shortener + "?" + urllib.parse.urlencode({query: Twython.unicode2utf8(url_to_shorten)})).read()
shortener + "?" + urllib.parse.urlencode({query: Twython.unicode2utf8(url_to_shorten)}),
"GET"
)
return content return content
except HTTPError as e: except HTTPError as e:
raise TwythonError("shortenURL() failed with a %s error code." % repr(e.code)) raise TwythonError("shortenURL() failed with a %s error code." % repr(e.code))