From 29f2dff4b0b6ce1d0727fcaa88851ac1bcf308d8 Mon Sep 17 00:00:00 2001 From: sbz Date: Mon, 17 Sep 2012 16:34:54 +0000 Subject: - Fix bytes problem returned by urlopen when using Python 3.x --- Tools/scripts/getpatch | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'Tools/scripts') diff --git a/Tools/scripts/getpatch b/Tools/scripts/getpatch index d8729ec93d3a..9c278ccd0086 100755 --- a/Tools/scripts/getpatch +++ b/Tools/scripts/getpatch @@ -57,7 +57,7 @@ class GetPatch(object): if filename.endswith(('.patch', '.txt')): filename = filename[:filename.rindex('.')]+'.diff' f=open(filename, 'w') - f.write(data) + f.write(data.decode()) f.close() self.out("[+] %s created" % filename) @@ -79,7 +79,7 @@ class GetPatch(object): data = urllib2.urlopen(url).read() if self.output_stdout: - sys.stdout.write(data) + sys.stdout.write(data.decode()) else: self.write(p, data) @@ -107,7 +107,7 @@ class GnatsGetPatch(GetPatch): self.out("[-] No patch found") sys.exit(1) - for patchs in re.findall(pattern, data): + for patchs in re.findall(pattern, str(data)): self.patchs.append({'url': patchs[0], 'name': patchs[1]}) class BzGetPatch(GetPatch): @@ -155,7 +155,7 @@ class BzGetPatch(GetPatch): self.out("[-] No patch found") sys.exit(1) - for i in xrange(nb_urls): + for i in range(nb_urls): self.patchs.append({'url': urls[i], 'name': names[i]}) def main(): -- cgit