Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 8e28c35

Browse files
committed
validate num argument to figure()
Otherwise, the resulting exception can be obscure and delayed. svn path=/trunk/matplotlib/; revision=6105
1 parent 88c285e commit 8e28c35

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

lib/matplotlib/pyplot.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ def figure(num=None, # autoincrement if None, else integer from 1-N
184184
"""
185185
call signature::
186186
187-
figure(num = None, figsize=(8, 6), dpi=80, facecolor='w', edgecolor='k')
187+
figure(num=None, figsize=(8, 6), dpi=80, facecolor='w', edgecolor='k')
188188
189189
190190
Create a new figure and return a :class:`matplotlib.figure.Figure`
@@ -234,6 +234,9 @@ class that will be passed on to :meth:`new_figure_manager` in the
234234
num = max(allnums) + 1
235235
else:
236236
num = 1
237+
else:
238+
num = int(num) # crude validation of num argument
239+
237240

238241
figManager = _pylab_helpers.Gcf.get_fig_manager(num)
239242
if figManager is None:

0 commit comments

Comments
 (0)