Skip to content
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

"v52.betas.to52beta1" puts the Python import machinery in an inconsistent state #245

Open
d-maurer opened this issue Sep 22, 2020 · 2 comments

Comments

@d-maurer
Copy link

Python 2.7, plone.app.upgrade==2.0.34, Products.ResourceRegistries installed:
After the call of to52beta1 import Products.ResourceRegistries fails with cannot import name "config" - even though config.py exists in Products.ResourceRegistries.

The reason: to52beta1 hacks the Python import machinery and brings it into an inconsistent state regarding Products.ResourceRegistries. The import machinery raises an ImportError for from m import n if n happens to be a module in sys.modules and is not an attribute of m. to52beta1 deletes Products.ResourceRegistries but lets Products.ResourceRegistries.config in sys.modules -- causing the inconsistency and the error above.

I recommend to remove all modules related to Products.ResourceRegistries from sys.modules in v52beta1 to properly clean up after the import machinery hack.

In recent versions (e.g. plone.app.upgrade==2.0.34), to52beta1 has got at its end an install_product('plone.staticresources'). This fails for us with the ImportError above (due to the import machinery inconsistency). Apparently, this ImportError is hidden by upper layers of the upgrade machinery (this likely should not happen).

The problems possibly only occur if Products.ResourceRegistries is installed.

@mauritsvanrees
Copy link
Sponsor Member

So that is this function.

And the cleanup here is not enough?

Note that we also have some sys modules hackery for resource registries in the __init__.pyhttps://github.com/plone/plone.app.upgrade/blob/2.0.34/plone/app/upgrade/__init__.py#L162-L164), although that does not touch the config module.

How do we reproduce this? From reading the above, my guess is (without trying it):

  • Create a Plone 5.1 site.
  • Upgrade the buildout to 5.2, still Python 2.7.
  • Make sure that Products.ResourceRegistries is explicitly in the eggs.
  • Start 5.2, run the migration at @@plone-upgrade, and it crashes.

@d-maurer
Copy link
Author

d-maurer commented Sep 22, 2020 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants