Always open files in text mode and always use utf-8
commit1eeec38a9a06a9956cdab9789cbd2ea105866198
authorChristoph Reiter <reiter.christoph@gmail.com>
Mon, 18 Sep 2017 20:49:09 +0000 (18 22:49 +0200)
committerStefan Sauer <ensonic@users.sf.net>
Thu, 26 Oct 2017 18:30:20 +0000 (26 20:30 +0200)
treeb647e55d759604a6f585d9dd645921201da10aa4
parentf8ea839aa531b8cf1de2f623f37064178d24f033
Always open files in text mode and always use utf-8

Introduces a common.open_text() helper with saner defaults for opening
text files across Python versions.

open() defaults to the locale encoding which on a properly configured
Unix is utf-8, but cp-1252 on Windows which can't handle all of Unicode.
Instead of using the default always use utf-8 for text files.

To reduce the difference of types processed by Python 2 vs 3 use
codecs.open() to open text files in text mode on Python 2. The
resulting file object will return unicode like on Python 3, but still
allows passing in ASCII only str.

Also fixes a few missing file.close() operations, which is important on
Windows as non-closed files can't be renamed/deleted on Windows.

https://bugzilla.gnome.org/show_bug.cgi?id=787862
gtkdoc/check.py
gtkdoc/common.py
gtkdoc/fixxref.py
gtkdoc/mkdb.py
gtkdoc/mkhtml.py
gtkdoc/mkpdf.py
gtkdoc/rebase.py
gtkdoc/scan.py
gtkdoc/scangobj.py