Skip to content

Adding Fix and Unit tests for UTF-8 Breakages#188

Closed
Calvin Chan (CalvinChan1) wants to merge 9 commits into
snowplow:masterfrom
fivestars:fix-encoding
Closed

Adding Fix and Unit tests for UTF-8 Breakages#188
Calvin Chan (CalvinChan1) wants to merge 9 commits into
snowplow:masterfrom
fivestars:fix-encoding

Conversation

@CalvinChan1

Copy link
Copy Markdown

We’re trying to encode as ascii when the text is probably UTF-8 thus getting errors like: UnicodeEncodeError: 'ascii' codec can't encode characters in position 133-141: ordinal not in range(128)

* Fixing encoding, change to utf8 from ascii

* Adding unit tests

* Remove imports

* Adding unit test and fix for utf8 breakages

* Remove print statement
@snowplowcla

Copy link
Copy Markdown

Thanks for your pull request. Is this your first contribution to a Snowplow open source project? Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

📝 Please visit https://github.com/snowplow/snowplow/wiki/CLA to learn more and sign.

Once you've signed, please reply here (e.g. I signed it!) and we'll verify. Thanks.

@coveralls

Coveralls (coveralls) commented Apr 3, 2017

Copy link
Copy Markdown

Coverage Status

Coverage increased (+0.1%) to 80.866% when pulling 996cf2f on fivestars:fix-encoding into 91da00a on snowplow:master.

@BenFradet Ben Fradet (BenFradet) left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM overall, a couple of Qs though

import logging

# Set default logging handler to avoid "No handler found" warnings.
logging.getLogger(__name__).addHandler(logging.NullHandler())

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why change the existing logging?


except ImportError:
# Otherwise configure Celery with default settings
app = Celery("Snowplow", broker="redis://guest@localhost//")

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what was the motivation behind this?

json_dict = json.dumps(dict_, ensure_ascii=False)

if encode_base64:
encoded_dict = base64.urlsafe_b64encode(json_dict.encode("ascii"))

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR doesn't solve the issue #194 in my local tests

Simply changing the encoding on this line to utf-8 does the trick

@oguzhanunlu

Copy link
Copy Markdown
Member

Closing due to long inactivity & missing CLA sign. This issue will be solved by #219 .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants