LINE icon indicating copy to clipboard operation
LINE copied to clipboard

Bug in _findContactByUserid

Open ivan98 opened this issue 9 years ago • 1 comments

There is recursion bug in function _findContactByUserid, as shown:

Python 2.7.10 (default, Jan 10 2016, 14:48:07) 
[GCC 4.8.4] on linux2
Type "help", "copyright", "credits" or "license" for more information.
__> from line import LineClient
__> client = LineClient(authToken="xxxxxx")
__> client.findContactByUserid("yyyyy")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: 'LineClient' object has no attribute 'findContactByUserid'
__> client._findContactByUserid("yyyyy")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "line/client.py", line 27, in wrapper_check_auth
    return func(*args, **kwargs)
  File "line/client.py", line 253, in _findContactByUserid
    contact = self._findContactByUserid(userid)
  File "line/client.py", line 27, in wrapper_check_auth
    return func(*args, **kwargs)
  File "line/client.py", line 253, in _findContactByUserid
    contact = self._findContactByUserid(userid)
  -=REPEATS=-
RuntimeError: maximum recursion depth exceeded
__> 

The fix seems to be

$ diff -Naur line2/client.py line/client.py                                                                                                        
--- line2/client.py     2016-09-07 11:47:38.729857006 +0800
+++ line/client.py      2016-09-04 21:52:29.243941119 +0800
@@ -244,7 +244,7 @@
         return c

     @check_auth
-    def _findContactByUserid(self, userid):
+    def findContactByUserid(self, userid):
         """Find a `contact` by userid

         :param userid: user id

ivan98 avatar Sep 07 '16 04:09 ivan98

try idL = "LINE_ID" fc = client._client.findContactByuserid(idL) print fc

if fc return something it mean id is exist

ii64 avatar Mar 27 '17 16:03 ii64