Skip to content

Commit

Permalink
Fix backend codegen unicode vs bytes issues
Browse files Browse the repository at this point in the history
  • Loading branch information
Eric Arellano committed Aug 17, 2018
1 parent c893f8c commit a8674f9
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
6 changes: 3 additions & 3 deletions src/python/pants/backend/jvm/tasks/bootstrap_jvm_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,15 @@ def compute_fingerprint(self, target):
if base_fingerprint is None:
return None

hasher.update('version=2')
hasher.update(b'version=2')
hasher.update(base_fingerprint.encode('utf-8'))

# NB: this series of updates must always cover the same fields that populate `_tuple`'s slots
# to ensure proper invalidation.
hasher.update(self._main)
hasher.update(self._main.encode('utf-8'))
if self._custom_rules:
for rule in self._custom_rules:
hasher.update(rule.render())
hasher.update(rule.render().encode('utf-8'))

return hasher.hexdigest() if PY3 else hasher.hexdigest().decode('utf-8')

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def test_bundle_protobuf_normal(self):
stdout=subprocess.PIPE,
cwd=out_path)
java_retcode = java_run.wait()
java_out = java_run.stdout.read()
java_out = java_run.stdout.read().decode('utf-8')
self.assertEqual(java_retcode, 0)
self.assertIn("parsec", java_out)

Expand All @@ -54,7 +54,7 @@ def test_bundle_protobuf_imports(self):
stdout=subprocess.PIPE,
cwd=out_path)
java_retcode = java_run.wait()
java_out = java_run.stdout.read()
java_out = java_run.stdout.read().decode('utf-8')
self.assertEqual(java_retcode, 0)
self.assertIn("very test", java_out)

Expand All @@ -76,7 +76,7 @@ def test_bundle_protobuf_unpacked_jars(self):
'org.pantsbuild.example.protobuf.unpacked_jars.ExampleProtobufExternalArchive']
java_run = subprocess.Popen(args, stdout=subprocess.PIPE, cwd=out_path)
java_retcode = java_run.wait()
java_out = java_run.stdout.read()
java_out = java_run.stdout.read().decode('utf-8')
self.assertEqual(java_retcode, 0)
self.assertIn("Message is: Hello World!", java_out)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ def test_namespace_effective(self):
# TODO(John Sirois): We really should be emitting setuptools in a
# `synthetic_target_extra_dependencies` override in `ApacheThriftPyGen`:
# https://github.com/pantsbuild/pants/issues/5975
pythonpath = interpreter.extras.values()
pythonpath = list(interpreter.extras.values())
pythonpath.extend(os.path.join(get_buildroot(), t.target_base) for t in targets)
for dist in resolve(['thrift=={}'.format(self.get_thrift_version(apache_thrift_gen))],
interpreter=interpreter,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def test_bundle_wire_normal(self):
'org.pantsbuild.example.wire.temperatureservice.WireTemperatureExample']
java_run = subprocess.Popen(args, stdout=subprocess.PIPE, cwd=out_path)
java_retcode = java_run.wait()
java_out = java_run.stdout.read()
java_out = java_run.stdout.read().decode('utf-8')
self.assertEqual(java_retcode, 0)
self.assertIn('19 degrees celsius', java_out)

Expand All @@ -63,7 +63,7 @@ def test_bundle_wire_dependent_targets(self):
stdout=subprocess.PIPE,
cwd=out_path)
java_retcode = java_run.wait()
java_out = java_run.stdout.read()
java_out = java_run.stdout.read().decode('utf-8')
self.assertEqual(java_retcode, 0)
self.assertIn('Element{symbol=Hg, name=Mercury, atomic_number=80, '
'melting_point=Temperature{unit=celsius, number=-39}, '
Expand Down

0 comments on commit a8674f9

Please sign in to comment.