#744 patch: Execute subprocess in text mode
Merged by onosek. Opened by ferdnyc.
ferdnyc/rpkg fix-patch-encoding  into  master

Download 744.patch

This prevents fedpkg patch suffix aborting with the error message
"Could not execute patch: write() argument must be str, not bytes".

Signed-off-by: FeRD (Frank Dana) ferdnyc@gmail.com

(Specifically, the error occurs when patch reaches these lines:

        # Write out the patch
        open(os.path.join(self.path, outfile), 'w').write(output)

...and output is a bytes object.)

Note: If Python 3.6 is still meant to be supported (I notice PR #730 from only a few months ago), then this PR will break compatibility because subprocess.Popen() didn't take a text= argument until Python 3.7.

Of course, Python 3.6 has been past end-of-life since December 2021...

The reason the CI doesn't fail in tox -e py36, despite my incompatible change, is that tests/commands/test_patch.py... never actually calls cmd.patch(). It only tests cmd._byte_offset_to_line_number().

(This also explains why the tests have been passing under all versions, despite subprocess.Popen() not being called correctly in patch().)

rebased onto 266ce739a075c6cee1a0221fd8faf0fc823daf37

You're right the Python 3.6 in Fedora has been the history for some time already. But rpkg is used internally for some Red Hat product, which is still supported in older releases. Therefore, I am trying to keep this backwards compatibility.

universal_newlines=True is still there for compatibility - I will replace text=True with it.

Commit f828c71a fixes this pull-request

Pull-Request has been merged by onosek

Metadata