[Rd] Question regarding .make_numeric_version with non-character input
Kurt Hornik
Kurt@Horn|k @end|ng |rom wu@@c@@t
Thu Apr 25 08:07:56 CEST 2024
>>>>> Hervé Pagès writes:
> Hi Kurt,
> Is it intended that numeric_version() returns an error by default on
> non-character input in R 4.4.0?
Dear Herve, yes, that's the intention.
> It seems that I can turn this into a warning by setting
> _R_CHECK_STOP_ON_INVALID_NUMERIC_VERSION_INPUTS_=false but I don't
> seem to be able to find any of this mentioned in the NEWS file.
That's what I added for smoothing the transition: it will be removed
from the trunk shortly.
Best
-k
> Thanks,
> H.
> On 4/1/24 05:28, Kurt Hornik wrote:
> Andrea Gilardi via R-devel writes:
> Thanks: should be fixed now in the trunk.
> Best
> -k
> Thank you very much Dirk for your kind words and for confirming the bug.
> Next week I will open a new issue on Bugzilla adding the related patch.
> Kind regards
> Andrea
> On 29/03/2024 20:14, Dirk Eddelbuettel wrote:
> On 29 March 2024 at 17:56, Andrea Gilardi via R-devel wrote:
> | Dear all,
> |
> | I have a question regarding the R-devel version of .make_numeric_version() function. As far as I can understand, the current code (https://github.com/wch/r-source/blob/66b91578dfc85140968f07dd4e72d8cb8a54f4c6/src/library/base/R/version.R#L50-L56) runs the following steps in case of non-character input:
> |
> | 1. It creates a message named msg using gettextf.
> | 2. Such object is then passed to stop(msg) or warning(msg) according to the following condition
> |
> | tolower(Sys.getenv("_R_CHECK_STOP_ON_INVALID_NUMERIC_VERSION_INPUTS_") != "false")
> |
> | However, I don't understand the previous code since the output of Sys.getenv("_R_CHECK_STOP_ON_INVALID_NUMERIC_VERSION_INPUTS_") != "false" is just a boolean value and tolower() will just return "true" or "false". Maybe the intended code is tolower(Sys.getenv("_R_CHECK_STOP_ON_INVALID_NUMERIC_VERSION_INPUTS_")) != "false" ? Or am I missing something?
> Yes, agreed -- good catch. In full, the code is (removing leading
> whitespace, and putting it back onto single lines)
> msg <- gettextf("invalid non-character version specification 'x' (type: %s)", typeof(x))
> if(tolower(Sys.getenv("_R_CHECK_STOP_ON_INVALID_NUMERIC_VERSION_INPUTS_") != "false"))
> stop(msg, domain = NA)
> else
> warning(msg, domain = NA, immediate. = TRUE)
> where msg is constant (but reflecting language settings via standard i18n)
> and as you not the parentheses appear wrong. What was intended is likely
> msg <- gettextf("invalid non-character version specification 'x' (type: %s)", typeof(x))
> if(tolower(Sys.getenv("_R_CHECK_STOP_ON_INVALID_NUMERIC_VERSION_INPUTS_")) != "false")
> stop(msg, domain = NA)
> else
> warning(msg, domain = NA, immediate. = TRUE)
> If you use bugzilla before and have a handle, maybe file a bug report with
> this as patch at https://bugs.r-project.org/
> Dirk
> ______________________________________________
> R-devel using r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
> ______________________________________________
> R-devel using r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
> --
> Hervé Pagès
> Bioconductor Core Team
> hpages.on.github using gmail.com
More information about the R-devel
mailing list