Rev 5007: (vila) Avoid infinite recursion when probing for apport in file:///home/pqm/archives/thelove/bzr/%2Btrunk/
Canonical.com Patch Queue Manager
pqm at pqm.ubuntu.com
Thu Feb 4 14:33:02 GMT 2010
At file:///home/pqm/archives/thelove/bzr/%2Btrunk/
------------------------------------------------------------
revno: 5007 [merge]
revision-id: pqm at pqm.ubuntu.com-20100204143259-91x2d08a31yfeqnm
parent: pqm at pqm.ubuntu.com-20100204140100-xiij51gtzay09vgi
parent: v.ladeuil+lp at free.fr-20100204134825-zlq6iei50818oa8t
committer: Canonical.com Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Thu 2010-02-04 14:32:59 +0000
message:
(vila) Avoid infinite recursion when probing for apport
modified:
NEWS NEWS-20050323055033-4e00b5db738777ff
bzrlib/tests/__init__.py selftest.py-20050531073622-8d0e3c8845c97a64
bzrlib/tests/features.py features.py-20090820042958-jglgza3wrn03ha9e-1
bzrlib/tests/test_crash.py test_crash.py-20090820042958-jglgza3wrn03ha9e-2
bzrlib/tests/test_selftest.py test_selftest.py-20051202044319-c110a115d8c0456a
=== modified file 'NEWS'
--- a/NEWS 2010-02-04 14:01:00 +0000
+++ b/NEWS 2010-02-04 14:32:59 +0000
@@ -25,6 +25,12 @@
automatically or by running ``apport-bug``. No information is sent
without specific permission from the user. (Martin Pool, #515052)
+Bug Fixes
+*********
+
+* Avoid infinite recursion when probing for apport.
+ (Vincent Ladeuil, #516934)
+
Testing
*******
=== modified file 'bzrlib/tests/__init__.py'
--- a/bzrlib/tests/__init__.py 2010-02-03 10:06:19 +0000
+++ b/bzrlib/tests/__init__.py 2010-02-04 13:45:44 +0000
@@ -4135,21 +4135,30 @@
should really use a different feature.
"""
- def __init__(self, module, name, this_name, dep_version):
+ def __init__(self, dep_version, module, name,
+ replacement_name, replacement_module=None):
super(_CompatabilityThunkFeature, self).__init__()
self._module = module
+ if replacement_module is None:
+ replacement_module = module
+ self._replacement_module = replacement_module
self._name = name
- self._this_name = this_name
+ self._replacement_name = replacement_name
self._dep_version = dep_version
self._feature = None
def _ensure(self):
if self._feature is None:
- msg = (self._dep_version % self._this_name) + (
- ' Use %s.%s instead.' % (self._module, self._name))
- symbol_versioning.warn(msg, DeprecationWarning)
- mod = __import__(self._module, {}, {}, [self._name])
- self._feature = getattr(mod, self._name)
+ depr_msg = self._dep_version % ('%s.%s'
+ % (self._module, self._name))
+ use_msg = ' Use %s.%s instead.' % (self._replacement_module,
+ self._replacement_name)
+ symbol_versioning.warn(depr_msg + use_msg, DeprecationWarning)
+ # Import the new feature and use it as a replacement for the
+ # deprecated one.
+ mod = __import__(self._replacement_module, {}, {},
+ [self._replacement_name])
+ self._feature = getattr(mod, self._replacement_name)
def _probe(self):
self._ensure()
@@ -4181,15 +4190,16 @@
if self.available(): # Make sure the probe has been done
return self._module
return None
-
+
def feature_name(self):
return self.module_name
# This is kept here for compatibility, it is recommended to use
# 'bzrlib.tests.feature.paramiko' instead
-ParamikoFeature = _CompatabilityThunkFeature('bzrlib.tests.features',
- 'paramiko', 'bzrlib.tests.ParamikoFeature', deprecated_in((2,1,0)))
+ParamikoFeature = _CompatabilityThunkFeature(
+ deprecated_in((2,1,0)),
+ 'bzrlib.tests.features', 'ParamikoFeature', 'paramiko')
def probe_unicode_in_user_encoding():
@@ -4357,8 +4367,9 @@
# Kept for compatibility, use bzrlib.tests.features.subunit instead
-SubUnitFeature = _CompatabilityThunkFeature('bzrlib.tests.features', 'subunit',
- 'bzrlib.tests.SubUnitFeature', deprecated_in((2,1,0)))
+SubUnitFeature = _CompatabilityThunkFeature(
+ deprecated_in((2,1,0)),
+ 'bzrlib.tests.features', 'SubUnitFeature', 'subunit')
# Only define SubUnitBzrRunner if subunit is available.
try:
from subunit import TestProtocolClient
=== modified file 'bzrlib/tests/features.py'
--- a/bzrlib/tests/features.py 2009-12-22 15:39:20 +0000
+++ b/bzrlib/tests/features.py 2010-02-04 13:45:44 +0000
@@ -20,8 +20,6 @@
apport = tests.ModuleAvailableFeature('apport')
-ApportFeature = tests._CompatabilityThunkFeature('bzrlib.tests.features',
- 'ApportFeature', 'bzrlib.tests.features.apport', deprecated_in((2,1,0)))
paramiko = tests.ModuleAvailableFeature('paramiko')
pycurl = tests.ModuleAvailableFeature('pycurl')
subunit = tests.ModuleAvailableFeature('subunit')
=== modified file 'bzrlib/tests/test_crash.py'
--- a/bzrlib/tests/test_crash.py 2010-02-02 23:02:18 +0000
+++ b/bzrlib/tests/test_crash.py 2010-02-04 13:45:44 +0000
@@ -25,31 +25,24 @@
from bzrlib import (
config,
crash,
+ osutils,
+ symbol_versioning,
tests,
- osutils,
- )
-
-from bzrlib.tests import (
- features,
- TestCaseInTempDir,
- )
-from bzrlib.tests.features import ApportFeature
-
-
-class TestApportReporting(TestCaseInTempDir):
+ )
+
+from bzrlib.tests import features
+
+
+class TestApportReporting(tests.TestCaseInTempDir):
_test_needs_features = [features.apport]
- def setUp(self):
- TestCaseInTempDir.setUp(self)
- self.requireFeature(ApportFeature)
-
def test_apport_report(self):
crash_dir = osutils.joinpath((self.test_base_dir, 'crash'))
os.mkdir(crash_dir)
os.environ['APPORT_CRASH_DIR'] = crash_dir
self.assertEquals(crash_dir, config.crash_dir())
-
+
stderr = StringIO()
try:
=== modified file 'bzrlib/tests/test_selftest.py'
--- a/bzrlib/tests/test_selftest.py 2010-01-25 17:48:22 +0000
+++ b/bzrlib/tests/test_selftest.py 2010-02-04 09:09:37 +0000
@@ -2400,9 +2400,11 @@
simple_thunk_feature = tests._CompatabilityThunkFeature(
- 'bzrlib.tests', 'UnicodeFilename',
- 'bzrlib.tests.test_selftest.simple_thunk_feature',
- deprecated_in((2,1,0)))
+ deprecated_in((2, 1, 0)),
+ 'bzrlib.tests.test_selftest',
+ 'simple_thunk_feature','UnicodeFilename',
+ replacement_module='bzrlib.tests'
+ )
class Test_CompatibilityFeature(tests.TestCase):
@@ -2413,7 +2415,7 @@
simple_thunk_feature.available)
self.assertEqual(tests.UnicodeFilename.available(), res)
-
+
class TestModuleAvailableFeature(tests.TestCase):
def test_available_module(self):
More information about the bazaar-commits
mailing list