Skip to content

Commit 23b4ce6

Browse files
committed
Merge pull request #66 from qiniu/develop
release v6.1.2
2 parents 00d23a2 + 7c8de38 commit 23b4ce6

File tree

5 files changed

+23
-9
lines changed

5 files changed

+23
-9
lines changed

CHANGELOG.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,19 @@
11
## CHANGE LOG
22

3+
### v6.1.2
4+
5+
2013-08-01 issue [#66](https://github.com/qiniu/python-sdk/pull/66)
6+
7+
- 修复在Windows环境下put_file无法读取文件的bug
8+
- 修复在Windows环境下创建临时文件的权限问题
9+
- 修复在Windows环境下对二进制文件计算crc32的bug
10+
311
### v6.1.1
412

513
2013-07-05 issue [#60](https://github.com/qiniu/python-sdk/pull/60)
614

715
- 整理文档
816

9-
1017
### v6.1.0
1118

1219
2013-07-03 issue [#58](https://github.com/qiniu/python-sdk/pull/58)

qiniu/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@
77
'''
88

99
# -*- coding: utf-8 -*-
10-
__version__ = '6.1.1'
10+
__version__ = '6.1.2'

qiniu/io.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,14 +61,14 @@ def put_file(uptoken, key, localfile, extra=None):
6161
"""
6262
if extra is not None and extra.check_crc == 1:
6363
extra.crc32 = _get_file_crc32(localfile)
64-
with open(localfile) as f:
64+
with open(localfile, 'rb') as f:
6565
return put(uptoken, key, f, extra)
6666

6767

6868
_BLOCK_SIZE = 1024 * 1024 * 4
6969

7070
def _get_file_crc32(filepath):
71-
with open(filepath) as f:
71+
with open(filepath, 'rb') as f:
7272
block = f.read(_BLOCK_SIZE)
7373
crc = 0
7474
while len(block) != 0:

qiniu/test/io_test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ def test_get_file_crc32(self):
171171
file_path = '%s' % __file__
172172

173173
data = None
174-
with open(file_path) as f:
174+
with open(file_path, 'rb') as f:
175175
data = f.read()
176176
io._BLOCK_SIZE = 4
177177
assert binascii.crc32(data) & 0xFFFFFFFF == io._get_file_crc32(file_path)

qiniu/test/resumable_io_test.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import unittest
44
import string
55
import random
6+
import platform
67
try:
78
import zlib as binascii
89
except ImportError:
@@ -34,7 +35,7 @@ def test_block(self):
3435
rets = [0, 0]
3536
data_slice_2 = "\nbye!"
3637
ret, err = resumable_io.mkblock(client, len(data_slice_2), data_slice_2)
37-
assert err is None, err
38+
assert err is None, err
3839
self.assertEqual(ret["crc32"], binascii.crc32(data_slice_2))
3940

4041
extra = resumable_io.PutExtra(bucket)
@@ -49,10 +50,15 @@ def test_block(self):
4950
assert err is None, err
5051
self.assertEqual(ret["hash"], "FtCFo0mQugW98uaPYgr54Vb1QsO0", "hash not match")
5152
rs.Client().delete(bucket, key)
52-
53+
5354
def test_put(self):
5455
src = urllib.urlopen("http://cheneya.qiniudn.com/hello_jpg")
55-
dst = tempfile.NamedTemporaryFile()
56+
ostype = platform.system()
57+
if ostype.lower().find("windows") != -1:
58+
tmpf = "".join([os.getcwd(), os.tmpnam()])
59+
else:
60+
tmpf = os.tmpnam()
61+
dst = open(tmpf, 'wb')
5662
shutil.copyfileobj(src, dst)
5763
src.close()
5864

@@ -63,11 +69,12 @@ def test_put(self):
6369
localfile = dst.name
6470
ret, err = resumable_io.put_file(policy.token(), key, localfile, extra)
6571
dst.close()
72+
os.remove(tmpf)
6673

6774
assert err is None, err
6875
self.assertEqual(ret["hash"], "FnyTMUqPNRTdk1Wou7oLqDHkBm_p", "hash not match")
6976
rs.Client().delete(bucket, key)
70-
77+
7178

7279
if __name__ == "__main__":
7380
unittest.main()

0 commit comments

Comments
 (0)