File tree Expand file tree Collapse file tree 1 file changed +11
-4
lines changed
Filter options
Expand file tree Collapse file tree 1 file changed +11
-4
lines changed
Original file line number Diff line number Diff line change @@ -1292,16 +1292,23 @@ def __init__(self, rc=None, fname=None):
1292
1292
if rc :
1293
1293
rcParams .update (rc )
1294
1294
except Exception :
1295
- # If anything goes wrong, revert to the original rcs.
1296
- dict .update (rcParams , self ._orig )
1295
+ self .__fallback ()
1297
1296
raise
1298
1297
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
+
1299
1307
def __enter__ (self ):
1300
1308
return self
1301
1309
1302
1310
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 ()
1305
1312
1306
1313
1307
1314
def use (arg , warn = True , force = False ):
You can’t perform that action at this time.
0 commit comments