Merge lp:~jkakar/txaws/silence-deprecation-warnings into lp:txaws

Proposed by Jamu Kakar
Status: Merged
Merged at revision: 84
Proposed branch: lp:~jkakar/txaws/silence-deprecation-warnings
Merge into: lp:txaws
Diff against target: 88 lines (+10/-8)
4 files modified
txaws/client/base.py (+1/-1)
txaws/ec2/client.py (+5/-3)
txaws/ec2/exception.py (+1/-1)
txaws/ec2/tests/test_client.py (+3/-3)
To merge this branch: bzr merge lp:~jkakar/txaws/silence-deprecation-warnings
Reviewer Review Type Date Requested Status
Duncan McGreggor Approve
Review via email: mp+58664@code.launchpad.net

Description of the change

This branch introduces the following changes:

- Minor changes have been made to silence deprecation warnings
  generated by the test suite when run with Python 2.7.

To post a comment you must log in.
Revision history for this message
Duncan McGreggor (oubiwann) wrote :

Note sure if you want to address Python 2.6 deprecation warnings at the same time:

    test_submit_400 ... [OK]
/mnt/oubiwann/lab/txAWS/branches/silence-deprecation-warnings/txaws/client/base.py:40: DeprecationWarning: BaseException.message has been deprecated as of Python 2.6
    test_submit_500 ... [OK]
/mnt/oubiwann/lab/txAWS/branches/silence-deprecation-warnings/txaws/client/base.py:40: DeprecationWarning: BaseException.message has been deprecated as of Python 2.6
    test_submit_non_EC2_400 ... [OK]
/mnt/oubiwann/lab/txAWS/branches/silence-deprecation-warnings/txaws/client/base.py:40: DeprecationWarning: BaseException.message has been deprecated as of Python 2.6

Changes look good; all tests pass on Python 2.6 and Python 2.7; +1 for merge, regardless what you want to do about the 2.6 exceptions.

review: Approve
Revision history for this message
Jamu Kakar (jkakar) wrote :

Duncan:

Interestingly, I don't get those warnings on Python 2.7... anyway,
I've made a change that should fix them. Can you please run the test
suite with Python 2.6 again and let me know if everything is fine?

85. By Jamu Kakar

- Minor change to quell warnings on Python 2.6.

Revision history for this message
Duncan McGreggor (oubiwann) wrote :

Those are gone, but for some reason, new ones have shown up... odd :-/

/mnt/oubiwann/lab/txAWS/branches/silence-deprecation-warnings/txaws/ec2/tests/test_client.py:1429: DeprecationWarning: BaseException.message has been deprecated as of Python 2.6
/mnt/oubiwann/lab/txAWS/branches/silence-deprecation-warnings/txaws/ec2/tests/test_client.py:1481: DeprecationWarning: BaseException.message has been deprecated as of Python 2.6
/mnt/oubiwann/lab/txAWS/branches/silence-deprecation-warnings/txaws/ec2/tests/test_client.py:1488: DeprecationWarning: BaseException.message has been deprecated as of Python 2.6

86. By Jamu Kakar

- Fixed more deprecation warnings for Python 2.6.

Revision history for this message
Jamu Kakar (jkakar) wrote :

Cool, I've fixed those and pushed new revisions. Can you please run
the tests again?

Revision history for this message
Duncan McGreggor (oubiwann) wrote :

Sure thing!

A new one popped up:

/mnt/oubiwann/lab/txAWS/branches/silence-deprecation-warnings/txaws/client/tests/test_client.py:44: DeprecationWarning: BaseException.message has been deprecated as of Python 2.6

I did a quick grep through the source code, and that's the last 'error.message' I could see:

$ find txaws/|xargs grep -n 'error\.message'
txaws/client/tests/test_client.py:44: self.assertEquals(error.message, "timeout")

So hopefully we're good now :-)

/me crosses fingers

Revision history for this message
Jamu Kakar (jkakar) wrote :

Sorry for all this nonsense. I fixed the issue and also installed
python2.6 to make sure there aren't anymore. Using trial with a
non-/usr/bin/python sucks and is awesome at the same time:

