[oe-commits] [openembedded-core] 03/77: combo-layer: fix crashes on wrong tempfile usage

git at git.openembedded.org git at git.openembedded.org
Tue Oct 25 10:32:10 UTC 2016


rpurdie pushed a commit to branch master-next
in repository openembedded-core.

commit afc6dc99683a6f7db04c14d191912e400094a27f
Author: Olaf Mandel <o.mandel at menlosystems.com>
AuthorDate: Mon Oct 17 08:16:27 2016 +0000

    combo-layer: fix crashes on wrong tempfile usage
    
    When calling tempfile.NamedTemporaryFile().write(str()), at least on
    Python 3.4.2 this fails with this error:
    TypeError: 'str' does not support the buffer interface
    
    Change the file-mode for all such files from binary to text mode.
    
    Signed-off-by: Olaf Mandel <o.mandel at menlosystems.com>
    Signed-off-by: Ross Burton <ross.burton at intel.com>
---
 scripts/combo-layer | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/scripts/combo-layer b/scripts/combo-layer
index b90bfc8..4a210fb 100755
--- a/scripts/combo-layer
+++ b/scripts/combo-layer
@@ -329,7 +329,7 @@ def action_init(conf, args):
                         # one. The commit should be in both repos with
                         # the same tree, but better check here.
                         tree = runcmd('git show -s --pretty=format:%%T %s' % rev).strip()
-                        with tempfile.NamedTemporaryFile() as editor:
+                        with tempfile.NamedTemporaryFile(mode='wt') as editor:
                             editor.write('''cat >$1 <<EOF
 tree %s
 author %s
@@ -353,7 +353,7 @@ EOF
                 # Optional: rewrite history to change commit messages or to move files.
                 if 'hook' in repo or dest_dir != ".":
                     filter_branch = ['git', 'filter-branch', '--force']
-                    with tempfile.NamedTemporaryFile() as hookwrapper:
+                    with tempfile.NamedTemporaryFile(mode='wt') as hookwrapper:
                         if 'hook' in repo:
                             # Create a shell script wrapper around the original hook that
                             # can be used by git filter-branch. Hook may or may not have
@@ -1137,7 +1137,7 @@ def update_with_history(conf, components, revisions, repos):
             if hook:
                 # Need to turn the verbatim commit message into something resembling a patch header
                 # for the hook.
-                with tempfile.NamedTemporaryFile(delete=False) as patch:
+                with tempfile.NamedTemporaryFile(mode='wt', delete=False) as patch:
                     patch.write('Subject: [PATCH] ')
                     patch.write(body)
                     patch.write('\n---\n')

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the Openembedded-commits mailing list