Open bnlawrence opened 6 months ago
Thanks for reporting, Bryan. I have seen some such warnings recently elsewhere (not from cfa but in cf-python within interactive Python) and from that I believe they only emerge at Python 3.12, or at least much newer versions of Python. They are definitely not emerging in Python 3.8, at least in the separate cases that raise them I observed (which may be the same ultimate origin).
We will investigate. FYI we have some other harmless warnings being raised (see https://github.com/NCAS-CMS/cfdm/issues/293) that we are overdue to get removed from spamming the user. Hopefully I can find some time and fix both of these at once.
Hi @bnlawrence, I'm a bit stumped, because that line in cfdump
is only executed if you want to look at the man page, i.e. with cfdump -h
. As @sadielbartholomew suggests, the only thing we have is that it's a Python 3.12 thing (I'm running 3.11.8 and don't see it). I've looked at the Python 3.12 changelog, but haven't seen a likely cause, yet.
Removing all of the \
from https://github.com/NCAS-CMS/cfdm/blob/main/scripts/cfdump#L15-L108
still works fine at 3.11.8, and I wonder if that will fix things at 3.12 ...
Hi @sadielbartholomew, I've tested https://github.com/NCAS-CMS/cfdm/pull/292 (\
removed from cfdump
) at Python 3.12.2, and it's fine (no warnings) - could you possibly test it with cfdm
at your older version? Thanks!
OK, here it is, I think (https://docs.python.org/3/whatsnew/3.12.html#other-language-changes):
A backslash-character pair that is not a valid escape sequence now generates a SyntaxWarning, instead of DeprecationWarning. For example, re.compile("\d+.\d+") now emits a SyntaxWarning ("\d" is an invalid escape sequence, use raw strings for regular expression: re.compile(r"\d+.\d+")). In a future Python version, SyntaxError will eventually be raised, instead of SyntaxWarning.
So, some more general work is probably needed on this.
The weird thing about this is that were was no \
anywhere in my command line ... so I wondered if something was trying to escape the hyphens?
I see what you mean, but rest assured that the problem is purely within strings embedded in the library code :)
Hi @sadielbartholomew, I've tested https://github.com/NCAS-CMS/cfdm/pull/292 (\ removed from cfdump) at Python 3.12.2, and it's fine (no warnings) - could you possibly test it with cfdm at your older version? Thanks!
Sure, I have just tested this and noted it on the PR (seemed like a more relevant place to submit comments, given it concerns the specific branch, not just the issue at hand).
The output of cf-dump seems to be seeing some sort of escaping and not liking it. Problem manifests in a docker container (you can use the
atmbnl/datatools
container to see it?So it doesn't like it, then does the right thing ... so the bug is the spurious warning error message!
Environment:
(But this is the "special" version using
)