python2.6 -c "from twisted.scripts.trial import run; run()" txaws
python2.7 -c "from twisted.scripts.trial import run; run()" txaws

The tests pass without deprecation warnings in both of these cases, so
I'm going to go ahead and merge.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'txaws/client/base.py'
2--- txaws/client/base.py 2011-04-14 16:57:11 +0000
3+++ txaws/client/base.py 2011-04-21 16:15:56 +0000
4@@ -37,7 +37,7 @@
5 error.raiseException()
6 try:
7 fallback_error = errorClass(
8- xml_payload, error.value.status, error.value.message,
9+ xml_payload, error.value.status, str(error.value),
10 error.value.response)
11 except (ParseError, AWSResponseParseError):
12 error_message = http.RESPONSES.get(http_status)
13
14=== modified file 'txaws/ec2/client.py'
15--- txaws/ec2/client.py 2011-04-19 17:42:18 +0000
16+++ txaws/ec2/client.py 2011-04-21 16:15:56 +0000
17@@ -76,7 +76,7 @@
18 "availabilityZone")
19 products = []
20 product_codes = instance_data.find("productCodes")
21- if product_codes:
22+ if product_codes is not None:
23 for product_data in instance_data.find("productCodes"):
24 products.append(product_data.text)
25 kernel_id = instance_data.findtext("kernelId")
26@@ -236,7 +236,9 @@
27 owner_id = group_info.findtext("ownerId")
28 allowed_groups = []
29 allowed_ips = []
30- ip_permissions = group_info.find("ipPermissions") or ()
31+ ip_permissions = group_info.find("ipPermissions")
32+ if ip_permissions is None:
33+ ip_permissions = ()
34 for ip_permission in ip_permissions:
35 ip_protocol = ip_permission.findtext("ipProtocol")
36 from_port = int(ip_permission.findtext("fromPort"))
37@@ -630,7 +632,7 @@
38 results = []
39 root = XML(xml_bytes)
40 keypairs = root.find("keySet")
41- if not keypairs:
42+ if keypairs is None:
43 return results
44 for keypair_data in keypairs:
45 key_name = keypair_data.findtext("keyName")
46
47=== modified file 'txaws/ec2/exception.py'
48--- txaws/ec2/exception.py 2009-11-22 05:15:21 +0000
49+++ txaws/ec2/exception.py 2011-04-21 16:15:56 +0000
50@@ -10,7 +10,7 @@
51 """
52 def _set_400_error(self, tree):
53 errors_node = tree.find(".//Errors")
54- if errors_node:
55+ if errors_node is not None:
56 for error in errors_node:
57 data = self._node_to_dict(error)
58 if data:
59
60=== modified file 'txaws/ec2/tests/test_client.py'
61--- txaws/ec2/tests/test_client.py 2011-04-19 17:42:18 +0000
62+++ txaws/ec2/tests/test_client.py 2011-04-21 16:15:56 +0000
63@@ -1426,7 +1426,7 @@
64 self.assertEquals(failure.type, type(error))
65 self.assertFalse(isinstance(error, EC2Error))
66 self.assertTrue(isinstance(error, Exception))
67- self.assertEquals(error.message, "found")
68+ self.assertEquals(str(error), "found")
69
70 def test_400_error(self):
71 failure = self.make_failure(400, TwistedWebError)
72@@ -1478,14 +1478,14 @@
73 error = self.assertRaises(Exception, client.ec2_error_wrapper, failure)
74 self.assertFalse(isinstance(error, EC2Error))
75 self.assertTrue(isinstance(error, Exception))
76- self.assertEquals(error.message, "A server error occurred")
77+ self.assertEquals(str(error), "A server error occurred")
78
79 def test_timeout_error(self):
80 failure = self.make_failure(type=Exception, message="timeout")
81 error = self.assertRaises(Exception, client.ec2_error_wrapper, failure)
82 self.assertFalse(isinstance(error, EC2Error))
83 self.assertTrue(isinstance(error, Exception))
84- self.assertEquals(error.message, "timeout")
85+ self.assertEquals(str(error), "timeout")
86
87 def test_connection_error(self):
88 failure = self.make_failure(type=ConnectionRefusedError)

Subscribers

People subscribed via source and target branches

to all changes: