-
Notifications
You must be signed in to change notification settings - Fork 49
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
Unit('0')
prints NULL factor argument
and NULL unit argument
#240
Comments
After looking around in the code a bit, I found that you can use the undocumented function from cf_units import Unit, suppress_errors
with suppress_errors():
Unit('0') |
Looks like there are a few undocumented yet public functions in there (e.g. |
The current default behaviour of printing to |
#453 FTW, I think. |
Hi @bouweandela @schlunma I've been looking into this and discovered some things (details to follow). Is that going to be a problem, or can we proceed to v3.3. without a fix for this ? |
Thanks for taking care of this @pp-mo! No, not a problem at all. We are happy with out current solution (that uses |
I've inspected the main module, the Cython code and the published C interface spec, in particular the section on error handling. So definitely there are other things you can do which result in the same sort of arbitrary error messages printed directly to the console.
-- here, the line beginning "productRoot()" is a printed error message. If the existing code logic is all correct, then presumably :
( Note: there definitely are functions which do not have identifiable error return values, such as So ... assuming all that is correct in the existing code, then any operation which prints an error message should also already be calling A better general solution ?So, I think a better way of handling this would be to permanently set the library error handler to a C function which records the error message somewhere global, and then include the error message text within the raised exception. Does that sound like an acceptable solution ? Some odd notes + thoughts :
|
🐛 Bug Report
While reading lots of large netCDF files with
iris
, I noticed that my entirestderr
is cluttered with the following prints:These come from the use of
cf_units.Unit('0')
for variables with the unit'0'
.How to Reproduce
Steps to reproduce the behaviour:
Using
correctly raises an error, but also prints the messages mentioned above:
These warnings cannot be suppressed using
python -W ignore
or by usingwarnings.filterwarnings
.Expected Behaviour
These warnings should not be printed or be issued using the
warnings
module so they can be handled properly.Environment
The text was updated successfully, but these errors were encountered: