Merge lp:~jelmer/brz/symbol-versioning into lp:brz

Proposed by Jelmer Vernooij
Status: Merged
Approved by: Jelmer Vernooij
Approved revision: no longer in the source branch.
Merge reported by: The Breezy Bot
Merged at revision: not available
Proposed branch: lp:~jelmer/brz/symbol-versioning
Merge into: lp:brz
Diff against target: 107 lines (+29/-21)
3 files modified
breezy/symbol_versioning.py (+13/-9)
breezy/tests/test_symbol_versioning.py (+15/-12)
python3.passing (+1/-0)
To merge this branch: bzr merge lp:~jelmer/brz/symbol-versioning
Reviewer Review Type Date Requested Status
Martin Packman Approve
Review via email: mp+353373@code.launchpad.net

Commit message

Fix names of deprecated symbols on Python 3.

Description of the change

Fix names of deprecated symbols on Python 3.

To post a comment you must log in.
Revision history for this message
Martin Packman (gz) wrote :

See suggestion about more code to delete. There's no great option for static methods on Python 2 anyway as the test notes, without getting needlessly fancy.

review: Approve
Revision history for this message
Jelmer Vernooij (jelmer) :
Revision history for this message
Jelmer Vernooij (jelmer) :

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'breezy/symbol_versioning.py'
2--- breezy/symbol_versioning.py 2017-05-22 00:56:52 +0000
3+++ breezy/symbol_versioning.py 2018-09-02 21:16:14 +0000
4@@ -38,6 +38,7 @@
5
6 import breezy
7
8+from .sixish import PY3
9
10 DEPRECATED_PARAMETER = "A deprecated parameter marker."
11
12@@ -75,16 +76,19 @@
13 have a single %s operator in it. a_callable will be turned into a nice
14 python symbol and then substituted into deprecation_version.
15 """
16- # We also want to handle old-style classes, in particular exception, and
17- # they don't have an im_class attribute.
18- if getattr(a_callable, 'im_class', None) is None:
19- symbol = "%s.%s" % (a_callable.__module__,
20- a_callable.__name__)
21+ if PY3:
22+ func = getattr(a_callable, '__func__', a_callable)
23+ symbol ='%s.%s' % (a_callable.__module__,
24+ a_callable.__qualname__)
25 else:
26- symbol = "%s.%s.%s" % (a_callable.__self__.__class__.__module__,
27- a_callable.__self__.__class__.__name__,
28- a_callable.__name__
29- )
30+ if getattr(a_callable, '__self__', None) is None:
31+ symbol = "%s.%s" % (a_callable.__module__,
32+ a_callable.__name__)
33+ else:
34+ symbol = "%s.%s.%s" % (a_callable.__self__.__class__.__module__,
35+ a_callable.__self__.__class__.__name__,
36+ a_callable.__name__
37+ )
38 return deprecation_version % symbol
39
40
41
42=== modified file 'breezy/tests/test_symbol_versioning.py'
43--- breezy/tests/test_symbol_versioning.py 2018-07-26 01:01:49 +0000
44+++ breezy/tests/test_symbol_versioning.py 2018-09-02 21:16:14 +0000
45@@ -19,6 +19,7 @@
46 import warnings
47
48 from breezy import symbol_versioning
49+from breezy.sixish import PY3
50 from breezy.symbol_versioning import (
51 deprecated_function,
52 deprecated_in,
53@@ -69,13 +70,19 @@
54 return 1
55
56 def test_deprecated_static(self):
57- # XXX: The results are not quite right because the class name is not
58- # shown - however it is enough to give people a good indication of
59- # where the problem is.
60- expected_warning = (
61- "breezy.tests.test_symbol_versioning."
62- "deprecated_static "
63- "was deprecated in version 0.7.0.", DeprecationWarning, 2)
64+ if PY3:
65+ expected_warning = (
66+ "breezy.tests.test_symbol_versioning.TestDeprecationWarnings."
67+ "deprecated_static "
68+ "was deprecated in version 0.7.0.", DeprecationWarning, 2)
69+ else:
70+ # XXX: The results are not quite right because the class name is not
71+ # shown on Python 2- however it is enough to give people a good indication of
72+ # where the problem is.
73+ expected_warning = (
74+ "breezy.tests.test_symbol_versioning."
75+ "deprecated_static "
76+ "was deprecated in version 0.7.0.", DeprecationWarning, 2)
77 expected_docstring = (
78 'Deprecated static.\n'
79 '\n'
80@@ -209,14 +216,10 @@
81 err_message = symbol_versioning.deprecation_string(
82 self.test_deprecation_string,
83 deprecated_in((0, 11, 0)))
84- self.assertIn(err_message,
85- ('breezy.tests.test_symbol_versioning.'
86- 'TestDeprecationWarnings.test_deprecation_string was deprecated in '
87- 'version 0.11.0.',
88+ self.assertEqual(err_message,
89 'breezy.tests.test_symbol_versioning.TestDeprecationWarnings.'
90 'test_deprecation_string was deprecated in '
91 'version 0.11.0.')
92- )
93
94 self.assertEqual('breezy.symbol_versioning.deprecated_function was '
95 'deprecated in version 0.11.0.',
96
97=== modified file 'python3.passing'
98--- python3.passing 2018-09-01 21:51:32 +0000
99+++ python3.passing 2018-09-02 21:16:14 +0000
100@@ -29817,6 +29817,7 @@
101 breezy.tests.test_symbol_versioning.TestDeprecationWarnings.test_deprecated_method
102 breezy.tests.test_symbol_versioning.TestDeprecationWarnings.test_deprecated_passed
103 breezy.tests.test_symbol_versioning.TestDeprecationWarnings.test_deprecated_static
104+breezy.tests.test_symbol_versioning.TestDeprecationWarnings.test_deprecation_string
105 breezy.tests.test_symbol_versioning.TestSuppressAndActivate.test_activate_deprecation_no_error
106 breezy.tests.test_symbol_versioning.TestSuppressAndActivate.test_activate_deprecation_with_DW_error
107 breezy.tests.test_symbol_versioning.TestSuppressAndActivate.test_activate_deprecation_with_error

Subscribers

People subscribed via source and target branches