Skip to content
This repository was archived by the owner on Dec 22, 2022. It is now read-only.

Commit a4461c1

Browse files
committed
Merge pull request tylertreat#74 from puhitaku/json_py3
Fix loading json for Python3
2 parents a944f71 + 198d35f commit a4461c1

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

bigquery/client.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,8 @@ def get_client(project_id, credentials=None, service_account=None,
8282
private_key = key_file.read()
8383

8484
if json_key_file:
85-
with open(json_key_file, 'rb') as key_file:
86-
json_key = json.loads(key_file.read())
85+
with open(json_key_file, 'r') as key_file:
86+
json_key = json.load(key_file)
8787

8888
if json_key:
8989
service_account = json_key['client_email']

bigquery/tests/test_client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ def test_initialize_json_key_file(self, mock_open, mock_build, mock_return_cred)
158158

159159
bq_client = client.get_client(project_id, json_key_file=json_key_file, readonly=False)
160160

161-
mock_open.assert_called_once_with(json_key_file, 'rb')
161+
mock_open.assert_called_once_with(json_key_file, 'r')
162162
mock_return_cred.assert_called_once_with()
163163
mock_cred.assert_called_once_with(json_key['client_email'], json_key['private_key'], scope=BIGQUERY_SCOPE)
164164
self.assertTrue(mock_cred.return_value.authorize.called)

0 commit comments

Comments
 (0)