Merge lp:~brian.curtin/ubuntu-sso-client/py3-callable into lp:ubuntu-sso-client

Proposed by Brian Curtin
Status: Rejected
Rejected by: Brian Curtin
Proposed branch: lp:~brian.curtin/ubuntu-sso-client/py3-callable
Merge into: lp:ubuntu-sso-client
Diff against target: 22 lines (+4/-1)
1 file modified
ubuntu_sso/qt/tests/__init__.py (+4/-1)
To merge this branch: bzr merge lp:~brian.curtin/ubuntu-sso-client/py3-callable
Reviewer Review Type Date Requested Status
Alejandro J. Cura (community) Disapprove
Review via email: mp+119054@code.launchpad.net

Commit message

- Switch to Python 3's version of checking if an instance is callable.

Description of the change

Python 3 loses the callable builtin. Switch to checking an object's callability by passing it to isinstance and checking collections.Callable. Safe on recent Python 2 and all Python 3 versions.

To post a comment you must log in.
Revision history for this message
Alejandro J. Cura (alecu) wrote :

Do we really need this change?
Since we are supporting Python 3.2 and upwards, we may not need it, since """This function was first removed in Python 3.0 and then brought back in Python 3.2.""": http://docs.python.org/py3k/library/functions.html#callable

review: Disapprove
Revision history for this message
Brian Curtin (brian.curtin) wrote :

You're right - I forgot this was brought back in 3.2. The 2to3 that's included with 2.7 was still reporting this as needing to be changed.

Rejecting this.

Unmerged revisions

990. By Brian Curtin

Move to a Python 3 friendly way to check if an object is callable

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'ubuntu_sso/qt/tests/__init__.py'
2--- ubuntu_sso/qt/tests/__init__.py 2012-07-03 17:07:33 +0000
3+++ ubuntu_sso/qt/tests/__init__.py 2012-08-09 21:49:18 +0000
4@@ -28,6 +28,8 @@
5 # files in the program, then also delete it here.
6 """Test the Ui code."""
7
8+import collections
9+
10 from PyQt4 import QtGui, QtCore
11 from twisted.internet import defer
12 from twisted.trial.unittest import TestCase
13@@ -565,7 +567,8 @@
14
15 for signal in self.ui_backend_signals:
16 self.assertIn(signal, self.ui._signals)
17- self.assertTrue(callable(self.ui._signals[signal]))
18+ self.assertTrue(isinstance(self.ui._signals[signal],
19+ collections.Callable))
20
21 expected = ['_set_translated_strings', '_connect_ui', '_setup_signals']
22 self.assertEqual(expected, called)

Subscribers

People subscribed via source and target branches