robotpy / pynetworktables

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

Fix handling of string entries under Python 2 #27

Closed lethosor closed 8 years ago

lethosor commented 8 years ago

We ran into this when testing pynetworktables2js - putValue() was failing for strings under Python 2 because they're sent across as unicode strings. I'm unsure if there's any case where byte strings would be sent across in either version, so I just changed this to check for str in Python 3 and unicode in Python 2. (Using six might be cleaner for this, but I didn't feel a need to introduce another dependency for something this trivial.)

virtuald commented 8 years ago

Why not isinstance(x, basestring)?

lethosor commented 8 years ago

Oh, that's neat. Thanks!

virtuald commented 8 years ago

Not sure why it wasn't that way to begin with. :)

lethosor commented 8 years ago

That's not defined in Python 3, actually.

virtuald commented 8 years ago

Grr. That would explain that.

virtuald commented 8 years ago

Ok, I'll fix it. One sec.

virtuald commented 8 years ago

Fixed. Thanks for the patch!