summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorzsquareplusc <cliechti@gmx.net>2019-08-13 13:56:59 +0200
committerGitHub <noreply@github.com>2019-08-13 13:56:59 +0200
commite20b773c9bc9aabd93504071ffcd30851be5a430 (patch)
tree5bbc7eb7738efee3fc1bd7f1313181263e61a45e
parent4f6666b39113ec58459cbc2f7af4d7de11214674 (diff)
parent24b02e6ae39b11e52137fd5e73c9dccc2cdeeaca (diff)
downloadpyserial-git-e20b773c9bc9aabd93504071ffcd30851be5a430.tar.gz
Merge pull request #371 from keelung-yang/master
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..2785b6f 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 is not None and not self.is_open:
self.open()
return self