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

Deprecate implicit/magic import of irods_types or irods_errors #184

Open
SwooshyCueb opened this issue Jan 4, 2024 · 0 comments
Open

Deprecate implicit/magic import of irods_types or irods_errors #184

SwooshyCueb opened this issue Jan 4, 2024 · 0 comments

Comments

@SwooshyCueb
Copy link
Member

In multiple places in main.cpp, we import irods_types and irods_errors and then stuff them into an already-imported module's __dict__, with the intention of making them available in the imported module:

bp::object core_module = bp::import("core");
bp::object core_namespace = core_module.attr("__dict__");
bp::object irods_types = bp::import("irods_types");
bp::object irods_errors = bp::import("irods_errors");
core_namespace["irods_types"] = irods_types;
core_namespace["irods_errors"] = irods_errors;

bp::object main_module = bp::import("__main__");
bp::object main_namespace = main_module.attr("__dict__");
bp::object irods_types = bp::import("irods_types");
bp::object irods_errors = bp::import("irods_errors");
// Import global INPUT and OUTPUT variables
main_namespace["global_vars"] = global_vars_python;
// Import global constants
main_namespace["irods_types"] = irods_types;
main_namespace["irods_errors"] = irods_errors;

bp::object main_module = bp::import("__main__");
bp::object irods_types = bp::import("irods_types");
bp::object irods_errors = bp::import("irods_errors");
bp::object main_namespace = main_module.attr("__dict__");
// Import global INPUT and OUTPUT variables
main_namespace["global_vars"] = global_vars_python;
// Import globals
main_namespace["irods_types"] = irods_types;
main_namespace["irods_errors"] = irods_errors;

This is bad for a few reasons:

  • Modules are interpreted on import, before __dict__ can be changed by the C++ code doing the importing. Therefore, the modules are actually not available to any code executed on import.
  • Changing __dict__ of a module in this manner creates further inconsistency for when these modules are implicitly available and when they must first be imported.
  • import irods_types and import irods_errors work just fine. Users should be doing this instead of assuming they will already be imported. No magic pls.

Given that this would be a breaking change, we should first deprecate implicitly/magically imported irods_types and irods_errors before actually making the change.

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

No branches or pull requests

2 participants