Changes between Initial Version and Version 1 of Ticket #2727, comment 8


Ignore:
Timestamp:
08/29/15 18:08:15 (9 years ago)
Author:
glynn

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #2727, comment 8

    initial v1  
    55When 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.
    66
    7 An explicit check will catch cases where the passed-in string happens to be convertible to ASCII. Relying upon Python raising an UnicodeError doesn't help much when most of the strings being passed around are convertible to ASCII.
     7An 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.
    88
    99Ideally, 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.