Skip to content

Commit

Permalink
Merge pull request #727 from bmoneke/contextmanager-termchar
Browse files Browse the repository at this point in the history
read_termination_context uses read_termination logic
  • Loading branch information
MatthieuDartiailh committed Feb 24, 2023
2 parents 19a5061 + fda606b commit df50969
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
1 change: 1 addition & 0 deletions CHANGES
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ PyVISA Changelog
1.14.0 (unreleased)
-------------------
- fix ctypes truncated pointers on 64-bit for ViBusAddress, ViBusSize, ViAttrState PR # 725
- fix read_termination_context does not allow None PR # 727

1.13.0 (22-12-2022)
-------------------
Expand Down
8 changes: 3 additions & 5 deletions pyvisa/resources/messagebased.py
Original file line number Diff line number Diff line change
Expand Up @@ -773,12 +773,10 @@ def read_stb(self) -> int:

@contextlib.contextmanager
def read_termination_context(self, new_termination: str) -> Iterator:
term = self.get_visa_attribute(constants.ResourceAttribute.termchar)
self.set_visa_attribute(
constants.ResourceAttribute.termchar, ord(new_termination[-1])
)
term = self.read_termination
self.read_termination = new_termination
yield
self.set_visa_attribute(constants.ResourceAttribute.termchar, term)
self.read_termination = term

def flush(self, mask: constants.BufferOperation) -> None:
"""Manually clears the specified buffers.
Expand Down

0 comments on commit df50969

Please sign in to comment.