Skip to content

Commit

Permalink
fix: Fix for Python 4: replace unsafe six.PY3 with PY2
Browse files Browse the repository at this point in the history
  • Loading branch information
hugovk committed Jan 9, 2020
1 parent b387134 commit 8f15925
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion logging/tests/unit/handlers/test__helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ def get(self):
self.response.out.write(json.dumps(trace_id))


@unittest.skipIf(six.PY3, "webapp2 is Python 2 only")
@unittest.skipIf(not six.PY2, "webapp2 is Python 2 only")
class Test_get_trace_id_from_webapp2(unittest.TestCase):
@staticmethod
def create_app():
Expand Down
6 changes: 3 additions & 3 deletions pubsub/google/cloud/pubsub_v1/gapic/publisher_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,10 @@


# TODO: remove conditional import after Python 2 support is dropped
if six.PY3:
from collections.abc import Mapping
else:
if six.PY2:
from collections import Mapping
else:
from collections.abc import Mapping


def _merge_dict(d1, d2):
Expand Down
6 changes: 3 additions & 3 deletions storage/google/cloud/storage/batch.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,10 +214,10 @@ def _prepare_batch_request(self):
timeout = _timeout

# The `email` package expects to deal with "native" strings
if six.PY3: # pragma: NO COVER Python3
buf = io.StringIO()
else:
if six.PY2: # pragma: NO COVER Python3
buf = io.BytesIO()
else:
buf = io.StringIO()
generator = Generator(buf, False, 0)
generator.flatten(multi)
payload = buf.getvalue()
Expand Down
2 changes: 1 addition & 1 deletion storage/tests/unit/test__signing.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ def test_w_expiration_int(self):
self.assertEqual(self._call_fut(123), 123)

def test_w_expiration_long(self):
if six.PY3:
if not six.PY2:
raise unittest.SkipTest("No long on Python 3")

self.assertEqual(self._call_fut(long(123)), 123) # noqa: F821
Expand Down

0 comments on commit 8f15925

Please sign in to comment.