Skip to content

Commit

Permalink
fix got newer python version
Browse files Browse the repository at this point in the history
  • Loading branch information
rlehfeld committed Apr 22, 2024
1 parent d11788a commit cf1596a
Showing 1 changed file with 16 additions and 22 deletions.
38 changes: 16 additions & 22 deletions RPyCRobotRemote/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,38 +36,32 @@ def _accept_method(self, sock):
def patch_is_list_like(func):
"""patch is_list_like as it leads to exception with remote namedtuples"""
def is_list_like(item):
if isinstance(item, (str, bytes, bytearray)):
return False
try:
if isinstance(item, UserString):
return False
except TypeError:
pass

try:
if isinstance(item, IOBase):
return False
except TypeError:
pass

for t in (str, bytes, bytearray, UserString, IOBase):
try:
if isinstance(item, t):
return False
except TypeError:
pass
try:
return isinstance(item, Iterable)
except TypeError:
pass

try:
iter(item)
except TypeError:
return False
return True

code = is_list_like.__code__
func.__code__ = func.__code__.replace(
co_code=code.co_code,
co_consts=code.co_consts,
co_names=code.co_names,
co_flags=code.co_flags,
co_stacksize=code.co_stacksize)
if True:
func.__code__ = is_list_like.__code__
else:
code = is_list_like.__code__
func.__code__ = func.__code__.replace(
co_code=code.co_code,
co_consts=code.co_consts,
co_names=code.co_names,
co_flags=code.co_flags,
co_stacksize=code.co_stacksize)


patch_is_list_like(robot.utils.is_list_like)

0 comments on commit cf1596a

Please sign in to comment.