Status: | Merged |
---|---|
Merged at revision: | 496 |
Proposed branch: | lp:~afb/pyliblzma/py2x |
Merge into: | lp:pyliblzma |
Diff against target: |
519 lines (+148/-11) 9 files modified
setup.py (+14/-7) src/liblzma.c (+30/-0) src/liblzma.h (+18/-0) src/liblzma_compressobj.c (+13/-0) src/liblzma_decompressobj.c (+15/-1) src/liblzma_fileobj.c (+21/-0) src/liblzma_options.c (+27/-0) src/liblzma_util.c (+4/-0) tests/test_liblzma.py (+6/-3) |
To merge this branch: | bzr merge lp:~afb/pyliblzma/py2x |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Per Øyvind Karlsen | Approve | ||
Review via email: mp+31839@code.launchpad.net |
Commit message
Description of the change
The branch adds backwards compatibility for python versions 2.3 through 2.6
There are NO changes for python 2.7, only fallbacks for new features missing
To post a comment you must log in.
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'setup.py' |
2 | --- setup.py 2010-05-27 18:48:15 +0000 |
3 | +++ setup.py 2010-08-05 13:18:45 +0000 |
4 | @@ -21,10 +21,18 @@ |
5 | # License along with this library; if not, write to the Free Software |
6 | # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
7 | # |
8 | -import sys, os, subprocess |
9 | +import sys, os |
10 | from warnings import warn |
11 | from setuptools import setup, Extension |
12 | |
13 | +try: |
14 | + import subprocess |
15 | + def popen(command): |
16 | + return subprocess.Popen(command, |
17 | + shell=True, stdout=subprocess.PIPE, close_fds=True).stdout |
18 | +except ImportError: |
19 | + popen = os.popen |
20 | + |
21 | descr = "Python bindings for liblzma" |
22 | long_descr = """PylibLZMA provides a python interface for the liblzma library |
23 | to read and write data that has been compressed or can be decompressed |
24 | @@ -41,16 +49,15 @@ |
25 | warnflags = ['-Wall', '-Wextra', '-pedantic', '-Wswitch-enum', '-Wswitch-default'] |
26 | compile_args.extend(warnflags) |
27 | link_args = [] |
28 | -if not subprocess.Popen('touch gnu99-test.c; gcc -std=gnu99 -E gnu99-test.c > /dev/null; rm -f gnu99-test.c', |
29 | - shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, close_fds=True).stdout.read(): |
30 | +if not popen('touch gnu99-test.c; gcc -std=gnu99 -E gnu99-test.c 2>&1 >/dev/null; rm -f gnu99-test.c').read(): |
31 | compile_args.append('-std=gnu99') |
32 | |
33 | -pc_cflags = subprocess.Popen("pkg-config --cflags liblzma", shell=True, stdout=subprocess.PIPE, close_fds=True).stdout.readline().strip() |
34 | +pc_cflags = popen("pkg-config --cflags liblzma").readline().strip() |
35 | if(pc_cflags): |
36 | - compile_args.extend(pc_cflags.split(' ')) |
37 | -pc_libs = subprocess.Popen("pkg-config --libs liblzma", shell=True, stdout=subprocess.PIPE, close_fds=True).stdout.readline().strip() |
38 | + compile_args.extend(str(pc_cflags).split(' ')) |
39 | +pc_libs = popen("pkg-config --libs liblzma").readline().strip() |
40 | if(pc_libs): |
41 | - link_args.extend(pc_libs.split(b' ')) |
42 | + link_args.extend(str(pc_libs).split(' ')) |
43 | |
44 | extens=[Extension('lzma', c_files, extra_compile_args=compile_args, extra_link_args=link_args, define_macros=version_define)] |
45 | |
46 | |
47 | === modified file 'src/liblzma.c' |
48 | --- src/liblzma.c 2010-04-13 21:05:20 +0000 |
49 | +++ src/liblzma.c 2010-08-05 13:18:45 +0000 |
50 | @@ -20,7 +20,9 @@ |
51 | LZMA_compress(__attribute__((unused)) PyObject *self, PyObject *args, PyObject *kwargs) |
52 | { |
53 | PyObject *ret = NULL, *options_dict = NULL; |
54 | +#if USE_PYBUFFER |
55 | Py_buffer pdata; |
56 | +#endif |
57 | uint8_t *data; |
58 | Py_ssize_t datasize, bufsize; |
59 | lzma_ret lzuerror; |
60 | @@ -31,16 +33,24 @@ |
61 | |
62 | static char *kwlist[] = {"input", "options", NULL}; |
63 | |
64 | +#if USE_PYBUFFER |
65 | if (!PyArg_ParseTupleAndKeywords(args, kwargs, "s*|O:compress", kwlist, |
66 | &pdata, &options_dict)) |
67 | return NULL; |
68 | +#else |
69 | + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "s#|O:compress", kwlist, |
70 | + (char **) &data, &datasize, &options_dict)) |
71 | + return NULL; |
72 | +#endif |
73 | |
74 | filters[0].options = &options; |
75 | if(!init_lzma_options("compress", options_dict, filters)) |
76 | return NULL; |
77 | |
78 | +#if USE_PYBUFFER |
79 | data = pdata.buf; |
80 | datasize = pdata.len; |
81 | +#endif |
82 | |
83 | lzma_stream tmp = LZMA_STREAM_INIT; |
84 | *lzus = tmp; |
85 | @@ -95,14 +105,18 @@ |
86 | _PyString_Resize(&ret, (Py_ssize_t)lzus->total_out); |
87 | } |
88 | |
89 | +#if USE_PYBUFFER |
90 | PyBuffer_Release(&pdata); |
91 | +#endif |
92 | return ret; |
93 | |
94 | error: |
95 | if(lzuerror != LZMA_MEM_ERROR && lzuerror != LZMA_PROG_ERROR) |
96 | lzma_end(lzus); |
97 | Py_XDECREF(ret); |
98 | +#if USE_PYBUFFER |
99 | PyBuffer_Release(&pdata); |
100 | +#endif |
101 | return NULL; |
102 | } |
103 | |
104 | @@ -120,7 +134,9 @@ |
105 | LZMA_decompress(__attribute__((unused)) PyObject *self, PyObject *args, PyObject *kwargs) |
106 | { |
107 | PyObject *ret = NULL; |
108 | +#if USE_PYBUFFER |
109 | Py_buffer pdata; |
110 | +#endif |
111 | uint8_t *data; |
112 | Py_ssize_t datasize, bufsize = SMALLCHUNK; |
113 | uint64_t memlimit = -1; |
114 | @@ -130,20 +146,30 @@ |
115 | |
116 | static char *kwlist[] = {"input", "bufsize", "memlimit", NULL}; |
117 | |
118 | +#if USE_PYBUFFER |
119 | if (!PyArg_ParseTupleAndKeywords(args, kwargs, "s*|lK:decompress", kwlist, |
120 | &pdata, &bufsize, &memlimit)) |
121 | return NULL; |
122 | data = pdata.buf; |
123 | datasize = pdata.len; |
124 | +#else |
125 | + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "s#|lK:decompress", kwlist, |
126 | + (char **) &data, &datasize, &memlimit)) |
127 | + return NULL; |
128 | +#endif |
129 | |
130 | if (datasize == 0) { |
131 | +#if USE_PYBUFFER |
132 | PyBuffer_Release(&pdata); |
133 | +#endif |
134 | return PyString_FromString(""); |
135 | } |
136 | |
137 | ret = PyString_FromStringAndSize(NULL, bufsize); |
138 | if (!ret) { |
139 | +#if USE_PYBUFFER |
140 | PyBuffer_Release(&pdata); |
141 | +#endif |
142 | return NULL; |
143 | } |
144 | |
145 | @@ -180,7 +206,9 @@ |
146 | |
147 | _PyString_Resize(&ret, (Py_ssize_t)lzus->total_out); |
148 | lzma_end(lzus); |
149 | +#if USE_PYBUFFER |
150 | PyBuffer_Release(&pdata); |
151 | +#endif |
152 | |
153 | return ret; |
154 | |
155 | @@ -188,7 +216,9 @@ |
156 | if(lzuerror != LZMA_MEM_ERROR && lzuerror != LZMA_PROG_ERROR) |
157 | lzma_end(lzus); |
158 | Py_XDECREF(ret); |
159 | +#if USE_PYBUFFER |
160 | PyBuffer_Release(&pdata); |
161 | +#endif |
162 | return NULL; |
163 | } |
164 | |
165 | |
166 | === modified file 'src/liblzma.h' |
167 | --- src/liblzma.h 2010-02-20 23:08:09 +0000 |
168 | +++ src/liblzma.h 2010-08-05 13:18:45 +0000 |
169 | @@ -6,6 +6,24 @@ |
170 | */ |
171 | #define PY_SSIZE_T_CLEAN 1 |
172 | #include <Python.h> |
173 | +#if PY_VERSION_HEX >= 0x020600F0 |
174 | +#define USE_PYBUFFER 1 |
175 | +#define USE_USECOUNT 1 |
176 | +#else |
177 | +#define Py_TYPE(op) (op)->ob_type |
178 | +#define PyOS_stricmp strcasecmp |
179 | +#define USE_PYBUFFER 0 |
180 | +#define USE_USECOUNT 0 |
181 | +#endif |
182 | +#if PY_VERSION_HEX < 0x020500F0 |
183 | +typedef int Py_ssize_t; |
184 | +#endif |
185 | +#if PY_VERSION_HEX < 0x020400F0 |
186 | +#define Py_RETURN_NONE return Py_INCREF(Py_None), Py_None |
187 | +#define Py_CLEAR(op) do { if (op) { PyObject *tmp = (PyObject *)(op); \ |
188 | + (op) = NULL; Py_DECREF(tmp); } } while(0) |
189 | +#define PyDict_Contains(p, key) (PyDict_GetItem(p, key) != NULL) |
190 | +#endif |
191 | #include <stdio.h> |
192 | #include <stdlib.h> |
193 | #if defined (__APPLE__) || defined(__FreeBSD__) || \ |
194 | |
195 | === modified file 'src/liblzma_compressobj.c' |
196 | --- src/liblzma_compressobj.c 2010-04-13 20:26:35 +0000 |
197 | +++ src/liblzma_compressobj.c 2010-08-05 13:18:45 +0000 |
198 | @@ -14,7 +14,9 @@ |
199 | static PyObject * |
200 | LZMAComp_compress(LZMACompObject *self, PyObject *args) |
201 | { |
202 | +#if USE_PYBUFFER |
203 | Py_buffer pdata; |
204 | +#endif |
205 | Py_ssize_t datasize, bufsize = SMALLCHUNK; |
206 | uint8_t *data; |
207 | uint64_t totalout; |
208 | @@ -23,10 +25,15 @@ |
209 | lzma_ret lzuerror; |
210 | |
211 | INITCHECK |
212 | +#if USE_PYBUFFER |
213 | if (!PyArg_ParseTuple(args, "s*:compress", &pdata)) |
214 | return NULL; |
215 | data = pdata.buf; |
216 | datasize = pdata.len; |
217 | +#else |
218 | + if (!PyArg_ParseTuple(args, "s#:compress", (char **) &data, &datasize)) |
219 | + return NULL; |
220 | +#endif |
221 | |
222 | ACQUIRE_LOCK(self); |
223 | if (!self->running) { |
224 | @@ -65,12 +72,16 @@ |
225 | _PyString_Resize(&ret, (Py_ssize_t)lzus->total_out - (Py_ssize_t)totalout); |
226 | |
227 | RELEASE_LOCK(self); |
228 | +#if USE_PYBUFFER |
229 | PyBuffer_Release(&pdata); |
230 | +#endif |
231 | return ret; |
232 | |
233 | error: |
234 | RELEASE_LOCK(self); |
235 | +#if USE_PYBUFFER |
236 | PyBuffer_Release(&pdata); |
237 | +#endif |
238 | Py_XDECREF(ret); |
239 | return NULL; |
240 | } |
241 | @@ -364,5 +375,7 @@ |
242 | 0, /*tp_subclasses*/ |
243 | 0, /*tp_weaklist*/ |
244 | 0, /*tp_del*/ |
245 | +#if PY_VERSION_HEX >= 0x020600F0 /* Added in version 2.6 */ |
246 | 0 /*tp_version_tag*/ |
247 | +#endif |
248 | }; |
249 | |
250 | === modified file 'src/liblzma_decompressobj.c' |
251 | --- src/liblzma_decompressobj.c 2010-01-13 08:28:17 +0000 |
252 | +++ src/liblzma_decompressobj.c 2010-08-05 13:18:45 +0000 |
253 | @@ -16,7 +16,9 @@ |
254 | static PyObject * |
255 | LZMADecomp_decompress(LZMADecompObject *self, PyObject *args, PyObject *kwargs) |
256 | { |
257 | +#if USE_PYBUFFER |
258 | Py_buffer pdata; |
259 | +#endif |
260 | Py_ssize_t datasize, oldbufsize, bufsize = SMALLCHUNK; |
261 | uint8_t *data; |
262 | uint64_t start_total_out; |
263 | @@ -26,11 +28,17 @@ |
264 | static char *kwlist[] = {"data", "max_length", NULL}; |
265 | |
266 | INITCHECK |
267 | +#if USE_PYBUFFER |
268 | if (!PyArg_ParseTupleAndKeywords(args, kwargs, "s*|l:decompress", kwlist, |
269 | &pdata, &self->max_length)) |
270 | return NULL; |
271 | data = pdata.buf; |
272 | datasize = pdata.len; |
273 | +#else |
274 | + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "s#|l:decompress", kwlist, |
275 | + (char **) &data, &datasize, &self->max_length)) |
276 | + return NULL; |
277 | +#endif |
278 | |
279 | ACQUIRE_LOCK(self); |
280 | if (!self->running) { |
281 | @@ -121,12 +129,16 @@ |
282 | _PyString_Resize(&ret, (Py_ssize_t)lzus->total_out - (Py_ssize_t)start_total_out); |
283 | |
284 | RELEASE_LOCK(self); |
285 | +#if USE_PYBUFFER |
286 | PyBuffer_Release(&pdata); |
287 | +#endif |
288 | return ret; |
289 | |
290 | error: |
291 | RELEASE_LOCK(self); |
292 | +#if USE_PYBUFFER |
293 | PyBuffer_Release(&pdata); |
294 | +#endif |
295 | Py_XDECREF(ret); |
296 | return NULL; |
297 | } |
298 | @@ -339,7 +351,7 @@ |
299 | lzma_stream *lzus = &self->lzus; |
300 | lzma_ret lzuerror; |
301 | |
302 | - static char *kwlist[] = {"input", "max_length", "memlimit", NULL}; |
303 | + static char *kwlist[] = {"max_length", "memlimit", NULL}; |
304 | |
305 | if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|lK:LZMADecompressor", kwlist, |
306 | &self->max_length, &self->memlimit)) |
307 | @@ -434,5 +446,7 @@ |
308 | 0, /*tp_subclasses*/ |
309 | 0, /*tp_weaklist*/ |
310 | 0, /*tp_del*/ |
311 | +#if PY_VERSION_HEX >= 0x020600F0 /* Added in version 2.6 */ |
312 | 0 /*tp_version_tag*/ |
313 | +#endif |
314 | }; |
315 | |
316 | === modified file 'src/liblzma_fileobj.c' |
317 | --- src/liblzma_fileobj.c 2010-01-13 08:28:17 +0000 |
318 | +++ src/liblzma_fileobj.c 2010-08-05 13:18:45 +0000 |
319 | @@ -314,15 +314,22 @@ |
320 | LZMAFile_write(LZMAFileObject *self, PyObject *args) |
321 | { |
322 | PyObject *ret = NULL; |
323 | +#if USE_PYBUFFER |
324 | Py_buffer pbuf; |
325 | +#endif |
326 | char *buf; |
327 | Py_ssize_t len; |
328 | lzma_ret lzuerror; |
329 | |
330 | +#if USE_PYBUFFER |
331 | if (!PyArg_ParseTuple(args, "s*:write", &pbuf)) |
332 | return NULL; |
333 | buf = pbuf.buf; |
334 | len = pbuf.len; |
335 | +#else |
336 | + if (!PyArg_ParseTuple(args, "s#:write", &buf, &len)) |
337 | + return NULL; |
338 | +#endif |
339 | |
340 | ACQUIRE_LOCK(self); |
341 | switch (self->mode) { |
342 | @@ -358,7 +365,9 @@ |
343 | ret = Py_None; |
344 | |
345 | cleanup: |
346 | +#if USE_PYBUFFER |
347 | PyBuffer_Release(&pbuf); |
348 | +#endif |
349 | RELEASE_LOCK(self); |
350 | return ret; |
351 | } |
352 | @@ -596,7 +605,9 @@ |
353 | /* we cannot move back, so rewind the stream */ |
354 | lzma_close_real(&lzuerror, self->fp); |
355 | if (self->fp) { |
356 | +#if USE_USECOUNT |
357 | PyFile_DecUseCount((PyFileObject *)self->file); |
358 | +#endif |
359 | self->fp = NULL; |
360 | } |
361 | if (lzuerror != LZMA_OK) { |
362 | @@ -611,8 +622,10 @@ |
363 | self->pos = 0; |
364 | self->fp = lzma_open_real(&lzuerror, self->filters, PyFile_AsFile(self->file), self->memlimit); |
365 | |
366 | +#if USE_USECOUNT |
367 | if (self->fp) |
368 | PyFile_IncUseCount((PyFileObject *)self->file); |
369 | +#endif |
370 | if (lzuerror != LZMA_OK) { |
371 | Util_CatchLZMAError(lzuerror, &self->fp->strm, self->fp->encoding); |
372 | goto cleanup; |
373 | @@ -704,7 +717,9 @@ |
374 | ACQUIRE_LOCK(self); |
375 | lzma_close_real(&lzuerror, self->fp); |
376 | if (self->fp) { |
377 | +#if USE_USECOUNT |
378 | PyFile_DecUseCount((PyFileObject *)self->file); |
379 | +#endif |
380 | self->fp = NULL; |
381 | } |
382 | self->mode = MODE_CLOSED; |
383 | @@ -931,7 +946,9 @@ |
384 | Util_CatchLZMAError(lzuerror, &self->fp->strm, self->fp->encoding); |
385 | goto error; |
386 | } |
387 | +#if USE_USECOUNT |
388 | PyFile_IncUseCount((PyFileObject *)self->file); |
389 | +#endif |
390 | |
391 | self->mode = self->filters[0].options ? MODE_WRITE : MODE_READ; |
392 | |
393 | @@ -958,7 +975,9 @@ |
394 | #endif |
395 | lzma_close_real(&lzuerror, self->fp); |
396 | if (self->fp) { |
397 | +#if USE_USECOUNT |
398 | PyFile_DecUseCount((PyFileObject *)self->file); |
399 | +#endif |
400 | self->fp = NULL; |
401 | } |
402 | Util_DropReadAhead(self); |
403 | @@ -1073,5 +1092,7 @@ |
404 | 0, /*tp_subclasses*/ |
405 | 0, /*tp_weaklist*/ |
406 | 0, /*tp_del*/ |
407 | +#if PY_VERSION_HEX >= 0x020600F0 /* Added in version 2.6 */ |
408 | 0 /*tp_version_tag*/ |
409 | +#endif |
410 | }; |
411 | |
412 | === modified file 'src/liblzma_options.c' |
413 | --- src/liblzma_options.c 2010-05-28 20:13:21 +0000 |
414 | +++ src/liblzma_options.c 2010-08-05 13:18:45 +0000 |
415 | @@ -246,6 +246,7 @@ |
416 | LZMAOptionsObject *self = (LZMAOptionsObject*)PyType_GenericAlloc(type, nitems); |
417 | PyObject *levelopts, *levelString, *mf_list; |
418 | |
419 | +#if PY_VERSION_HEX >= 0x020400F0 |
420 | self->format = PyTuple_Pack(2, PyString_FromString("xz"), PyString_FromString("alone")); |
421 | format = self->format; |
422 | self->check = PyTuple_Pack(3, PyString_FromString("crc32"), PyString_FromString("crc64"), |
423 | @@ -264,6 +265,26 @@ |
424 | self->mode_dict = PyDict_New(); |
425 | self->nice_len = PyTuple_Pack(2, PyInt_FromLong((ulong)LZMA_NICE_LEN_MIN), |
426 | PyInt_FromLong((ulong)LZMA_NICE_LEN_MAX)); |
427 | +#else |
428 | + self->format = Py_BuildValue("(OO)", PyString_FromString("xz"), PyString_FromString("alone")); |
429 | + format = self->format; |
430 | + self->check = Py_BuildValue("(OOO)", PyString_FromString("crc32"), PyString_FromString("crc64"), |
431 | + PyString_FromString("sha256")); |
432 | + check = self->check; |
433 | + self->level = Py_BuildValue("(OO)", PyInt_FromLong((ulong)LZMA_BEST_SPEED), |
434 | + PyInt_FromLong((ulong)LZMA_BEST_COMPRESSION)); |
435 | + self->dict_size = Py_BuildValue("(OO)", PyInt_FromLong((ulong)LZMA_DICT_SIZE_MIN), |
436 | + PyInt_FromLong((ulong)LZMA_DICT_SIZE_MAX)); |
437 | + self->lc = Py_BuildValue("(OO)", PyInt_FromLong((ulong)LZMA_LCLP_MIN), |
438 | + PyInt_FromLong((ulong)LZMA_LCLP_MAX)); |
439 | + self->lp = Py_BuildValue("(OO)", PyInt_FromLong((ulong)LZMA_LCLP_MIN), |
440 | + PyInt_FromLong((ulong)LZMA_LCLP_MAX)); |
441 | + self->pb = Py_BuildValue("(OO)", PyInt_FromLong((ulong)LZMA_PB_MIN), |
442 | + PyInt_FromLong((ulong)LZMA_PB_MAX)); |
443 | + self->mode_dict = PyDict_New(); |
444 | + self->nice_len = Py_BuildValue("(OO)", PyInt_FromLong((ulong)LZMA_NICE_LEN_MIN), |
445 | + PyInt_FromLong((ulong)LZMA_NICE_LEN_MAX)); |
446 | +#endif |
447 | self->mf_dict = PyDict_New(); |
448 | self->depth = PyInt_FromLong(0); |
449 | |
450 | @@ -307,7 +328,11 @@ |
451 | lzma_lzma_preset(&options, levelNum); |
452 | lzma_filter filter = { LZMA_FILTER_LZMA2, &options }; |
453 | PyObject *options_dict = LZMA_options_get(filter); |
454 | +#if PY_VERSION_HEX >= 0x020400F0 |
455 | PyObject *settingsString = PyString_Format(levelopts, PyTuple_Pack(9, |
456 | +#else |
457 | + PyObject *settingsString = PyString_Format(levelopts, Py_BuildValue("(OOOOOOOOO)", |
458 | +#endif |
459 | PyInt_FromLong(levelNum), |
460 | PyDict_GetItem(options_dict, PyString_FromString("lc")), |
461 | PyDict_GetItem(options_dict, PyString_FromString("lp")), |
462 | @@ -460,5 +485,7 @@ |
463 | 0, /*tp_subclasses*/ |
464 | 0, /*tp_weaklist*/ |
465 | 0, /*tp_del*/ |
466 | +#if PY_VERSION_HEX >= 0x020600F0 /* Added in version 2.6 */ |
467 | 0 /*tp_version_tag*/ |
468 | +#endif |
469 | }; |
470 | |
471 | === modified file 'src/liblzma_util.c' |
472 | --- src/liblzma_util.c 2010-01-13 08:28:17 +0000 |
473 | +++ src/liblzma_util.c 2010-08-05 13:18:45 +0000 |
474 | @@ -13,7 +13,11 @@ |
475 | break; |
476 | |
477 | case LZMA_NO_CHECK: |
478 | +#if PY_VERSION_HEX >= 0x020500F0 |
479 | PyErr_WarnEx(LZMAError, "stream has no integrity check", 1); |
480 | +#else |
481 | + PyErr_Warn(LZMAError, "stream has no integrity check"); |
482 | +#endif |
483 | break; |
484 | |
485 | case LZMA_UNSUPPORTED_CHECK: |
486 | |
487 | === modified file 'tests/test_liblzma.py' |
488 | --- tests/test_liblzma.py 2010-04-13 20:29:41 +0000 |
489 | +++ tests/test_liblzma.py 2010-08-05 13:18:45 +0000 |
490 | @@ -29,7 +29,10 @@ |
491 | import os |
492 | from test.test_support import TESTFN |
493 | |
494 | -from hashlib import md5 |
495 | +try: |
496 | + from hashlib import md5 |
497 | +except ImportError: |
498 | + from md5 import md5 |
499 | from binascii import unhexlify, hexlify |
500 | from cStringIO import StringIO |
501 | from StringIO import StringIO as PyStringIO |
502 | @@ -606,7 +609,7 @@ |
503 | # checksum test cases |
504 | def test_crc32start(self): |
505 | self.assertEqual(lzma.crc32(""), lzma.crc32("", 0)) |
506 | - self.assert_(lzma.crc32("abc", 0xffffffff)) |
507 | + self.assert_(lzma.crc32("abc", 0xffffffffL)) |
508 | |
509 | def test_crc32empty(self): |
510 | self.assertEqual(lzma.crc32("", 0), 0) |
511 | @@ -627,7 +630,7 @@ |
512 | # These crc64 tests needs to be reviewed.. |
513 | def test_crc64start(self): |
514 | self.assertEqual(lzma.crc64(""), lzma.crc64("", 0)) |
515 | - self.assert_(lzma.crc64("abc", 0xffffffff)) |
516 | + self.assert_(lzma.crc64("abc", 0xffffffffL)) |
517 | |
518 | def test_crc64empty(self): |
519 | self.assertEqual(lzma.crc64("", 0), 0) |
Thx!