Skip to content

Commit

Permalink
change imports to avoid shadowing
Browse files Browse the repository at this point in the history
in
```
from buildbot.util import poll

class Foo:
    @poll.method
    def someMethod(self):
        pass
    def poll(self):
        pass
```

The `poll` in `@poll.method` correctly refers to the module.  However,
if the order of the methods is reversed, it refers instead to the `poll`
method in the class scope.

Pyflakes only detects this in the problematic ordering, while pylint
detects it even in the working order.  Pylint is probably right -
re-ordering methods shouldn't change behavior!
  • Loading branch information
djmitche committed Jun 11, 2014
1 parent c67feed commit 2602206
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
10 changes: 5 additions & 5 deletions master/buildbot/changes/base.py
Expand Up @@ -18,8 +18,8 @@
from zope.interface import implements

from buildbot.interfaces import IChangeSource
from buildbot.util import poll
from buildbot.util import service
from buildbot.util.poll import method as poll_method


class ChangeSource(service.ClusteredService):
Expand Down Expand Up @@ -57,15 +57,15 @@ def __init__(self, name=None, pollInterval=60 * 10, pollAtLaunch=False):
self.pollInterval = pollInterval
self.pollAtLaunch = pollAtLaunch

@poll.method
def poll(self):
pass

@poll_method
def doPoll(self):
d = defer.maybeDeferred(self.poll)
d.addErrback(log.err, 'while polling for changes')
return d

def poll(self):
pass

def force(self):
self.doPoll()

Expand Down
6 changes: 3 additions & 3 deletions master/buildbot/test/unit/test_util_poll.py
Expand Up @@ -13,15 +13,15 @@
#
# Copyright Buildbot Team Members

from buildbot.util import poll
from buildbot.util.poll import method as poll_method
from twisted.internet import defer
from twisted.internet import task
from twisted.trial import unittest


class TestPollerSync(unittest.TestCase):

@poll.method
@poll_method
def poll(self):
self.calls += 1
if self.fail:
Expand Down Expand Up @@ -107,7 +107,7 @@ def test_fails(self):

class TestPollerAsync(unittest.TestCase):

@poll.method
@poll_method
def poll(self):
assert not self.running, "overlapping call"
self.running = True
Expand Down

0 comments on commit 2602206

Please sign in to comment.