codewars / codewars.com

Issue tracker for Codewars
https://www.codewars.com
BSD 2-Clause "Simplified" License
2.09k stars 219 forks source link

Python 2.x string output doesn't accept unicode strings #459

Closed deadowl closed 7 years ago

deadowl commented 8 years ago

I was trying to rewrite a kata translation for one of my kata a month or so ago, and was unable to get it to pass due to issues in the test cases. It seems like the Python kata test framework completely rejects unicode strings now.

jhoffner commented 8 years ago

I'll try to take a look tomorrow. What kata is this for?

deadowl commented 8 years ago

Vigenere Cipher and Vigenere Autokey Cipher in particular. The current Python test cases are so bad for those they need to be replaced, although it looks like you actually have a beta process for translations now, which was a much-needed improvement from my perspective.

Character encoding support has been going downhill in a very bad way. I've had complaints on like half of my kata about character encoding issues, all of which had assumed UTF-8 strings and that had been coded with Javascript in mind. I think the root of the problem is that the different languages that are being supported have different character set support, and that contributors might not have much experience with character encoding issues.

https://www.codewars.com/kata/vigenere-cipher-helper/discuss https://www.codewars.com/kata/vigenere-autokey-cipher-helper/discuss

I'm also wondering if the new issue I'm seeing with the affine cipher kata is related to this. If not, feel free to fork out another issue.

https://www.codewars.com/kata/affine-cipher-helper/discuss

jhoffner commented 8 years ago

Character encoding beyond ascii accidentally got broken with the new runner released on Friday, which I'm in the process of pushing an update out for.

jhoffner commented 8 years ago

I deployed a fix yesterday. Please verify that this is no longer an issue.

deadowl commented 8 years ago

It looks like when test.it is called with the kata builder on a unicode string, it fails to output and none of the following asserts are presented or executed, unless trying to resubmit. Same with the print statement.

deadowl commented 8 years ago

Python, at least 2.x, has a source coding declaration https://www.python.org/dev/peps/pep-0263/ Not sure if that's applicable. I don't know what's going on otherwise.

Here's the Vigenere solution and test cases I want to replace the present ones with, which will break every existing solution, but also resolve every reported complaint and issue and bring it in line with the difficulty level of the other translations. I should add that it works-for-me^TM but it's weird on Codewars.

vigenere.zip

ebreton commented 7 years ago

I hit the same issue today, trying to write a kata about unicodes.

My issue is not to be able to display any message with unicode.

When trying test.it(u"Testing with {0}".format(incoming)), where incoming is a unicode. I got the following error:

Traceback:
   in 
  File "./frameworks/python/cw-2.py", line 56, in it
    print("{0}".format(format_message(message)))
UnicodeEncodeError: 'ascii' codec can't encode character u'\xe9' in position 13: ordinal not in range(128)

I also tried the work around print u"Testing with {0}".format(incoming), which leads to:

Traceback:
   in 
UnicodeEncodeError: 'ascii' codec can't encode character u'\xe9' in position 13: ordinal not in range(128)

Is there a way to display unicode messages on the execution of tests ?

kazk commented 7 years ago

This will be tracked at https://github.com/Codewars/codewars-runner-cli/issues/508