Replace deprecation warning with RuntimeError (GH-14397)

(cherry picked from commit 97d15b1ee06ce80c4dbda91fb538a89bbcb2bed9)

Co-authored-by: Andrew Svetlov <andrew.svetlov@gmail.com>
2 files changed