You've already forked style_checker
mirror of
https://github.com/AdaCore/style_checker.git
synced 2026-02-12 12:58:19 -08:00
This os.write function is a low-level function whose API changed between Python 2.7 and Python 3.x. With Python 2.7, it takes a string as a parameter, whereas with Python 3.x, it takes a bytestring. This commit re-implements the function so as to make it compatible with both Python 2 and Python 3.7, by avoiding the call to os.write entirely. Instead, we convert the the file descriptor that mkstemp returned, and use the regular methods of the File class from there. This allows us to use a "with" clause, combined with contextlib.closing to automate the closing of that file once we're done writing to it. Change-Id: Ie3a46d1c2672e801c56488f452dfcece33c0ea77 TN: T605-002