tryCatch for nchar() on old R - #7848
Merged
Merged
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## other-attach-order #7848 +/- ##
===================================================
Coverage 99.01% 99.01%
===================================================
Files 88 88
Lines 17286 17286
===================================================
Hits 17116 17116
Misses 170 170 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
Generated via commit a0baec7 Download link for the artifact containing the test results: ↓ atime-results.zip
|
MichaelChirico
force-pushed
the
old-nchar-try
branch
from
July 27, 2026 17:00
bc34480 to
a8b67f9
Compare
MichaelChirico
force-pushed
the
old-nchar-try
branch
from
July 27, 2026 21:51
a8b67f9 to
cda0c41
Compare
Member
|
changes look good to me.. this may be the fix on R's side: r-devel/r-svn@a786d1e |
Member
Author
|
Great spot! I find that on R 4.1.3: But not R 4.2.0: |
MichaelChirico
force-pushed
the
old-nchar-try
branch
from
July 28, 2026 00:06
cda0c41 to
f31ac69
Compare
MichaelChirico
force-pushed
the
other-attach-order
branch
from
July 28, 2026 02:04
05c2b03 to
ebd74db
Compare
MichaelChirico
force-pushed
the
old-nchar-try
branch
2 times, most recently
from
July 28, 2026 05:37
401eb10 to
c4a4fee
Compare
Member
|
Since diff --git a/R/print.data.table.R b/R/print.data.table.R
index e602f80d6..817e49420 100644
--- a/R/print.data.table.R
+++ b/R/print.data.table.R
@@ -256,7 +256,7 @@ char.trunc = function(x, trunc.char = getOption("datatable.prettyprint.char")) {
if (is.null(trunc.char)) return(x)
trunc.char = max(0L, suppressWarnings(as.integer(trunc.char[1L])), na.rm=TRUE)
if (!is.character(x) || trunc.char <= 0L) return(x)
- nchar_width = nchar(x, 'width', allowNA = TRUE)
+ nchar_width = tryCatch(nchar(x, 'width', allowNA = TRUE), error = function(...) NA)
nchar_chars = nchar(x, 'char', allowNA = TRUE)
is_full_width = nchar_width > nchar_chars
is_full_width[is.na(is_full_width)] = FALSEand let the rest of the code handle the |
Member
Author
|
Great suggestion! Added the NEWS now |
joshhwuu
approved these changes
Jul 28, 2026
aitap
approved these changes
Jul 28, 2026
MichaelChirico
force-pushed
the
old-nchar-try
branch
from
July 28, 2026 20:07
a0baec7 to
a80cd2f
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

See e.g.
h/t @joshhwuu for identifying the culprit R bugfix in the comment below.