Fixed some crashes under Python 3

Fixes for:
http://www.logilab.org/ticket/136037
http://www.logilab.org/ticket/137244

Release: 4