Skip to content
This repository has been archived by the owner on May 20, 2024. It is now read-only.

Encode native strings to avoid errors when encountering non-ASCII characters #1144

Merged
merged 1 commit into from
Jan 8, 2019

Conversation

samdoran
Copy link
Contributor

@samdoran samdoran commented Jan 7, 2019

Fixes #1142

Use to_bytes() to encode native strings to avoid UnicodeDecoeError when encountering a non-ASCII character.

Write files in binary mode for Python 2/3 portability.

Encode strings to bytes in order to avoid encoding errers. Change to writing files in binary mode to make code Python 2/3 compatible.

Remove debugging statements

Use to_bytes to encode text.
@abadger
Copy link
Contributor

abadger commented Jan 7, 2019

Looks good. 1

@samdoran samdoran changed the title Use binary mode when writing files to avoid encoding errors Encode native strings avoid errors when encountering non-ASCII characters Jan 7, 2019
@codecov
Copy link

codecov bot commented Jan 7, 2019

Codecov Report

Merging #1144 into master will not change coverage.
The diff coverage is n/a.

@@           Coverage Diff           @@
##           master    #1144    /-   ##
=======================================
  Coverage   32.77%   32.77%           
=======================================
  Files          48       48           
  Lines        9264     9264           
=======================================
  Hits         3036     3036           
  Misses       6228     6228

@samdoran samdoran changed the title Encode native strings avoid errors when encountering non-ASCII characters Encode native strings to avoid errors when encountering non-ASCII characters Jan 7, 2019
@samdoran samdoran merged commit ad8e889 into ansible:master Jan 8, 2019
@samdoran samdoran deleted the encoding-fix branch January 8, 2019 17:05
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants