Skip to content

Commit 36ace9c

Browse files
author
Jason Mobarak
authored
fix tox tests for Python 3.5 (swift-nav#853) #no_auto_pr
* fix tox tests for Python 3.5 * use a helper to decrease nesting
1 parent 237985b commit 36ace9c

File tree

3 files changed

+15
-5
lines changed

3 files changed

+15
-5
lines changed

generator/setup.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
setup(name='sbp_gen',
1313
description='Generator for Swift Binary Protocol',
14-
long_description=open('README.md').read(),
14+
long_description=open('README.md', 'rb').read().decode('utf8'),
1515
version='0.10',
1616
author='Swift Navigation',
1717
author_email='[email protected]',

python/sbp/client/loggers/json_logger.py

+12-2
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@ def _next_conventional(self):
134134
if self._broken:
135135
raise StopIteration
136136

137+
line = ''
137138
try:
138139
line = self.handle.readline()
139140

@@ -147,13 +148,22 @@ def _next_conventional(self):
147148
# Try next line, can lead to RecursionError if source is full of rubbish
148149
return self._next_conventional()
149150

150-
def _next_legacy(self):
151+
def _next_legacy_inner(self):
152+
line = ''
151153
for line in self.handle:
152154
try:
153155
yield self._extract_data(line)
154156
except (ValueError, UnicodeDecodeError):
155-
warn = "Bad JSON decoding for line %s" % line
157+
warn = "Bad JSON decoding for line %s" % (line,)
156158
warnings.warn(warn, RuntimeWarning)
159+
160+
def _next_legacy(self):
161+
try:
162+
for line in self._next_legacy_inner():
163+
yield line
164+
except (ValueError, UnicodeDecodeError):
165+
warn = "Bad JSON decoding"
166+
warnings.warn(warn, RuntimeWarning)
157167
self.handle.seek(0, 0)
158168

159169
def __next__(self):

python/setup.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -163,8 +163,8 @@ def exclude_jit_libs(lib):
163163

164164
if __name__ == "__main__":
165165

166-
with open(os.path.join(setup_py_dir, 'README.rst')) as f:
167-
readme = f.read()
166+
with open(os.path.join(setup_py_dir, 'README.rst'), 'rb') as f:
167+
readme = f.read().decode('utf8')
168168

169169
write_version_py()
170170

0 commit comments

Comments
 (0)