Browse Source

Use six.StringIO/BytesIO instead of StringIO.StringIO

to keep Python 3.x compatibility, use six.StringIO/BytesIO to
replace StringIO.StringIO

StringIO works for unicode
BytesIO works for bytes

Change-Id: I063d62a4f005084f4088da403f348ad97656ad45
Partial-Bug: #1280100
tags/10.0.0
Harshada Mangesh Kakad 3 years ago
parent
commit
b3ecf6534f
2 changed files with 4 additions and 4 deletions
  1. 2
    2
      tools/check_logs.py
  2. 2
    2
      tools/find_stack_traces.py

+ 2
- 2
tools/check_logs.py View File

@@ -19,7 +19,7 @@ import argparse
19 19
 import gzip
20 20
 import os
21 21
 import re
22
-import StringIO
22
+import six
23 23
 import sys
24 24
 import urllib2
25 25
 
@@ -71,7 +71,7 @@ def process_files(file_specs, url_specs, whitelists):
71 71
         req = urllib2.Request(url)
72 72
         req.add_header('Accept-Encoding', 'gzip')
73 73
         page = urllib2.urlopen(req)
74
-        buf = StringIO.StringIO(page.read())
74
+        buf = six.StringIO(page.read())
75 75
         f = gzip.GzipFile(fileobj=buf)
76 76
         if scan_content(name, f.read().splitlines(), regexp, whitelist):
77 77
             logs_with_errors.append(name)

+ 2
- 2
tools/find_stack_traces.py View File

@@ -18,7 +18,7 @@
18 18
 import gzip
19 19
 import pprint
20 20
 import re
21
-import StringIO
21
+import six
22 22
 import sys
23 23
 import urllib2
24 24
 
@@ -68,7 +68,7 @@ def hunt_for_stacktrace(url):
68 68
     req = urllib2.Request(url)
69 69
     req.add_header('Accept-Encoding', 'gzip')
70 70
     page = urllib2.urlopen(req)
71
-    buf = StringIO.StringIO(page.read())
71
+    buf = six.StringIO(page.read())
72 72
     f = gzip.GzipFile(fileobj=buf)
73 73
     content = f.read()
74 74
 

Loading…
Cancel
Save