Changes between Initial Version and Version 1 of Ticket #2727, comment 8
- Timestamp:
- 08/29/15 18:08:15 (9 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
Ticket #2727, comment 8
initial v1 5 5 When issues arise due to unicode strings being passed to functions expecting byte string, the issue is normally fixed by adding an encode() call in the caller. But to catch other such cases, it would help to also modify the callee to explicitly check (e.g. via an assert statement) that the value is a byte string rather than a unicode string. 6 6 7 An explicit check will catch cases where the passed-in string happens to be convertible to ASCII. Relying upon Python raising a nUnicodeError doesn't help much when most of the strings being passed around are convertible to ASCII.7 An explicit check will catch cases where the passed-in string happens to be convertible to ASCII. Relying upon Python raising a !UnicodeError doesn't help much when most of the strings being passed around are convertible to ASCII. 8 8 9 9 Ideally, such checks should be added at the lowest point of the call chain, in order to catch all possible routes to the point where the error occurs.