Commit d52d7475 authored by Richard Darst's avatar Richard Darst

Imported Debian patch 0.5.3-1

------------------------------------------------------------
revno: 485
committer: Per Øyvind Karlsen <peroyvind@mandriva.org>
branch nick: pyliblzma
timestamp: Tue 2010-04-13 23:24:57 +0200
message:
update NEWS for 0.5.3
------------------------------------------------------------
revno: 484
committer: Per Øyvind Karlsen <peroyvind@mandriva.org>
branch nick: pyliblzma
timestamp: Tue 2010-04-13 23:24:44 +0200
message:
update path to headers to include
------------------------------------------------------------
revno: 483
committer: Per Øyvind Karlsen <peroyvind@mandriva.org>
branch nick: pyliblzma
timestamp: Tue 2010-04-13 23:06:47 +0200
message:
bump version
------------------------------------------------------------
revno: 482
committer: Per Øyvind Karlsen <peroyvind@mandriva.org>
branch nick: pyliblzma
timestamp: Tue 2010-04-13 23:05:20 +0200
message:
loop untill there's no data left in LZMA_compress() (fixes #537199)
------------------------------------------------------------
revno: 481
committer: Per Øyvind Karlsen <peroyvind@mandriva.org>
branch nick: pyliblzma
timestamp: Tue 2010-04-13 22:29:41 +0200
message:
check the uncompressed stream with lzma_alone format in test_compress_large_stream
------------------------------------------------------------
revno: 480
committer: Per Øyvind Karlsen <peroyvind@mandriva.org>
branch nick: pyliblzma
timestamp: Tue 2010-04-13 22:26:35 +0200
message:
fix flushing not running all the way till it's done (#521975)
------------------------------------------------------------
revno: 479
committer: Per Øyvind Karlsen <peroyvind@mandriva.org>
branch nick: pyliblzma
timestamp: Tue 2010-04-13 22:23:44 +0200
message:
just use generate_Random for data_large
------------------------------------------------------------
revno: 478
committer: Per Øyvind Karlsen <peroyvind@mandriva.org>
branch nick: pyliblzma
timestamp: Fri 2010-04-09 03:59:35 +0200
message:
get random data for testing compression og large block
------------------------------------------------------------
revno: 477
committer: Per Øyvind Karlsen <peroyvind@localhost.localdomain>
branch nick: pyliblzma
timestamp: Sun 2010-02-21 01:53:50 +0100
message:
make code a bit more consistent with bz2module.c for easier maintenance...
------------------------------------------------------------
revno: 476
committer: Per Øyvind Karlsen <peroyvind@localhost.localdomain>
branch nick: pyliblzma
timestamp: Sun 2010-02-21 00:45:54 +0100
message:
- fix segfault with LZMACompressor (#521975) (and sync layout of the related code with bz2module.c a bit too while at it)
------------------------------------------------------------
revno: 475
committer: Per Øyvind Karlsen <peroyvind@localhost.localdomain>
branch nick: pyliblzma
timestamp: Sun 2010-02-21 00:08:09 +0100
message:
from /python/trunk/Modules/bz2module.c:
Issue #7205: Fix a possible deadlock when using a LZMAFile object from several threads at once.
------------------------------------------------------------
revno: 474
committer: Per Øyvind Karlsen <peroyvind@localhost.localdomain>
branch nick: pyliblzma
timestamp: Sat 2010-02-20 21:57:53 +0100
message:
fix a typo
------------------------------------------------------------
revno: 473
committer: Per Øyvind Karlsen <proyvind@gmail.com>
branch nick: pyliblzma
timestamp: Wed 2010-01-13 11:30:00 +0100
message:
update default options string to be consistent with renamed option names
------------------------------------------------------------
revno: 472
committer: Per Øyvind Karlsen <proyvind@gmail.com>
branch nick: pyliblzma
timestamp: Wed 2010-01-13 09:28:17 +0100
message:
move source and headers into a separate sub-directory
------------------------------------------------------------
revno: 471
committer: Per Øyvind Karlsen <proyvind@gmail.com>
branch nick: pyliblzma
timestamp: Sat 2009-11-28 09:07:27 +0100
message:
move 'module' out of header and make it local to initlzma() which is the only place it's being used...
------------------------------------------------------------
revno: 470
committer: Per Øyvind Karlsen <proyvind@gmail.com>
branch nick: pyliblzma
timestamp: Sat 2009-11-28 09:06:07 +0100
message:
make 'module' extern
------------------------------------------------------------
revno: 469
committer: Per Øyvind Karlsen <proyvind@gmail.com>
branch nick: pyliblzma
timestamp: Sat 2009-07-25 00:40:32 +0200
message:
do actually execute test_main()…
------------------------------------------------------------
revno: 468
committer: Per Øyvind Karlsen <proyvind@gmail.com>
branch nick: pyliblzma
timestamp: Fri 2009-07-24 22:24:12 +0200
message:
don't comment out tests in test_main()
------------------------------------------------------------
revno: 467
committer: Per Øyvind Karlsen <proyvind@gmail.com>
branch nick: pyliblzma
timestamp: Fri 2009-07-24 16:43:49 +0200
message:
remove this one as it were never used…
------------------------------------------------------------
revno: 466
committer: Per Øyvind Karlsen <proyvind@gmail.com>
branch nick: trunk
......
include MANIFEST.in ChangeLog COPYING THANKS README NEWS liblzma*.h python-liblzma.spec setup.cfg
include MANIFEST.in ChangeLog COPYING THANKS README NEWS src/liblzma*.h python-liblzma.spec setup.cfg
recursive-include tests *.py
recursive-include tests/data *
Version 0.5.3 - 13 Apr 2010, by Per Øyvind Karlsen <peroyvind@mandriva.org>
- update compression option names in API documentation.
- fix segfault with LZMACompressor (#521975).
- fix compress() & LZMACompressor.flush() finishing when there's still data left.
(#521975 & #537199)
- Synchronize code with bz2module.c from python upstream:
o Issue #7205: Fix a possible deadlock when using a LZMAFile object from
several threads at once.
Version 0.5.2 - 26 Feb 2009, by Per Øyvind Karlsen <peroyvind@mandriva.org>
- Synchronize code with bz2module.c from python upstream.
- Synchronize code with bz2module.c from python upstream:
o fixes various minor issues and bugs.
o support the context manager protocol (adds __enter__() & __enter__()).
o use Py_buffer.
......
Metadata-Version: 1.0
Name: pyliblzma
Version: 0.5.2
Version: 0.5.3
Summary: Python bindings for liblzma
Home-page: https://launchpad.net/pyliblzma
Author: Per Øyvind Karlsen
......
ls
pdebuild --pbuilder cowbuilder
ls ..
lintian ../python-lzma-dbg_0.5.2-3_i386.deb
lintian ../python-lzma-dbg_0.5.2-3_i386.deb --all
lintian ../python-lzma-dbg_0.5.2-3_i386.deb -a
lintian ../python-lzma_0.5.2-3.dsc
man lintian
lintian ../python-lzma_0.5.2-3_i386.deb
python2.6
python2.6-dbg
debdiff ../python-lzma_0.5.2
dput -h ../python-lzma_0.5.2-3.dsc
l debian/control
l debian/changelog
cd ..
python-lzma (0.5.3-1) unstable; urgency=low
* New upstream version
* Upgrade to 3.0 (quilt) just to be able to use .orig.tar.bz2
* Bump standards-version to 3.8.4
-- Richard Darst <rkd@zgib.net> Mon, 19 Apr 2010 14:16:48 -0400
python-lzma (0.5.2-3) unstable; urgency=low
* Rebuild against unstable as python2.6 has migrated to there.
......
......@@ -4,7 +4,7 @@ Priority: optional
Maintainer: Debian Python Modules Team <python-modules-team@lists.alioth.debian.org>
Uploaders: Richard Darst <rkd@zgib.net>
Build-Depends: debhelper (>= 7.0.50~), liblzma-dev, python-all-dev (>= 2.5.4-3~), python-setuptools, pkg-config, python-support, python-all-dbg (>= 2.5.4-3~)
Standards-Version: 3.8.3
Standards-Version: 3.8.4
XS-Python-Version: >= 2.6
Homepage: https://launchpad.net/pyliblzma
Vcs-Svn: svn://svn.debian.org/python-modules/packages/python-lzma/trunk
......
Metadata-Version: 1.0
Name: pyliblzma
Version: 0.5.2
Version: 0.5.3
Summary: Python bindings for liblzma
Home-page: https://launchpad.net/pyliblzma
Author: Per Øyvind Karlsen
......
......@@ -4,21 +4,7 @@ MANIFEST.in
NEWS
README
THANKS
liblzma.c
liblzma.h
liblzma.py
liblzma_compressobj.c
liblzma_compressobj.h
liblzma_decompressobj.c
liblzma_decompressobj.h
liblzma_file.c
liblzma_file.h
liblzma_fileobj.c
liblzma_fileobj.h
liblzma_options.c
liblzma_options.h
liblzma_util.c
liblzma_util.h
python-liblzma.spec
setup.cfg
setup.py
......@@ -26,8 +12,21 @@ pyliblzma.egg-info/PKG-INFO
pyliblzma.egg-info/SOURCES.txt
pyliblzma.egg-info/dependency_links.txt
pyliblzma.egg-info/top_level.txt
src/liblzma.c
src/liblzma.h
src/liblzma_compressobj.c
src/liblzma_compressobj.h
src/liblzma_decompressobj.c
src/liblzma_decompressobj.h
src/liblzma_file.c
src/liblzma_file.h
src/liblzma_fileobj.c
src/liblzma_fileobj.h
src/liblzma_options.c
src/liblzma_options.h
src/liblzma_util.c
src/liblzma_util.h
tests/__init__.py
tests/regrtest.py
tests/test_liblzma.py
tests/data/teststring.lzma
tests/data/teststring.xz
\ No newline at end of file
......@@ -29,7 +29,7 @@ descr = "Python bindings for liblzma"
long_descr = """PylibLZMA provides a python interface for the liblzma library
to read and write data that has been compressed or can be decompressed
by Lasse Collin's xz / lzma utils."""
version = '0.5.2'
version = '0.5.3'
version_define = [('VERSION', '"%s"' % version)]
# FIXME: Probably some nicer way to do this
......@@ -37,6 +37,8 @@ if 'sdist' in sys.argv:
os.system('bzr log . > ChangeLog')
modules = ['liblzma']
c_files = ['liblzma.c', 'liblzma_compressobj.c', 'liblzma_decompressobj.c', 'liblzma_file.c', 'liblzma_fileobj.c', 'liblzma_options.c', 'liblzma_util.c']
for i in xrange(len(c_files)):
c_files[i] = os.path.join('src', c_files[i])
compile_args = []
warnflags = ['-Wall', '-Wextra', '-pedantic', '-Wswitch-enum', '-Wswitch-default']
......
......@@ -64,22 +64,32 @@ LZMA_compress(__attribute__((unused)) PyObject *self, PyObject *args, PyObject *
else if(filters[0].id == LZMA_FILTER_LZMA1)
{
lzuerror = lzma_alone_encoder(lzus, filters[0].options);
if(!Util_CatchLZMAError(lzuerror, lzus, true))
goto error;
lzus->avail_in = (size_t)datasize;
lzus->next_in = data;
lzus->next_out = (uint8_t *)PyString_AS_STRING(ret);
lzus->avail_out = (size_t)bufsize;
Py_BEGIN_ALLOW_THREADS
lzuerror = lzma_code(lzus, LZMA_FINISH);
Py_END_ALLOW_THREADS
for (;;) {
Py_BEGIN_ALLOW_THREADS
lzuerror = lzma_code(lzus, LZMA_FINISH);
Py_END_ALLOW_THREADS
if (!Util_CatchLZMAError(lzuerror, lzus, true))
goto error;
if(lzuerror == LZMA_STREAM_END)
break; /* no more input data */
if (lzus->avail_out == 0) {
bufsize = Util_NewBufferSize(bufsize);
if (_PyString_Resize(&ret, bufsize) < 0)
goto error;
lzus->next_out = (uint8_t *)PyString_AS_STRING(ret) + lzus->total_out;
lzus->avail_out = (size_t)bufsize - (lzus->next_out - (uint8_t *)PyString_AS_STRING(ret));
}
}
if(!Util_CatchLZMAError(lzuerror, lzus, true))
goto error;
lzma_end(lzus);
if (lzuerror == LZMA_STREAM_END)
_PyString_Resize(&ret, (Py_ssize_t)lzus->total_out);
......@@ -235,7 +245,7 @@ static PyMethodDef lzma_methods[] = {
PyDoc_STRVAR(lzma_module_documentation,
"The python lzma module provides a comprehensive interface for\n\
the lzma compression library. It implements one shot (de)compression\n\
functions, CRC-32 & CRC-64 checksum copmutations, types for sequential\n\
functions, CRC-32 & CRC-64 checksum computations, types for sequential\n\
(de)compression, and advanced options for lzma compression.\n\
");
......@@ -244,7 +254,7 @@ PyMODINIT_FUNC initlzma(void);
PyMODINIT_FUNC
initlzma(void)
{
PyObject *ver, *optionsSingleton;
PyObject *ver, *optionsSingleton, *module;
char verstring[10], major, minor[5], revision[5], s[8];
Py_TYPE(&LZMAComp_Type) = &PyType_Type;
Py_TYPE(&LZMADecomp_Type) = &PyType_Type;
......
......@@ -25,7 +25,12 @@ typedef unsigned long ulong;
#ifdef WITH_THREAD
#include <pythread.h>
#define ACQUIRE_LOCK(obj) PyThread_acquire_lock(obj->lock, 1)
#define ACQUIRE_LOCK(obj) do { \
if (!PyThread_acquire_lock(obj->lock, 0)) { \
Py_BEGIN_ALLOW_THREADS \
PyThread_acquire_lock(obj->lock, 1); \
Py_END_ALLOW_THREADS \
} } while(0)
#define RELEASE_LOCK(obj) PyThread_release_lock(obj->lock)
#else
#define ACQUIRE_LOCK(obj)
......@@ -49,5 +54,4 @@ typedef unsigned long ulong;
#define INITCHECK if (!self->is_initialised) { PyErr_Format(PyExc_RuntimeError, "%s object not initialised!", self->ob_type->tp_name); return NULL; }
PyObject *module;
#endif /* LIBLZMA_H */
......@@ -17,7 +17,7 @@ LZMAComp_compress(LZMACompObject *self, PyObject *args)
Py_buffer pdata;
Py_ssize_t datasize, bufsize = SMALLCHUNK;
uint8_t *data;
uint64_t start_total_out;
uint64_t totalout;
PyObject *ret = NULL;
lzma_stream *lzus = &self->lzus;
lzma_ret lzuerror;
......@@ -38,28 +38,31 @@ LZMAComp_compress(LZMACompObject *self, PyObject *args)
if (!(ret = PyString_FromStringAndSize(NULL, bufsize)))
goto error;
start_total_out = lzus->total_out;
lzus->avail_in = (size_t)datasize;
lzus->next_in = data;
lzus->avail_out = (size_t)bufsize;
lzus->next_out = (uint8_t *)PyString_AS_STRING(ret);
totalout = lzus->total_out;
for (;;) {
Py_BEGIN_ALLOW_THREADS
lzuerror = lzma_code(lzus, LZMA_RUN);
Py_END_ALLOW_THREADS
if (lzus->avail_in == 0 || lzus->avail_out != 0)
break;
if (_PyString_Resize(&ret, bufsize << 1) < 0)
goto error;
lzus->next_out = (uint8_t *)PyString_AS_STRING(ret) + datasize;
lzus->avail_out = (size_t)bufsize;
bufsize = bufsize << 1;
if(!Util_CatchLZMAError(lzuerror, lzus, true))
if (!Util_CatchLZMAError(lzuerror, lzus, true))
goto error;
if (lzus->avail_in == 0)
break; /* no more input data */
if (lzus->avail_out == 0) {
bufsize = Util_NewBufferSize(bufsize);
if (_PyString_Resize(&ret, bufsize) < 0)
goto error;
lzus->next_out = (uint8_t *)PyString_AS_STRING(ret) + (lzus->total_out - totalout);
lzus->avail_out = (size_t)bufsize - (lzus->next_out - (uint8_t *)PyString_AS_STRING(ret));
}
}
_PyString_Resize(&ret, (Py_ssize_t)lzus->total_out - (Py_ssize_t)start_total_out);
_PyString_Resize(&ret, (Py_ssize_t)lzus->total_out - (Py_ssize_t)totalout);
RELEASE_LOCK(self);
PyBuffer_Release(&pdata);
......@@ -88,7 +91,7 @@ LZMAComp_flush(LZMACompObject *self, PyObject *args)
Py_ssize_t bufsize = SMALLCHUNK;
PyObject *ret = NULL;
lzma_action flushmode = LZMA_FINISH;
uint64_t start_total_out;
uint64_t totalout;
lzma_stream *lzus = &self->lzus;
lzma_ret lzuerror;
......@@ -126,27 +129,30 @@ LZMAComp_flush(LZMACompObject *self, PyObject *args)
if (!(ret = PyString_FromStringAndSize(NULL, bufsize)))
goto error;
start_total_out = lzus->total_out;
lzus->avail_in = 0;
lzus->avail_out = (size_t)bufsize;
lzus->next_out = (uint8_t *)PyString_AS_STRING(ret);
totalout = lzus->total_out;
for (;;) {
Py_BEGIN_ALLOW_THREADS
lzuerror = lzma_code(lzus, flushmode);
Py_END_ALLOW_THREADS
if (lzus->avail_in == 0 || lzus->avail_out != 0)
break;
if (_PyString_Resize(&ret, bufsize << 1) < 0)
goto error;
lzus->next_out = (uint8_t *)PyString_AS_STRING(ret) + bufsize;
lzus->avail_out = (size_t)bufsize;
bufsize = bufsize << 1;
if(!Util_CatchLZMAError(lzuerror, lzus, true))
if (!Util_CatchLZMAError(lzuerror, lzus, true))
goto error;
if(lzuerror == LZMA_STREAM_END)
break; /* no more input data */
if (lzus->avail_out == 0) {
bufsize = Util_NewBufferSize(bufsize);
if (_PyString_Resize(&ret, bufsize) < 0)
goto error;
lzus->next_out = (uint8_t *)PyString_AS_STRING(ret) + (lzus->total_out - totalout);;
lzus->avail_out = (size_t)bufsize - (lzus->next_out - (uint8_t *)PyString_AS_STRING(ret));
}
}
_PyString_Resize(&ret, (Py_ssize_t)self->lzus.total_out - (Py_ssize_t)start_total_out);
_PyString_Resize(&ret, (Py_ssize_t)lzus->total_out - (Py_ssize_t)totalout);
RELEASE_LOCK(self);
return ret;
......
......@@ -47,6 +47,8 @@ bool init_lzma_options(const char *funcName, PyObject *kwargs, lzma_filter *filt
PyObject *LZMA_options_get(lzma_filter filter);
#define DEFAULT_OPTIONS_STRING "options={'format':'xz', 'check':'crc32', 'level':6, 'extreme':False,\n\
'dictionary_size':23, 'literal_contextbits':3 'literal_pos_bits':0, 'pos_bits':2, 'mode':2,\n\
'fast_bytes':128, 'match_finder':'bt4', 'match_finder_cycles':0"
'dict_size':23, 'lc':3 'lp':0, 'pb':2, 'mode':2,\n\
'nice_len':128, 'mf':'bt4', 'depth':0"
#endif /* LIBLZMA_OPTIONS_H */
#! /usr/bin/env python
"""Regression test.
This will find all modules whose name is "test_*" in the test
directory, and run them. Various command line options provide
additional facilities.
Command line options:
-v: verbose -- run tests in verbose mode with output to stdout
-q: quiet -- don't print anything except if a test fails
-g: generate -- write the output file for a test instead of comparing it
-x: exclude -- arguments are tests to *exclude*
-s: single -- run only a single test (see below)
-r: random -- randomize test execution order
-f: fromfile -- read names of tests to run from a file (see below)
-l: findleaks -- if GC is available detect tests that leak memory
-u: use -- specify which special resource intensive tests to run
-h: help -- print this text and exit
-t: threshold -- call gc.set_threshold(N)
-T: coverage -- turn on code coverage using the trace module
-L: runleaks -- run the leaks(1) command just before exit
-R: huntrleaks -- search for reference leaks (needs debug build, v. slow)
-d: duration -- times the execution for all tests
If non-option arguments are present, they are names for tests to run,
unless -x is given, in which case they are names for tests not to run.
If no test names are given, all tests are run.
-v is incompatible with -g and does not compare test output files.
-T turns on code coverage tracing with the trace module.
-s means to run only a single test and exit. This is useful when
doing memory analysis on the Python interpreter (which tend to consume
too many resources to run the full regression test non-stop). The
file /tmp/pynexttest is read to find the next test to run. If this
file is missing, the first test_*.py file in testdir or on the command
line is used. (actually tempfile.gettempdir() is used instead of
/tmp).
-f reads the names of tests from the file given as f's argument, one
or more test names per line. Whitespace is ignored. Blank lines and
lines beginning with '#' are ignored. This is especially useful for
whittling down failures involving interactions among tests.
-L causes the leaks(1) command to be run just before exit if it exists.
leaks(1) is available on Mac OS X and presumably on some other
FreeBSD-derived systems.
-R runs each test several times and examines sys.gettotalrefcount() to
see if the test appears to be leaking references. The argument should
be of the form stab:run:fname where 'stab' is the number of times the
test is run to let gettotalrefcount settle down, 'run' is the number
of times further it is run and 'fname' is the name of the file the
reports are written to. These parameters all have defaults (5, 4 and
"reflog.txt" respectively), so the minimal invocation is '-R ::'.
"""
import os
import sys
import getopt
import random
import warnings
import re
import cStringIO
import traceback
import time
# I see no other way to suppress these warnings;
# putting them in test_grammar.py has no effect:
warnings.filterwarnings("ignore", "hex/oct constants", FutureWarning,
".*test.test_grammar$")
if sys.maxint > 0x7fffffff:
# Also suppress them in <string>, because for 64-bit platforms,
# that's where test_grammar.py hides them.
warnings.filterwarnings("ignore", "hex/oct constants", FutureWarning,
"<string>")
# MacOSX (a.k.a. Darwin) has a default stack size that is too small
# for deeply recursive regular expressions. We see this as crashes in
# the Python test suite when running test_re.py and test_sre.py. The
# fix is to set the stack limit to 2048.
# This approach may also be useful for other Unixy platforms that
# suffer from small default stack limits.
if sys.platform == 'darwin':
try:
import resource
except ImportError:
pass
else:
soft, hard = resource.getrlimit(resource.RLIMIT_STACK)
newsoft = min(hard, max(soft, 1024*2048))
resource.setrlimit(resource.RLIMIT_STACK, (newsoft, hard))
from test import test_support
RESOURCE_NAMES = ()
def usage(code, msg=''):
print __doc__
if msg: print msg
sys.exit(code)
def main(tests=None, testdir=None, verbose=0, quiet=False, generate=False,
exclude=False, single=False, randomize=False, fromfile=None,
findleaks=False, use_resources=None, trace=False, runleaks=False,
huntrleaks=False, duration=False):
"""Execute a test suite.
This also parses command-line options and modifies its behavior
accordingly.
tests -- a list of strings containing test names (optional)
testdir -- the directory in which to look for tests (optional)
Users other than the Python test suite will certainly want to
specify testdir; if it's omitted, the directory containing the
Python test suite is searched for.
If the tests argument is omitted, the tests listed on the
command-line will be used. If that's empty, too, then all *.py
files beginning with test_ will be used.
The other default arguments (verbose, quiet, generate, exclude, single,
randomize, findleaks, use_resources, and trace) allow programmers calling
main() directly to set the values that would normally be set by flags on
the command line.
"""
test_support.record_original_stdout(sys.stdout)
try:
opts, args = getopt.getopt(sys.argv[1:], 'hvgqxsrf:lt:TLR:d',
['help', 'verbose', 'quiet', 'generate',
'exclude', 'single', 'random', 'fromfile',
'findleaks', 'threshold=', 'trace',
'runleaks', 'huntrleaks=', 'duration',
])
except getopt.error, msg:
usage(2, msg)
# Defaults
if use_resources is None:
use_resources = []
for o, a in opts:
if o in ('-h', '--help'):
usage(0)
elif o in ('-v', '--verbose'):
verbose += 1
elif o in ('-q', '--quiet'):
quiet = True;
verbose = 0
elif o in ('-g', '--generate'):
generate = True
elif o in ('-x', '--exclude'):
exclude = True
elif o in ('-s', '--single'):
single = True
elif o in ('-r', '--randomize'):
randomize = True
elif o in ('-f', '--fromfile'):
fromfile = a
elif o in ('-l', '--findleaks'):
findleaks = True
elif o in ('-L', '--runleaks'):
runleaks = True
elif o in ('-t', '--threshold'):
import gc
gc.set_threshold(int(a))
elif o in ('-T', '--coverage'):
trace = True
elif o in ('-R', '--huntrleaks'):
huntrleaks = a.split(':')
if len(huntrleaks) != 3:
print a, huntrleaks
usage(2, '-R takes three colon-separated arguments')
if len(huntrleaks[0]) == 0:
huntrleaks[0] = 5
else:
huntrleaks[0] = int(huntrleaks[0])
if len(huntrleaks[1]) == 0:
huntrleaks[1] = 4
else:
huntrleaks[1] = int(huntrleaks[1])
if len(huntrleaks[2]) == 0:
huntrleaks[2] = "reflog.txt"
elif o in ('-d', '--duration'):
duration = True
if generate and verbose:
usage(2, "-g and -v don't go together!")
if single and fromfile:
usage(2, "-s and -f don't go together!")
good = []
bad = []
skipped = []
resource_denieds = []
if findleaks:
try:
import gc
except ImportError:
print 'No GC available, disabling findleaks.'
findleaks = False
else:
# Uncomment the line below to report garbage that is not
# freeable by reference counting alone. By default only
# garbage that is not collectable by the GC is reported.
#gc.set_debug(gc.DEBUG_SAVEALL)
found_garbage = []
if single:
from tempfile import gettempdir
filename = os.path.join(gettempdir(), 'pynexttest')
try:
fp = open(filename, 'r')
next = fp.read().strip()
tests = [next]
fp.close()
except IOError:
pass
if fromfile:
tests = []
fp = open(fromfile)
for line in fp:
guts = line.split() # assuming no test has whitespace in its name
if guts and not guts[0].startswith('#'):
tests.extend(guts)
fp.close()
# Strip .py extensions.
if args:
args = map(removepy, args)
if tests:
tests = map(removepy, tests)
stdtests = STDTESTS[:]
nottests = NOTTESTS[:]
if exclude:
for arg in args:
if arg in stdtests:
stdtests.remove(arg)
nottests[:0] = args
args = []
tests = tests or args or findtests(testdir, stdtests, nottests)
if single:
tests = tests[:1]
if randomize:
random.shuffle(tests)
if trace:
import trace
tracer = trace.Trace(ignoredirs=[sys.prefix, sys.exec_prefix],
trace=False, count=True)
coverdir = os.path.join(os.getcwd(), 'coverage')
test_support.verbose = verbose # Tell tests to be moderately quiet
test_support.use_resources = use_resources
save_modules = sys.modules.keys()
start_time = time.time()
for test in tests: