Dean Attali
2019-Feb-20 23:07 UTC
[Rd] Bug in print.default: dispatches to global show instead of methods::show
This is related to a problem that was fixed in 2015 https://github.com/wch/r-source/commit/38ea40dcd0353af16d35296ee621338c49ae48c9 The problem then was that auto-printing by typing an object to the console would search for show() in the globalenv instead of in the methods namespace. The problem I would like to report is that it seems that when an S4 object is printed with print(), a similar issue happens. I do realize that S4 objects should be printed with show() rather than print(), which would solve the issue, but this still seems like a bug to me. Example: library(methods) show <- function(...) message("hijacked!") setClass("Test", representation(test = "character")) test <- new("Test") print(test) # hijacked! [[alternative HTML version deleted]]
Lionel Henry
2019-Feb-21 11:27 UTC
[Rd] Bug in print.default: dispatches to global show instead of methods::show
Hello, This is already fixed in r-devel, I think by this commit: https://github.com/wch/r-source/commit/b59a1526085d1b4375b184d35118c6fd6f003912#diff-12de104c9320556f0e99da345c6fb259 <https://github.com/wch/r-source/commit/b59a1526085d1b4375b184d35118c6fd6f003912#diff-12de104c9320556f0e99da345c6fb259> Best, Lionel> On 21 Feb 2019, at 00:07, Dean Attali <daattali at gmail.com> wrote: > > This is related to a problem that was fixed in 2015 > https://github.com/wch/r-source/commit/38ea40dcd0353af16d35296ee621338c49ae48c9 > The problem then was that auto-printing by typing an object to the console > would search for show() in the globalenv instead of in the methods > namespace. > > The problem I would like to report is that it seems that when an S4 object > is printed with print(), a similar issue happens. I do realize that S4 > objects should be printed with show() rather than print(), which would > solve the issue, but this still seems like a bug to me. > > Example: > > library(methods) > show <- function(...) message("hijacked!") > setClass("Test", representation(test = "character")) > test <- new("Test") > print(test) > # hijacked! > > [[alternative HTML version deleted]] > > ______________________________________________ > R-devel at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-devel[[alternative HTML version deleted]]
Martin Maechler
2019-Feb-21 16:29 UTC
[Rd] Bug in print.default: dispatches to global show instead of methods::show
>>>>> Lionel Henry >>>>> on Thu, 21 Feb 2019 12:27:11 +0100 writes:> Hello, > This is already fixed in r-devel, I think by this commit: > https://github.com/wch/r-source/commit/b59a1526085d1b4375b184d35118c6fd6f003912#diff-12de104c9320556f0e99da345c6fb259 <https://github.com/wch/r-source/commit/b59a1526085d1b4375b184d35118c6fd6f003912#diff-12de104c9320556f0e99da345c6fb259> > Best, > Lionel Yes, indeed... part of patches that Lionel had proposed himself! Best, Martin >> On 21 Feb 2019, at 00:07, Dean Attali <daattali at gmail.com> wrote: >> >> This is related to a problem that was fixed in 2015 >> https://github.com/wch/r-source/commit/38ea40dcd0353af16d35296ee621338c49ae48c9 >> The problem then was that auto-printing by typing an object to the console >> would search for show() in the globalenv instead of in the methods >> namespace. >> >> The problem I would like to report is that it seems that when an S4 object >> is printed with print(), a similar issue happens. I do realize that S4 >> objects should be printed with show() rather than print(), which would >> solve the issue, but this still seems like a bug to me. >> >> Example: >> >> library(methods) >> show <- function(...) message("hijacked!") >> setClass("Test", representation(test = "character")) >> test <- new("Test") >> print(test) >> # hijacked! >> >> [[alternative HTML version deleted]] >> >> ______________________________________________ >> R-devel at r-project.org mailing list >> https://stat.ethz.ch/mailman/listinfo/r-devel > [[alternative HTML version deleted]] > ______________________________________________ > R-devel at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-devel
Seemingly Similar Threads
- Bug in print.default: dispatches to global show instead of methods::show
- Defining a `show` function breaks the print-ing of S4 object -- bug or expected?
- Suggestion/opinions: add a `absolute` param to `normalizePath()` to force returning an absolute path
- best way to build from Git
- Bug in tools::md5sum - does not work when filepath contains tilde (ie home directory)