Ticket #3066 defect closed fixed

Opened 6 years ago

Last modified 6 years ago

twisted.words.xish.utility.addOnetimeObserver can register a permanent xml stream observer

Reported by: jgill Owned by:
Priority: high Milestone:
Component: words Keywords:
Cc: jgill, ralphm, therve Branch: branches/xish-nested-dispatch-3066
(diff, github, buildbot, log)
Author: ralphm Launchpad Bug:

Description

twisted.words.xish.utility.addOnetimeObserver() adds an observer to an XPath event on an xml stream. Under some situations the method will defer appending the callback to the callback queue, e.g. if is in the middle of a dispatch call. The queued command, however, calls addObserver() rather than _addObserver(), and therefore drops the 'onetime' flag.

A simple fix might be to change the lambda call near the start of _addObserver() from

lambda:self.addObserver(event, observerfn, priority, *args, **kwargs)

to:

lambda:self._addObserver(onetime, event, observerfn, priority, *args, **kwargs)

Change History

1

Changed 6 years ago by jgill

  • owner changed from glyph to exarkun
  • component changed from core to words

Part of words package.

2

Changed 6 years ago by ralphm

  • owner changed from exarkun to ralphm

Reading that piece of code, this indeed seems to be the case. Do you have a test case that shows this behavior?

3

Changed 6 years ago by ralphm

  • branch set to branches/xish-nested-dispatch-3066
  • author set to ralphm

(In [23387]) Branching to 'xish-nested-dispatch-3066'

4

Changed 6 years ago by ralphm

  • owner ralphm deleted
  • cc jgill, ralphm added
  • priority changed from normal to highest
  • keywords review added
  • milestone set to Words 8.0.0 + 1

I made up the test case myself and fixed the one for the non-onetime observer to actually test that.

Please review.

5

Changed 6 years ago by therve

  • owner set to ralphm
  • keywords review removed

2 tests are failing:

[ERROR]: twisted.words.test.test_xishutil.EventDispatcherTest.testStuff

Traceback (most recent call last):
  File "/home/therve/Projets/Twisted/trunk/twisted/words/test/test_xishutil.py", line 80, in testStuff
    self.assertEquals(cb1.object, msg)
exceptions.AttributeError: CallbackTracker instance has no attribute 'object'
===============================================================================
[ERROR]: twisted.words.test.test_xishutil.EventDispatcherTest.test_addObserverTwice

Traceback (most recent call last):
  File "/home/therve/Projets/Twisted/trunk/twisted/words/test/test_xishutil.py", line 113, in test_addObserverTwice
    self.assertEquals(cb1.object, d)
exceptions.AttributeError: CallbackTracker instance has no attribute 'object'

6

Changed 6 years ago by ralphm

  • cc therve added
  • owner changed from ralphm to therve
  • keywords review added

:-( Sorry about that. Fixed now.

7

Changed 6 years ago by therve

  • priority changed from highest to high
  • keywords review removed
  • owner changed from therve to ralphm

Great, please merge.

8

Changed 6 years ago by ralphm

  • status changed from new to closed
  • resolution set to fixed

(In [23418]) Fix adding one-time observers while in dispatch.

Author: jgill, ralphm Reviewer: therve Fixes #3066.

9

Changed 6 years ago by trac

  • milestone Words 8.0.0 + 1 deleted

Milestone Words 8.0.0 + 1 deleted

10

Changed 3 years ago by <automation>

  • owner ralphm deleted
Note: See TracTickets for help on using tickets.