robotpy / pynetworktables

Pure python implementation of the FRC NetworkTables protocol
Other
60 stars 30 forks source link

ntcore.value: Use unicode strings in Python 2 #37

Closed auscompgeek closed 7 years ago

auscompgeek commented 7 years ago

Fixes #36.

virtuald commented 7 years ago

Thanks for doing this, can you add some weird unicode strings (like ©) to the existing unit tests, just so we can verify that it doesn't happen again in the future?

auscompgeek commented 7 years ago

Hm. Looks like I misread ntcore.support.compat.

I guess the easy way out would be to consider bytestrings in Python 2 to be raw, but that might be problematic…

Value.make* are public APIs, right? Is it documented that Value.makeString can take non-strings (converting the value to a string)?

virtuald commented 7 years ago

It's only vaguely public... users aren't expected to use ntcore.

virtuald commented 7 years ago

Also, keep in mind that Value.makeString is used for incoming values from the network (py2: str, py3: bytes) and from NetworkTable.xxx apis (so.. whatever the user throws at it).

auscompgeek commented 7 years ago

From discussion on Gitter:

virtuald commented 7 years ago

Looks good, can you add a unicode test to the round trips in https://github.com/robotpy/pynetworktables/blob/master/tests/test_api.py?