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

Skip to content

Commit a7b574c

Browse files
committed
fixed -dbackend to only respond to known backends
svn path=/trunk/matplotlib/; revision=661
1 parent a3428e8 commit a7b574c

2 files changed

Lines changed: 15 additions & 5 deletions

File tree

CHANGELOG

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
New entries should be added at the top
22

33
==============================================================
4+
2004-11-04 Changed -dbackend processing to only use known backends, so
5+
we don't clobber other non-matplotlib uses of -d, like -debug.
6+
47
2004-11-04 backend_agg.py: added IMAGE_FORMAT to list the formats that the
58
backend can save to.
69
backend_gtkagg.py: added support for saving JPG files by using the

lib/matplotlib/__init__.py

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -756,15 +756,22 @@ def rcdefaults():
756756
# Allow command line access to the backend with -d (matlab compatible
757757
# flag)
758758

759+
_knownBackends = {
760+
'PS':1, 'GTK':1, 'Template':1, 'GD':1,
761+
'WX':1, 'Paint':1, 'Agg':1, 'GTKAgg':1, 'SVG':1,
762+
'TkAgg':1, 'WXAgg':1, 'FltkAgg':1, 'Cairo':1, 'GTKCairo':1,}
763+
759764
if hasattr(sys,'argv'): # mod_python doesn't have argv attr
765+
known = _knownBackends.keys()
760766
for s in sys.argv[1:]:
761767
if s.startswith('-d'): # look for a -d flag
762-
rcParams['backend'] = s[2:].strip()
763-
break
768+
name = s[2:].strip()
769+
# we don't want to assume all -d flags are backends, eg -debug
770+
if name in known:
771+
rcParams['backend'] = name
772+
break
773+
764774

765-
_knownBackends = {'PS':1, 'GTK':1, 'Template':1, 'GD':1,
766-
'WX':1, 'Paint':1, 'Agg':1, 'GTKAgg':1, 'SVG':1,
767-
'TkAgg':1, 'WXAgg':1, 'FltkAgg':1, 'Cairo':1, 'GTKCairo':1,}
768775

769776
def use(arg):
770777
"""

0 commit comments

Comments
 (0)