summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKeelung Yang <keelung_yang@163.com>2018-07-26 15:27:26 +0800
committerGitHub <noreply@github.com>2018-07-26 15:27:26 +0800
commit2a77846ee3e5a0c9fae7de02ec04609d46e6ef9e (patch)
treeccb5a1b7968310336826fc81bcd3d41246d64f36
parenta27715f322bb08b1fccffebab776c94df50057e9 (diff)
downloadpyserial-git-2a77846ee3e5a0c9fae7de02ec04609d46e6ef9e.tar.gz
Don't open port if self.port is not set while entering context manager
-rw-r--r--serial/serialutil.py2
1 files changed, 1 insertions, 1 deletions
diff --git a/serial/serialutil.py b/serial/serialutil.py
index 2cce816..0ba0563 100644
--- a/serial/serialutil.py
+++ b/serial/serialutil.py
@@ -559,7 +559,7 @@ class SerialBase(io.RawIOBase):
# context manager
def __enter__(self):
- if not self.is_open:
+ if self.port and not self.is_open:
self.open()
return self