Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 7dffd5b

Browse filesBrowse files
tacaswellanntzer
authored andcommitted
MNT: special case the handling of 'backend' in rc_context
If the context block triggers the auto-resolution of the backend keep than information around.
1 parent ce04937 commit 7dffd5b
Copy full SHA for 7dffd5b

File tree

Expand file treeCollapse file tree

1 file changed

+11
-4
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+11
-4
lines changed

‎lib/matplotlib/__init__.py

Copy file name to clipboardExpand all lines: lib/matplotlib/__init__.py
+11-4Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1292,16 +1292,23 @@ def __init__(self, rc=None, fname=None):
12921292
if rc:
12931293
rcParams.update(rc)
12941294
except Exception:
1295-
# If anything goes wrong, revert to the original rcs.
1296-
dict.update(rcParams, self._orig)
1295+
self.__fallback()
12971296
raise
12981297

1298+
def __fallback(self):
1299+
# If anything goes wrong, revert to the original rcs.
1300+
updated_backend = self._orig['backend']
1301+
dict.update(rcParams, self._orig)
1302+
# except for the backend. If the context block triggered resloving
1303+
# the auto backend resolution keep that value around
1304+
if self._orig['backend'] is rcsetup._auto_backend_sentinel:
1305+
rcParams['backend'] = updated_backend
1306+
12991307
def __enter__(self):
13001308
return self
13011309

13021310
def __exit__(self, exc_type, exc_value, exc_tb):
1303-
# No need to revalidate the original values.
1304-
dict.update(rcParams, self._orig)
1311+
self.__fallback()
13051312

13061313

13071314
def use(arg, warn=True, force=False):

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.