Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: replace unsafe six.PY3 with PY2 for better future compatibility with Python 4 #10081

Merged
merged 2 commits into from Jan 15, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion logging/tests/unit/handlers/test__helpers.py
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/synth.py
Expand Up @@ -127,10 +127,10 @@
"google/cloud/pubsub_v1/gapic/publisher_client.py",
"class PublisherClient",
"""# 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
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
4 changes: 2 additions & 2 deletions storage/tests/unit/test__signing.py
Expand Up @@ -69,8 +69,8 @@ def test_w_expiration_int(self):
self.assertEqual(self._call_fut(123), 123)

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

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

Expand Down