Skip to content

Commit a4d2105

Browse files
committed
refactor(pane,session,window): Use object.__getattribute__
See also: - In order to avoid infinite recursion in this method, its implementation should always call the base class method with the same name to access any attributes it needs, for example, object.__getattribute__(self, name) https://docs.python.org/2.7/reference/datamodel.html#object.__getattribute__
1 parent c483644 commit a4d2105

File tree

3 files changed

+6
-3
lines changed

3 files changed

+6
-3
lines changed

src/libtmux/pane.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,8 @@ def refresh(self) -> None:
152152

153153
@property
154154
def _info(self) -> PaneDict: # type: ignore # mypy#1362
155-
attrs = {"pane_id": self._pane_id}
155+
# attrs = {"pane_id": self._pane_id}
156+
attrs = {"pane_id": object.__getattribute__(self, "_pane_id")}
156157

157158
# from https://github.com/serkanyersen/underscore.py
158159
def by(val: PaneDict) -> bool:

src/libtmux/session.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,8 @@ def __init__(self, server: "Server", session_id: str, **kwargs: t.Any) -> None:
8686

8787
@property
8888
def _info(self) -> t.Optional[SessionDict]: # type: ignore # mypy#1362
89-
attrs = {"session_id": str(self._session_id)}
89+
# attrs = {"session_id": str(self._session_id)}
90+
attrs = {"session_id": object.__getattribute__(self, "_session_id")}
9091

9192
def by(val: SessionDict) -> bool:
9293
for key in attrs.keys():

src/libtmux/window.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,8 @@ def __repr__(self) -> str:
103103

104104
@property
105105
def _info(self) -> WindowDict: # type: ignore # mypy#1362
106-
attrs = {"window_id": self._window_id}
106+
# attrs = {"window_id": self._window_id}
107+
attrs = {"window_id": object.__getattribute__(self, "_window_id")}
107108

108109
# from https://github.com/serkanyersen/underscore.py
109110
def by(val: WindowDict) -> bool:

0 commit comments

Comments
 (0)