Skip to content

Conversation

@aitap
Copy link
Member

@aitap aitap commented Jul 24, 2025

It turns out that my test case from #7138 (comment) causes a warning, but only if run under test.data.table(). The underlying cause is options(encoding = "UTF-8") being in effect for the duration of the test:

oldOptions = options(
datatable.verbose = verbose,
encoding = "UTF-8", # just for tests 708-712 on Windows

We need to write a byte with the most significant bit set, and file(encoding = getOption('encoding')) opened by writeLines() trying to convert that byte from the current encoding to UTF-8 doesn't help. Avoid the warning by explicitly opening a file connection with encoding="" (no conversion) and marking the payload line as "bytes".

Under options(encoding="UTF-8"), writeLines() always tries to perform
text conversion. Giving it bytes that aren't valid in the current
encoding results in warnings. Avoid the warning by explicitly opening a
file connection with encoding="" (no conversion).
@codecov
Copy link

codecov bot commented Jul 24, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.77%. Comparing base (63339e1) to head (2403127).
⚠️ Report is 2 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #7209   +/-   ##
=======================================
  Coverage   98.77%   98.77%           
=======================================
  Files          81       81           
  Lines       15215    15215           
=======================================
  Hits        15029    15029           
  Misses        186      186           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

# regression test for hexdigits subscript overrun (uint8_t wraps over 255, unsigned overflow is well defined in c)
f = tempfile()
writeLines(c('a', rep('0x1.ffffp0', 10000L), '0x1.ff\x9fp0', rep('0x1.ffffp0', 20000L)), f)
ff = file(f, encoding = "")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

might as well put the whole thing in local() to on.exit() closing & deleting.

Also a comment pointing to this PR would be good for posterity sake.

Co-Authored-By: Michael Chirico <michaelchirico4@gmail.com>
@aitap aitap merged commit ca30752 into master Jul 26, 2025
11 checks passed
@aitap aitap deleted the tests-dont-warn-encoding branch July 26, 2025 10:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants