-
Notifications
You must be signed in to change notification settings - Fork 272
Description
Hello Graham,
We met this issue when trying to upgrade our app to Fedora Linux 35 (which has mod_wsgi 4.9.0 and Python 3.10). After some research, it seems that decorators added to class definitions are somehow ignored, so any modification they would do to the class just wont happen.
For example, the following code raises a TypeError: Greeting() takes no arguments
when served through mod_wsgi
running on Fedora Linux 35, but works without errors on Fedora Linux 34 (mod_wsgi 4.7.1, Python 3.9).
Serving it with flask's own server or through gunicorn on Fedora Linux 35 also works fine.
Running the code in an interactive interpreter or standalone script also works fine.
from flask import Flask
def tweak_init(cls):
def new_init(inst, name):
inst.text = f"Hello, {name}\n"
cls.__init__ = new_init
return cls
@tweak_init
class Greeting:
pass
app = Flask(__name__)
@app.route("/")
def main():
return Greeting("Pete").text
I've prepared a reproducer to build the app above both on Fedora Linux 34 and 35.
ATM I have run out of ideas how to continue to debug this. If you could give me some pointers, I would gladly spend the time to research this more.