[r21693]GrampsLocale: Prevent some AttributeErrors

and 'referenced before assignment' errors.

git-svn-id: svn+ssh://svn.code.sf.net/p/gramps/code/branches/maintenance/gramps40@21697 4ae1f11a-8b86-4847-b8af-ab372f36d1fd
[r21694]GrampsLocale: Use glocale.lang or glocale.language[0]

To get the default localization instead of locale.getlocale() or
glocale.get_translation().language().

git-svn-id: svn+ssh://svn.code.sf.net/p/gramps/code/branches/maintenance/gramps40@21698 4ae1f11a-8b86-4847-b8af-ab372f36d1fd
[r21695]GrampsLocale: Ensure correct stdout encoding

Replace stdout with one that uses a transcoding Streamwriter. This
better handles differences between Py2 and Py3 than does trying to
encode strings prior to output. In particular Py3's default stdout
demands unencoded strings and prints byte-strings when one tries to
pre-encode them.

git-svn-id: svn+ssh://svn.code.sf.net/p/gramps/code/branches/maintenance/gramps40@21699 4ae1f11a-8b86-4847-b8af-ab372f36d1fd
[r21696]TreeBaseModel: Avoid TypeError when bisecting

git-svn-id: svn+ssh://svn.code.sf.net/p/gramps/code/branches/maintenance/gramps40@21700 4ae1f11a-8b86-4847-b8af-ab372f36d1fd