From c9b3a73a6c246071e84f944e1d39c897dfc54088 Mon Sep 17 00:00:00 2001 From: Antony Lee Date: Thu, 11 May 2023 21:04:57 +0200 Subject: [PATCH] Fix incorrect usage of nargs_error. nargs_error simply returns the exception, the caller needs to throw it. --- lib/matplotlib/axes/_axes.py | 6 +++--- lib/matplotlib/rcsetup.py | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/matplotlib/axes/_axes.py b/lib/matplotlib/axes/_axes.py index 91aba7c1bdac..5d130930d5f0 100644 --- a/lib/matplotlib/axes/_axes.py +++ b/lib/matplotlib/axes/_axes.py @@ -321,7 +321,7 @@ def legend(self, *args, **kwargs): *args, **kwargs) if len(extra_args): - _api.nargs_error('legend', '0-2', len(args)) + raise _api.nargs_error('legend', '0-2', len(args)) self.legend_ = mlegend.Legend(self, handles, labels, **kwargs) self.legend_._remove_method = self._remove_legend return self.legend_ @@ -3005,7 +3005,7 @@ def stem(self, *args, linefmt=None, markerfmt=None, basefmt=None, bottom=0, which inspired this method. """ if not 1 <= len(args) <= 3: - _api.nargs_error('stem', '1-3', len(args)) + raise _api.nargs_error('stem', '1-3', len(args)) _api.check_in_list(['horizontal', 'vertical'], orientation=orientation) if len(args) == 1: @@ -6422,7 +6422,7 @@ def pcolorfast(self, *args, alpha=None, norm=None, cmap=None, vmin=None, else: raise TypeError("arguments do not match valid signatures") else: - _api.nargs_error('pcolorfast', '1 or 3', len(args)) + raise _api.nargs_error('pcolorfast', '1 or 3', len(args)) if style == "quadmesh": # data point in each cell is value at lower left corner diff --git a/lib/matplotlib/rcsetup.py b/lib/matplotlib/rcsetup.py index a9bebd209077..e9b967468226 100644 --- a/lib/matplotlib/rcsetup.py +++ b/lib/matplotlib/rcsetup.py @@ -693,7 +693,7 @@ def cycler(*args, **kwargs): elif len(args) == 2: pairs = [(args[0], args[1])] elif len(args) > 2: - _api.nargs_error('cycler', '0-2', len(args)) + raise _api.nargs_error('cycler', '0-2', len(args)) else: pairs = kwargs.items()