Skip to content

Commit

Permalink
Declare / test Python 3.4. support:
Browse files Browse the repository at this point in the history
- Pin protobuf == 3.0.0-alpha1

- Clarify text vs. bytes in upload / download as string, in response
  bodies, in 'bytes_field' proto values (e.g. 'transaction').

- Add a copy of the protobuf spec file and regenerate protobuf wrapper
  with 'protoc' 3.0.0-alpha1.

- Transaction ID must be bytes.

- Straddle 'range', 'native' strings. URL quoting / encoding / parsing.
  integer division, 'httplib'.

- Pre-apply changes from /craigcitro/apitools#15.

  We will need to reload the files once Craig makes a new release (or
  even better, remove the vendoring).

- Work around missing 'contextlib.nested' in Py3k.

- Disable lint's failed attempt to import 'six.moves'.

  See: https://bitbucket.org/logilab/pylint/issue/200/ etc.

- Add support for regression testing w/ Python 3.4.

  Note that these tests are currently *failing* due to
  googleapis/oauth2client#125
  • Loading branch information
tseaver committed Feb 4, 2015
1 parent cecdc4f commit 8ab8c1b
Show file tree
Hide file tree
Showing 21 changed files with 1,286 additions and 472 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ install:
script:
- tox -e py26
- tox -e py27
- tox -e py34
- tox -e lint
- tox -e regression
- scripts/merge.sh
Expand Down
4 changes: 2 additions & 2 deletions _gcloud_vendor/apitools/base/py/http_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@
import logging
import socket
import time
import urlparse

import httplib2
from six.moves import http_client
from six.moves import range
from six.moves.urllib.parse import urlsplit

from _gcloud_vendor.apitools.base.py import exceptions
from _gcloud_vendor.apitools.base.py import util
Expand Down Expand Up @@ -127,7 +127,7 @@ def MakeRequest(http, http_request, retries=5, redirections=5):
# wants control over the underlying connection for managing callbacks
# or hash digestion.
if getattr(http, 'connections', None):
url_scheme = urlparse.urlsplit(http_request.url).scheme
url_scheme = urlsplit(http_request.url).scheme
if url_scheme and url_scheme in http.connections:
connection_type = http.connections[url_scheme]
for retry in range(retries + 1):
Expand Down
3 changes: 1 addition & 2 deletions _gcloud_vendor/apitools/base/py/transfer.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import json
import mimetypes
import os
import StringIO
import threading

from six.moves import http_client
Expand Down Expand Up @@ -568,7 +567,7 @@ def __ConfigureMultipartRequest(self, http_request):

# encode the body: note that we can't use `as_string`, because
# it plays games with `From ` lines.
fp = StringIO.StringIO()
fp = io.StringIO()
g = email_generator.Generator(fp, mangle_from_=False)
g.flatten(msg_root, unixfrom=False)
http_request.body = fp.getvalue()
Expand Down
11 changes: 6 additions & 5 deletions _gcloud_vendor/apitools/base/py/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@
import collections
import os
import random
import urllib
import urllib2

import six
from six.moves import http_client
from six.moves.urllib.error import URLError
from six.moves.urllib.parse import quote
from six.moves.urllib.request import urlopen

from _gcloud_vendor.apitools.base.py import exceptions

Expand Down Expand Up @@ -44,8 +45,8 @@ def DetectGce():
True iff we're running on a GCE instance.
"""
try:
o = urllib2.urlopen('http://metadata.google.internal')
except urllib2.URLError:
o = urlopen('http://metadata.google.internal')
except URLError:
return False
return (o.getcode() == http_client.OK and
o.headers.get('metadata-flavor') == 'Google')
Expand Down Expand Up @@ -103,7 +104,7 @@ def ExpandRelativePath(method_config, params, relative_path=None):
if not isinstance(value, six.string_types):
value = str(value)
path = path.replace(param_template,
urllib.quote(value.encode('utf_8'), reserved_chars))
quote(value.encode('utf_8'), reserved_chars))
except TypeError as e:
raise exceptions.InvalidUserInputError(
'Error setting required parameter %s to value %s: %s' % (
Expand Down
4 changes: 2 additions & 2 deletions gcloud/credentials.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
import base64
import calendar
import datetime
import urllib
import six
from six.moves.urllib.parse import urlencode # pylint: disable=F0401

from Crypto.Hash import SHA256
from Crypto.PublicKey import RSA
Expand Down Expand Up @@ -260,4 +260,4 @@ def generate_signed_url(credentials, resource, expiration,
# Return the built URL.
return '{endpoint}{resource}?{querystring}'.format(
endpoint=api_access_endpoint, resource=resource,
querystring=urllib.urlencode(query_params))
querystring=urlencode(query_params))
Loading

0 comments on commit 8ab8c1b

Please sign in to comment.