Pidgeot / python-lnp

Cross-platform re-implementation of the Lazy Newb Pack launcher.
ISC License
64 stars 10 forks source link

Fixes for KDETerminal #168

Closed cryzed closed 4 years ago

cryzed commented 4 years ago

Only kreadconfig5 exists on my Arch Linux installation. Arch Linux is known for not patching upstream, so I assume this is how it is shipped by the latest KDE Plasma version. Some distros might decide to symlink kreadconfig to kreadconfig5 -- this code should support both cases.

See the paragraph about universal_newlines here:

If encoding or errors are specified, or text is true, file objects for stdin, stdout and stderr are opened in text mode using the specified encoding and errors or the io.TextIOWrapper default. The universal_newlines argument is equivalent to text and is provided for backwards compatibility. By default, file objects are opened in binary mode.

And the default encoding for io.TextIOWrapper is described here:

encoding gives the name of the encoding that the stream will be decoded or encoded with. It defaults to locale.getpreferredencoding(False).

Which can be found here. So we can assume this makes the best choice using what can be inferred from the running system, instead of just assuming "UTF-8". I decided to use "universal_newlines" instead of the more-modern "text" keyword-argument, because that was only introduced relatively recently (Python 3.7).