simplefilter decorator does not work as documented

Issue #1075 closed
Alexander Belopolsky
created an issue

When I create a filter as described in the "Write your own filter" document:

@simplefilter
def myfilter(lexer, stream, options):
      ..

lexer.add_filter(myfilter())

I get

TypeError: myfilter() takes 3 positional arguments but 4 were given

I have to work around by adding an extra argument to myfilter:

@simplefilter
def myfilter(self, lexer, stream, options):
      ..

I am using

$ pygmentize -V
Pygments version 2.0.1, (c) 2006-2014 by Georg Brandl.

Comments (2)

  1. Georg Brandl repo owner

    Closes #1075: fix docs for @simplefilter.

    The function needs a "self" argument since it is used as a method in the
    automatically created class. No use fixing that in the code, as it
    kills backwards compatibility.

    → <<cset 8f531b593818>>

  2. Georg Brandl repo owner

    Closes #1075: fix docs for @simplefilter.

    The function needs a "self" argument since it is used as a method in the
    automatically created class. No use fixing that in the code, as it
    kills backwards compatibility.

    → <<cset c98934fb123b>>

  3. Log in to comment