Merge branch 'master' into develop

This commit is contained in:
Vincent Jacques
2013-03-03 18:47:22 +01:00
7 changed files with 50 additions and 5 deletions
+5
View File
@@ -10,6 +10,11 @@ PyGithub is stable. I will maintain it up to date with the API, and fix bugs if
What's new?
===========
Version 1.12.2 (March 3rd, 2013)
--------------------------------
* `Fix <https://github.com/jacquev6/PyGithub/issues/142>`_ major issue with Python 3: Json decoding was broken. Thank you `bilderbuchi <https://github.com/bilderbuchi>`_ for reporting
Version 1.12.1 (February 20th, 2013)
------------------------------------
+5
View File
@@ -4,6 +4,11 @@ Change log
Stable versions
~~~~~~~~~~~~~~~
Version 1.12.2 (March 3rd, 2013)
--------------------------------
* `Fix <https://github.com/jacquev6/PyGithub/issues/142>`_ major issue with Python 3: Json decoding was broken. Thank you `bilderbuchi <https://github.com/bilderbuchi>`_ for reporting
Version 1.12.1 (February 20th, 2013)
------------------------------------
+13 -4
View File
@@ -40,6 +40,11 @@ class Requester:
cls.__httpConnectionClass = httpConnectionClass
cls.__httpsConnectionClass = httpsConnectionClass
@classmethod
def resetConnectionClasses(cls):
cls.__httpConnectionClass = httplib.HTTPConnection
cls.__httpsConnectionClass = httplib.HTTPSConnection
def __init__(self, login_or_token, password, base_url, timeout, client_id, client_secret, user_agent):
if password is not None:
login = login_or_token
@@ -91,6 +96,8 @@ class Requester:
if len(data) == 0:
return None
else:
if atLeastPython3 and isinstance(data, bytes): # pragma no branch
data = data.decode("utf-8") # pragma no cover
return json.loads(data)
def requestJson(self, verb, url, parameters, input):
@@ -192,10 +199,12 @@ class Requester:
return url + "?" + urllib.urlencode(parameters)
def __createConnection(self):
if atLeastPython26:
return self.__connectionClass(host=self.__hostname, port=self.__port, strict=True, timeout=self.__timeout)
else: # pragma no cover
return self.__connectionClass(host=self.__hostname, port=self.__port, strict=True) # pragma no cover
kwds = {}
if not atLeastPython3: # pragma no branch
kwds["strict"] = True # Useless in Python3, would generate a deprecation warning
if atLeastPython26: # pragma no branch
kwds["timeout"] = self.__timeout # Did not exist before Python2.6
return self.__connectionClass(host=self.__hostname, port=self.__port, **kwds)
def __log(self, verb, url, requestHeaders, input, status, responseHeaders, output):
logger = logging.getLogger(__name__)
+1
View File
@@ -65,3 +65,4 @@ from Issue133 import *
from Issue134 import *
from Issue139 import *
from Issue140 import *
from Issue142 import *
+1
View File
@@ -157,6 +157,7 @@ class BasicTestCase(unittest.TestCase):
def tearDown(self):
unittest.TestCase.tearDown(self)
self.__closeReplayFileIfNeeded()
github.Requester.Requester.resetConnectionClasses()
def __openFile(self, mode):
for (_, _, functionName, _) in traceback.extract_stack():
+24
View File
@@ -0,0 +1,24 @@
# -*- coding: utf-8 -*-
# Copyright 2012 Vincent Jacques
# vincent@vincent-jacques.net
# This file is part of PyGithub. http://jacquev6.github.com/PyGithub/
# PyGithub is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License
# as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
# PyGithub is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
# You should have received a copy of the GNU Lesser General Public License along with PyGithub. If not, see <http://www.gnu.org/licenses/>.
import unittest
import github
class Issue142(unittest.TestCase): # https://github.com/jacquev6/PyGithub/issues/140
def testDecodeJson(self):
# This test has to hit GitHub for real, because the record-replay framework looses types
# and python3 does not behave like python3 for strings and bytes
self.assertEqual(github.Github().get_user("jacquev6").name, "Vincent Jacques")
+1 -1
View File
@@ -20,7 +20,7 @@ import subprocess
import shutil
import os.path
version = "1.12.1"
version = "1.12.2"
def execute(*args):