Skip to content

Commit 0bab303

Browse files
author
y-p
committed
BLD: python3 unicode issue in print_versions
1 parent cbe3e20 commit 0bab303

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

pandas/util/print_versions.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import sys
44
import struct
55
import subprocess
6+
import codecs
67

78

89
def get_sys_info():
@@ -99,14 +100,13 @@ def show_versions(as_json=False):
99100
except:
100101
import simplejson as json
101102

102-
j = json.dumps(
103-
dict(system=dict(sys_info), dependencies=dict(deps_blob)), indent=2)
103+
j = dict(system=dict(sys_info), dependencies=dict(deps_blob))
104104

105105
if as_json == True:
106106
print(j)
107107
else:
108-
with open(as_json, "wb") as f:
109-
f.write(j)
108+
with codecs.open(as_json, "wb", encoding='utf8') as f:
109+
json.dump(j, f, indent=2)
110110

111111
else:
112112

@@ -120,6 +120,7 @@ def show_versions(as_json=False):
120120
for k, stat in deps_blob:
121121
print("%s: %s" % (k, stat))
122122

123+
123124
def main():
124125
# optparse is 2.6-safe
125126
from optparse import OptionParser
@@ -137,4 +138,4 @@ def main():
137138
return 0
138139

139140
if __name__ == "__main__":
140-
sys.exit(main())
141+
sys.exit(main())

0 commit comments

Comments
 (0)