Skip to content

Commit

Permalink
More lenient encoding error reporting for source files
Browse files Browse the repository at this point in the history
  • Loading branch information
mapio committed Jun 29, 2018
1 parent 94fe5bd commit c3b6eda
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/sf/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
DEFAULT_ENCODING = 'utf-8'
MAX_BYTES_READ = 1048576
TEST_TIMEOUT = int(environ.get('SIMFUNI_TIMEOUT', 1))
VERSION = '0.5.2'
VERSION = '0.5.3'

class WronglyEncodedFile(UnicodeError):
pass
2 changes: 1 addition & 1 deletion src/sf/lang/java.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def __init__(self, path):
for name in self.sources:
if name == 'TestRunner.java':
try:
with io.open(join(path, name), 'r', encoding = DEFAULT_ENCODING) as f: content = f.read()
with io.open(join(path, name), 'r', encoding = DEFAULT_ENCODING, errors = 'replace') as f: content = f.read()
except UnicodeDecodeError:
raise WronglyEncodedFile(join(path, name))
self.main_source = (name, content)
Expand Down
2 changes: 1 addition & 1 deletion src/sf/solution.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def __init__(self, path):
main_source = []
for name in self.sources:
try:
with io.open(join(path, name), 'r', encoding = DEFAULT_ENCODING) as f: content = f.read()
with io.open(join(path, name), 'r', encoding = DEFAULT_ENCODING, errors = 'replace') as f: content = f.read()
except UnicodeDecodeError:
raise WronglyEncodedFile(join(path, name))
if self.MAIN_SOURCE_RE.search(content): main_source.append((name, content))
Expand Down

0 comments on commit c3b6eda

Please sign in to comment.