#5127 [py3] Use io.open() instead of builtin open()
Closed: Invalid None Opened 3 years ago by cheimes.

Python 3 has a new io layer. In Python 3 the builtin open() function is just a small shim of on top of io.open(). On Python 2 the return value of io.open() is mostly compatible with open(), except for one fact: {{{isinstance(obj, file)}}} is no longer true.

The new io layer is more powerful, e.g. it supports transparent encoding and decoding of text. While most of the work can be handled with modernize automatically, every occurrence of open() should be checked manually, too. In some cases encoding and decoding can be handled more efficiently.

https://docs.python.org/2/library/io.html#module-io


PS: [PATCH 011] fixes two occurences of file().

master:

  • 18d417e Replace file() with open()

All open() calls are compatible with both Python 2 and Python 3. It's not necessary to use the io module on Python 2.

Metadata Update from @cheimes:
- Issue assigned to someone
- Issue set to the milestone: FreeIPA Python 3 support

2 years ago

Login to comment on this ticket.

Metadata