-
-
Notifications
You must be signed in to change notification settings - Fork 898
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
TypeError: can't apply this __setattr__ to DefaultMeta object #852
Comments
Interestingly, this works fine:
|
With
|
I've just met similar problem. |
This problem is probably caused by changes in Python 3.8.4 (see https://docs.python.org/3/whatsnew/changelog.html#core-and-builtins) |
This issue is caused by this PR from Python 3.8.4: To be more specific, the problem happens here: |
I just confirmed @piotrgredowski hint: |
@taryodor Is this change expected to break backwards compatibility? If not, did somebody inform people at cpython already? |
This comment has been minimized.
This comment has been minimized.
I don't completely understand the reason referred to in the linked cpython change, so I'm not sure what the intended solution in our code is. In 2017, I made a change to construct the declarative base metaclass from some mixin classes to support customizing what features we add. SQLAlchemy is what overrides original cpython issue: https://bugs.python.org/issue39960 |
This comes from the line Causes error: from sqlalchemy.ext.declarative import declarative_base
from flask_sqlalchemy.model import DefaultMeta
Base = declarative_base(metaclass=DefaultMeta)
Base.test = True Doesn't cause error: from sqlalchemy.ext.declarative import declarative_base
Base = declarative_base()
Base.test = True |
cc @zzzeek in case you see reports of this |
I reported it in Python bug tracker: https://bugs.python.org/issue41295 But look carefully into report, and then check the flask-sqlalchemy code: the problem is caused, when a class inheritance from meta and non-metaclasses. And now, 2 months ago the base class for mixins included in You can check this by installing from master ( Please release new version and problem (here) will be gone. |
Oh nice, thanks for reporting and checking the development version. If someone backports the fix to the 2.x branch, I can make a quick bugfix release. Applying flake8 and flake8-bugbear is what caused us to start subclassing |
I created PR: #854 |
2.4.4 released: https://pypi.org/project/Flask-SQLAlchemy/2.4.4/ |
Wow, you guys are amazing! Thank you for resolving the issue that quickly! |
I hope we rescued some developers a few hours of stopped deployments ;) |
Python 3.8.5 was released and this regression (https://bugs.python.org/issue41295) was resolved there: https://docs.python.org/release/3.8.5/whatsnew/changelog.html#python-3-8-5-final. |
I don't know where this comes from. I have a small project where all versions are pinned and the Flask app runs in a Docker container. I just made an unrelated changes with the same versions and get this error. Does this look familiar?
Expected Behavior
Just running without crashes
Actual Behavior
Crashes
Environment
python:3.8-slim-buster
)The text was updated successfully, but these errors were encountered: