File tree Expand file tree Collapse file tree 1 file changed +2
-9
lines changed Expand file tree Collapse file tree 1 file changed +2
-9
lines changed Original file line number Diff line number Diff line change @@ -160,7 +160,7 @@ def session_pointer(self) -> ctp.c_void_p:
160
160
If trying to access without a currently open GMT session (i.e., outside of
161
161
the context manager).
162
162
"""
163
- if not hasattr (self , "_session_pointer" ) or self . _session_pointer is None :
163
+ if getattr (self , "_session_pointer" , None ) is None :
164
164
raise GMTCLibNoSessionError ("No currently open GMT API session." )
165
165
return self ._session_pointer
166
166
@@ -338,19 +338,12 @@ def create(self, name: str):
338
338
name
339
339
A name for this session. Doesn't really affect the outcome.
340
340
"""
341
- try :
342
- # Won't raise an exception if there is a currently open session.
343
- _ = self .session_pointer
344
- # In this case, fail to create a new session until the old one is destroyed.
341
+ if getattr (self , "session_pointer" , None ) is not None :
345
342
msg = (
346
343
"Failed to create a GMT API session: There is a currently open session."
347
344
" Must destroy it first."
348
345
)
349
346
raise GMTCLibError (msg )
350
- # If the exception is raised, this means that there is no open session and we're
351
- # free to create a new one.
352
- except GMTCLibNoSessionError :
353
- pass
354
347
355
348
c_create_session = self .get_libgmt_func (
356
349
"GMT_Create_Session" ,
You can’t perform that action at this time.
0 commit comments