Ticket #5494 defect closed fixed

Opened 2 years ago

Last modified 2 years ago

If gi can't be imported, gtk2 reactor still fails (and vice versa)

Reported by: itamar Owned by: itamar
Priority: normal Milestone: Twisted-12.1
Component: core Keywords:
Cc: jesstess Branch: branches/gtk2-vs-gtk3-5494
(diff, github, buildbot, log)
Author: itamar Launchpad Bug:

Description

#4558 made it impossible to import twisted.internet.gtk2reactor if sys.modules contains a "gi" key. This seems to overlook the fact that even a *failed* import of the gi module adds such a key to that dictionary. Since the test suite tries to test gireactor, there will always be such a key, so gtk2reactor can never be imported by the test suite. The same issue would operate, only in reverse, if gtk2reactor was imported first.

Change History

1

Changed 2 years ago by itamarst

  • branch set to branches/gtk2-vs-gtk3-5494
  • branch_author set to itamarst

(In [33588]) Branching to 'gtk2-vs-gtk3-5494'

2

Changed 2 years ago by itamar

  • owner itamar deleted
  • keywords review added

3

Changed 2 years ago by itamar

  • owner set to itamar
  • keywords review removed

There's an effort to make a pygtk2 compatible wrapper around gi, and the current checks break that:  http://bazaar.launchpad.net/~stoq-dev/stoq/master/view/head:/stoq/lib/gicompat.py

So, we should make sure we support that too in this branch. Removing from review to ensure that.

4

Changed 2 years ago by itamar

  • keywords review added
  • owner itamar deleted

JP wants this in ASAP so we can have gtk2 tests running again, I'll do the compat layer fix separately.

5

Changed 2 years ago by jdahlin

The patch looks good, but I'd switch the order of the parameters preventImports/errorMessage and always pass in the former by keyword, True/False are not really useful at the callsites.

I'd like a way to disable these checks, for gireactor/gtk3reactor, but that's probably another bug as discussed on irc.

6

Changed 2 years ago by exarkun

  • keywords review removed
  • owner set to itamar

Sort of an improvement. However, gtk2reactor tests still run on no build slaves (in other words, the issue has not been resolved).

The ones which might possibly run it seem to have a too-old version of gi?

First they skip the gtk3 tests because 'gi.repository.GLib' object has no attribute 'threads_init' then they skip the gtk2 tests because No module named gobject (presumably due to the early behavior of twisted/internet/gireactor.py.

I feel as though our buildbot configuration is not doing us any favors here. Do we need an alternate behavior for skipping or skip reporting?

7

Changed 2 years ago by itamar

We are going to have to either setup a specific reactor buildstep for glib2 and gtk2, or setup a specific reactor buildstep for gi+gtk3. Technically we have the former but it has issues because it's too old to run gtk2 correctly!

I reordered things to do the latter; since we don't have a sufficiently new buildslave to use gi anyway, may as well have gtk2 tests running. We will need to setup a buildslave for gi once we have one on a sufficiently modern OS. I will open a ticket for that and jdahlin's pygtk2 compat mode support when this ticket is merged.

8

Changed 2 years ago by itamar

  • keywords review added
  • owner itamar deleted
  • branch_author changed from itamarst to itamar

9

Changed 2 years ago by jesstess

  • owner set to jesstess
  • cc jesstess added

10

Changed 2 years ago by jesstess

  • owner changed from jesstess to itamar
  • keywords review removed

Thanks for working on this, itamar. The code changes look good to me. A couple of mostly cosmetic comments:

  • preventImports defaults to a tuple but is described as a list in the docstring and is passed a list in the tests:
    +def ensureNotImported(moduleNames, errorMessage, preventImports=()):
    
  • Can you add @type markup to the parameters in ensureNotImported?
  • missage => message in:
    +    @raises: C{ImportError} with given error missage if a given module name
    
  • None could get epytext markup in:
    +        If the specified modules have been set to None in C{sys.modules},
    
  • raise => raises in:
    +        L{ensureNotImported} raise an exception.
    

11

Changed 2 years ago by itamarst

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

(In [33732]) Merge gtk2-vs-gtk3-5494: Make sure gtk2 tests run.

Author: itamar Review: exarkun, jesstess Fixes: #5494

If gtk3 was missing, gtk2 tests still wouldn't run. This makes sure they will run. To run gtk3 or gi tests you will need to explicitly choose the applicable reactor for trial.

Note: See TracTickets for help on using tickets.