internlm/SWE-Fixer-Train-110K huggingface dataset:
Repository: InstaPy/InstaPy

Issue:
OnlyNotFollowMe not doing anything
<!-- Is this a Feature Request ? Please, check out our Wiki first https://github.com/timgrossmann/InstaPy/wiki -->
## Expected Behavior
This simple script does absolutly nothing. I can't find the reason why and couldn't find anyone here that had the same problem. I don't know if it's working for everybody else, but The more people I follow, the less i'm able to unfollow afterwards.

## Current Behavior
INFO - Session started - 2017-12-01 23:01:53
CRITICAL - Sorry, Record Activity is not working on Windows. We're working to fix this soon!
INFO - Logged in successfully!
INFO - Number of people followed automatically remaining: 5681
INFO - --> Total people unfollowed : 0 
INFO - Session ended - 2017-12-01 23:02:13
INFO - --------------------

## InstaPy configuration
session = InstaPy()
session.login()
session.unfollow_users(amount=100,onlyInstapyFollowed = False, onlyNotFollowMe=True)
session.end()



Discussion:
I tried to look for a Y. but it seems that you don't capture all of your follower/following since rate is too high and instagram blocks you.
Try add this:
unfollow_util.py 
line 175 add a sleep after the while:
while has_next_data:
    **sleep(10)**


You need to add the sleep after the while


Thanks for the reply, Still experiencing exactly the same results though. Should I just delete some of the followers from the list?

Resolving patch:
diff --git a/instapy/unfollow_util.py b/instapy/unfollow_util.py
--- a/instapy/unfollow_util.py
+++ b/instapy/unfollow_util.py
@@ -128,7 +128,7 @@ def unfollow(browser,
         except BaseException as e:
             logger.error("unfollow loop error {}".format(str(e)))
 
-    elif onlyInstapyFollowed is not True and onlyNotFollowMe is True:
+    elif onlyInstapyFollowed is False and onlyNotFollowMe is True:
         # unfollow only not follow me
         try:
             browser.get(
@@ -161,10 +161,12 @@ def unfollow(browser,
                     .format(graphql_followers, str(json.dumps(variables)))
                 )
                 if i != 0:
+                    del variables['after']
                     url = (
                         '{}&variables={}'
                         .format(graphql_following, str(json.dumps(variables)))
                     )
+                sleep(2)
                 browser.get(url)
 
                 # fetch all user while still has data
@@ -204,6 +206,7 @@ def unfollow(browser,
                                     str(json.dumps(variables))
                                 )
                             )
+                        sleep(2)
                         browser.get(url)
         except BaseException as e:
             print(


Test patch:
Repository: InstaPy/InstaPy

Issue:
log_record_all_unfollowed() takes 4 args, not 3, fix this line to add log folder
In instapy/print_log_writer.py 
`def log_record_all_unfollowed(login, unfollowed, logger, logfolder):`
log_record_all_unfollowed() takes 4 args, fix this line to add log folder.

https://github.com/timgrossmann/InstaPy/blob/191bf315386f505b45f26d098aada24e741c69e0/instapy/unfollow_util.py#L140

and here

https://github.com/timgrossmann/InstaPy/blob/191bf315386f505b45f26d098aada24e741c69e0/instapy/unfollow_util.py#L136

among other places...


Discussion:

Resolving patch:
diff --git a/instapy/unfollow_util.py b/instapy/unfollow_util.py
--- a/instapy/unfollow_util.py
+++ b/instapy/unfollow_util.py
@@ -151,11 +151,11 @@ def unfollow(browser,
                     else:
 						# this user found in our list of unfollow but is not followed
                         if follow_button.text != 'Follow':
-                            log_uncertain_unfollowed_pool(username, person, logger)
+                            log_uncertain_unfollowed_pool(username, person, logger, logfolder)
                         delete_line_from_file('{0}{1}_followedPool.csv'.format(logfolder, username),
                                               person + ",\n", logger)
                         # save any unfollowed person
-                        log_record_all_unfollowed(username, person, logger)
+                        log_record_all_unfollowed(username, person, logger, logfolder)
 
                         logger.warning(
                             '--> Cannot Unfollow From InstaPy {}'


Test patch:
Repository: InstaPy/InstaPy

Issue:
self.liked_img not initialized
I just had a crash because self.liked_img in instapy.py line 1115 was not initialized. Looking at the code, if usernames in like_by_users(self, usernames, amount=10, randomize=False, media=None) is empty, it is possible that the for loop will exit without having initialized the variable.

## Expected Behavior
variable is initialized

## Current Behavior
variable is not initialized.

## Possible Solution (optional)
initialize variable after line 964

## InstaPy configuration




Discussion:

Resolving patch:
diff --git a/instapy/instapy.py b/instapy/instapy.py
--- a/instapy/instapy.py
+++ b/instapy/instapy.py
@@ -961,6 +961,7 @@ def like_by_users(self, usernames, amount=10, randomize=False, media=None):
         if self.aborting:
             return self
 
+        liked_img = 0
         total_liked_img = 0
         already_liked = 0
         inap_img = 0


Test patch:
diff --git a/tests/test_instapy.py b/tests/test_instapy.py
new file mode 100644
--- /dev/null
+++ b/tests/test_instapy.py
@@ -0,0 +1,8 @@
+from instapy.instapy import InstaPy
+
+
+def test_like_by_users_with_no_usernames():
+    """test no inputs returns instance without errors"""
+    instapy = InstaPy(selenium_local_session=False)
+    res = instapy.like_by_users([])
+    assert isinstance(res, InstaPy)
Repository: InstaPy/InstaPy

Issue:
Minor bug:
in every (at list in interact by users):
self.liked_img += liked_img
it should be:
self.liked_img += total_liked_img



Discussion:

Resolving patch:
diff --git a/instapy/instapy.py b/instapy/instapy.py
--- a/instapy/instapy.py
+++ b/instapy/instapy.py
@@ -1299,7 +1299,7 @@ def interact_by_users(self,
         self.logger.info('Inappropriate: {}'.format(inap_img))
         self.logger.info('Commented: {}'.format(commented))
 
-        self.liked_img += liked_img
+        self.liked_img += total_liked_img
         self.already_liked += already_liked
         self.inap_img += inap_img
         self.commented += commented


Test patch:
diff --git a/tests/test_instapy.py b/tests/test_instapy.py
--- a/tests/test_instapy.py
+++ b/tests/test_instapy.py
@@ -1,10 +1,21 @@
-from unittest.mock import patch
+from unittest.mock import patch, PropertyMock
 
 import pytest
 
 from instapy.instapy import InstaPy, InstaPyError
 
 
+def test_interact_by_users_with_no_usernames():
+    """ensure no usernames input is handled"""
+    instapy = InstaPy(selenium_local_session=False)
+    res = instapy.interact_by_users(None)
+    assert isinstance(res, InstaPy)
+    assert instapy.liked_img == 0
+    assert instapy.already_liked == 0
+    assert instapy.inap_img == 0
+    assert instapy.commented == 0
+
+
 def test_like_by_users_with_no_usernames():
     """test no inputs returns instance without errors"""
     instapy = InstaPy(selenium_local_session=False)
@@ -16,6 +27,7 @@ def test_like_by_users_with_no_usernames():
 def test_set_use_clarifai_raises_on_windows(load_follow_restriction):
     """windows not supported"""
     instapy = InstaPy(selenium_local_session=False)
-    with patch('instapy.instapy.os'):
+    with patch('instapy.instapy.os') as os:
+        type(os).name = PropertyMock(return_value='nt')
         with pytest.raises(InstaPyError):
             instapy.set_use_clarifai()
Repository: InstaPy/InstaPy

Issue:
set_user_interact liking leads to "element not found, skipping this user" error
<!-- Is this a Feature Request ? Please, check out our Wiki first https://github.com/timgrossmann/InstaPy/wiki -->
## Expected Behavior
The script goes through liking by tag, interacting with/following each user whose photo it likes by tag. After following a user, the script will output:
Getting _____'s image list...
Interaction begin...
And then will like 3 photos for the user with which I am interacting (current settings are: session.set_user_interact(amount=3, randomize=True, percentage=100, media='Photo') )
## Current Behavior
Instead of liking the user's photos, the script outputs a "element not found, skipping this username" error, prints the Liked: 0, Already Liked: 0, Commented: 0, etc stats it usually prints when done with a username, and then moves on to liking the next photo by tag and following that user.
## Possible Solution (optional)
Is it possible that instagram recently updated something and now the 'like' button is no longer where the script expects? That's my best guess, but I'm new to this package and not familiar enough with the code to have tracked down where the error is arising from yet (especially without a traceback). 
## InstaPy configuration
I was originally running this script on windows with a version of InstaPy pulled on July 22nd and chrome. The interact feature worked perfectly then. I have since migrated to a rasppi and am running on firefox there, using an InstaPy version pulled on Aug 1st. I have not edited any of the functions since pulling from git, and followed the instructions to setup on a rasppi exactly, with no additional issues (beyond needing to create a db folder). 



Discussion:
If you resize the browser, the script is not able to find the buttons on the responsive layout. Let the browser at the size it was when you launched the script. 
I've the same issue on a RPi without GUI. I tried `headless_browser=True` and `headless_browser=False` neither of them worked.

Resolving patch:
diff --git a/instapy/util.py b/instapy/util.py
--- a/instapy/util.py
+++ b/instapy/util.py
@@ -685,7 +685,7 @@ def username_url_to_username(username_url):
 
 def get_number_of_posts(browser):
     """Get the number of posts from the profile screen"""
-    num_of_posts_txt = browser.find_element_by_xpath("//section/main/div/header/section/ul/li[1]/span/span").text
+    num_of_posts_txt = browser.find_element_by_xpath("//section/div[3]/div/header/section/ul/li[1]/span/span").text
     num_of_posts_txt = num_of_posts_txt.replace(" ", "")
     num_of_posts_txt = num_of_posts_txt.replace(",", "")
     num_of_posts = int(num_of_posts_txt)


Test patch:
Repository: InstaPy/InstaPy

Issue:
Last update ha a bug: local variable 'send_security_code_button' referenced before assignment
@timgrossmann @uluQulu @sionking 

Traceback (most recent call last):
  File "/root/InstaPy/5bcd8f2445908600133a63b6.py", line 18, in <module>
    session.login()
  File "/root/InstaPy/instapy/instapy.py", line 396, in login
    self.bypass_with_mobile):
  File "/root/InstaPy/instapy/login_util.py", line 268, in login_user
    bypass_suspicious_login(browser, bypass_with_mobile)
  File "/root/InstaPy/instapy/login_util.py", line 90, in bypass_suspicious_login
    .move_to_element(send_security_code_button)
UnboundLocalError: local variable 'send_security_code_button' referenced before assignment




Discussion:
the same thing
@imkimchi please fix this, it's from your last PR

Resolving patch:
diff --git a/instapy/login_util.py b/instapy/login_util.py
--- a/instapy/login_util.py
+++ b/instapy/login_util.py
@@ -75,9 +75,6 @@ def bypass_suspicious_login(browser, bypass_with_mobile):
         choice = browser.find_element_by_xpath(
             "//label[@for='choice_0']").text
 
-        send_security_code_button = browser.find_element_by_xpath(
-            "//button[text()='Send Security Code']")
-
         mobile_button = browser.find_element_by_xpath(
             "//label[@for='choice_0']")
 
@@ -88,6 +85,9 @@ def bypass_suspicious_login(browser, bypass_with_mobile):
         
         sleep(5)
 
+    send_security_code_button = browser.find_element_by_xpath(
+            "//button[text()='Send Security Code']")
+
     (ActionChains(browser)
         .move_to_element(send_security_code_button)
         .click()


Test patch:
Repository: InstaPy/InstaPy

Issue:
Instapy-chromedriver not supporting latest Chrome browser version
The Instapy-chrome driver only supports Chrome upto versions  71 and since the update, the whole program quits with the error of ensure chromedriver is installed at .../insta-py/chromedriver_linux64..


Discussion:
@breuerfelix is there a new binary you haven't included yet?   

Resolving patch:
diff --git a/instapy/__init__.py b/instapy/__init__.py
--- a/instapy/__init__.py
+++ b/instapy/__init__.py
@@ -8,5 +8,5 @@
 
 
 # __variables__ with double-quoted values will be available in setup.py
-__version__ = "0.2.1"
+__version__ = "0.2.2"
 


Test patch:
Repository: InstaPy/InstaPy

Issue:
bot doesn't comment : "UnboundLocalError: local variable 'commenting_approved' referenced before assignment"
## Expected Behavior
comment on post when activity is like_by_tags

## Current Behavior
bot likes photo but exits with the following error when trying to comment:

File "/Users/InstaPy-master/instapy/comment_util.py", line 411, in process_comments
    if not commenting_approved:
UnboundLocalError: local variable 'commenting_approved' referenced before assignment


## InstaPy configuration
session = InstaPy(username=insta_username,
                  password=insta_password,
                  headless_browser=False)

with smart_run(session)
  session.set_do_follow(True, percentage=100)
  session.set_do_comment(True, percentage=100)
  session.set_comments(['Nice!','Cool!']
  session.set_do_like(enabled=True, percentage=100)
  session.set_user_interact(amount=3, randomize=True, percentage=100)

  session.like_by_tags(["sunset"], amount=10,interact=True)



Discussion:
Having the same issue.
Same issue on latest release. 
I was having the same issue. I downgraded Instapy to 0.6.8 now its working..
I have the same issue. It was working great until I upgraded and now it crashes anytime I try to use comments. Works perfect without the comment scripts. I have tried all the other community comment scripts and nothing works. 
I solved the issue by downgrading as well. Just type this into cmd, `pip install instapy==0.6.8
` and make sure none of the comments have `@{}`. Having `@{}` is causing it to crash for some reason. It wasn't the case before. 
try to add:
`session.set_delimit_commenting(enabled=True, max_comments=10000, min_comments=0)`

it shouldn't affect your flow but will be a workaround
Line 431-433 of comment_util.py should go one tab to the right because they belong to the delimit_commenting option. 

Resolving patch:
diff --git a/instapy/comment_util.py b/instapy/comment_util.py
--- a/instapy/comment_util.py
+++ b/instapy/comment_util.py
@@ -428,9 +428,9 @@ def process_comments(
         (commenting_approved, disapproval_reason,) = verify_commenting(
             browser, max_comments, min_comments, logger,
         )
-    if not commenting_approved:
-        logger.info(disapproval_reason)
-        return False
+        if not commenting_approved:
+            logger.info(disapproval_reason)
+            return False
 
     (
         commenting_approved,


Test patch:
Repository: InstaPy/InstaPy

Issue:
Instead of tagged posts interact_by_users_tagged_posts interacts with user's posts
<!-- Did you know that we have a Discord channel ? Join us: https://discord.gg/FDETsht -->
<!-- Is this a Feature Request ? Please, check out our Wiki first https://github.com/timgrossmann/InstaPy/wiki -->
InstaPy starts interacting with user's posts instead of interacting with tagged posts of the user when using `interact_by_users_tagged_posts` function.
## Expected Behavior
InstaPy should interact with user's tagged posts.
## Current Behavior
InstaPy interacts with user's posts.
## Possible Solution (optional)
I looked into the InstaPy source code and found the call to `get_following_status` navigates the browser to user's ig homepage immediately after it was set to user's tagged page. Therefore moving the call to `get_following_status` above `web_address_navigator` call inside `get_links_for_username` fixes the issue.
## InstaPy configuration
```python
from instapy import InstaPy

session = InstaPy(username=_username,
                  password=_password)
session.login()
session.set_do_follow(enabled=False, percentage=50)
# session.set_comments(["Cool", "Super!"])
# session.set_do_comment(enabled=True, percentage=80)
session.set_do_like(True, percentage=70)
session.interact_by_users_tagged_posts(
    ['anotherusername'], amount=10, randomize=True)
session.end()
```




Discussion:

Resolving patch:
diff --git a/instapy/like_util.py b/instapy/like_util.py
--- a/instapy/like_util.py
+++ b/instapy/like_util.py
@@ -448,6 +448,11 @@ def get_links_for_username(
     if taggedImages:
         user_link = user_link + "tagged/"
 
+    # if private user, we can get links only if we following
+    following_status, _ = get_following_status(
+        browser, "profile", username, person, None, logger, logfolder
+    )
+
     # Check URL of the webpage, if it already is user's profile page,
     # then do not navigate to it again
     web_address_navigator(browser, user_link)
@@ -459,11 +464,6 @@ def get_links_for_username(
         )
         return False
 
-    # if private user, we can get links only if we following
-    following_status, _ = get_following_status(
-        browser, "profile", username, person, None, logger, logfolder
-    )
-
     # if following_status is None:
     #    browser.wait_for_valid_connection(browser, username, logger)
 


Test patch:
Repository: InstaPy/InstaPy

Issue:
Wrong behaviour while setting 'skip_bio_keyword'
<!-- Did you know that we have a Discord channel ? Join us: https://discord.gg/FDETsht -->
<!-- Is this a Feature Request ? Please, check out our Wiki first https://github.com/timgrossmann/InstaPy/wiki -->
Function 'evaluate_mandatory_words' fails when passing an empty list. While setting 'skip_bio_keyword' to 'set_skip_users', 'evaluate_mandatory_words' gets called without a list and returns false, wrongly skipping users.

## Expected Behavior
The expected behavior should not 'evaluate_mandatory_words' if not mandatory words were setted.

## Current Behavior
While setting 'skip_bio_keyword' to 'set_skip_users', 'evaluate_mandatory_words' gets called without a list and returns false, wrongly skipping users.

## Possible Solution (optional)
Two alternatives:

1. Validate 'mandatory_bio_keywords' before calling 'evaluate_mandatory_words'
2. Change the function logic to return True when evaluating empty lists




Discussion:

Resolving patch:
diff --git a/instapy/util.py b/instapy/util.py
--- a/instapy/util.py
+++ b/instapy/util.py
@@ -449,7 +449,7 @@ def validate_username(
                     ),
                 )
         # the mandatory keywords applies to the username as well as the bio text
-        if not evaluate_mandatory_words(
+        if mandatory_bio_keywords and not evaluate_mandatory_words(
             username + " " + profile_bio, mandatory_bio_keywords
         ):
             return False, "Mandatory bio keywords not found"


Test patch:
Repository: InstaPy/InstaPy

Issue:
Cannot get followers of owner account if it's private
## Expected Behavior

Get followers/followings of owner profiles.

## Current Behavior

Logs "this account is private".

## Possible Solution (optional)

Modify relationship_tools.py to check if `not username == self_username`.

Cannot get followers of owner account if it's private
## Expected Behavior

Get followers/followings of owner profiles.

## Current Behavior

Logs "this account is private".

## Possible Solution (optional)

Modify relationship_tools.py to check if `not username == self_username`.



Discussion:

Resolving patch:
diff --git a/instapy/__init__.py b/instapy/__init__.py
--- a/instapy/__init__.py
+++ b/instapy/__init__.py
@@ -1,7 +1,7 @@
 # flake8: noqa
 
 # __variables__ with double-quoted values will be available in setup.py
-__version__ = "0.6.14"
+__version__ = "0.6.15"
 
 from .instapy import InstaPy
 from .util import smart_run
diff --git a/instapy/relationship_tools.py b/instapy/relationship_tools.py
--- a/instapy/relationship_tools.py
+++ b/instapy/relationship_tools.py
@@ -79,7 +79,7 @@ def get_followers(
 
     is_private = is_private_profile(browser, logger, following_status == "Following")
 
-    if (
+    if not username == self_username and (
         is_private is None
         or (is_private is True and following_status not in ["Following", True])
         or (following_status == "Blocked")
@@ -372,7 +372,7 @@ def get_following(
     )
 
     is_private = is_private_profile(browser, logger, following_status == "Following")
-    if (
+    if not username == self_username and (
         is_private is None
         or (is_private is True and following_status not in ["Following", True])
         or (following_status == "Blocked")


Test patch:
Repository: InstaPy/InstaPy

Issue:
ImportError: cannot import name 'UNICODE_EMOJI' from 'emoji.unicode_codes'
<!-- Did you know that we have a Discord channel ? Join us: https://discord.gg/FDETsht -->
<!-- Is this a Feature Request ? Please, check out our Wiki first https://github.com/timgrossmann/InstaPy/wiki -->
## Expected Behavior

## Current Behavior
on Running a simple Script like
from instapy import InstaPy
InstaPy(username=<username>, password=<password>).login()
getting  ImportError: cannot import name 'UNICODE_EMOJI' from 'emoji.unicode_codes'
## Possible Solution (optional)

## InstaPy configuration





Discussion:
I'm having this same issue and it looks like it's related to the lastest version of the `emoji` library. As a temporal solution I have installed this library by manually specifying version `<2.0.0`, and now it works.
> <2.0.0

https://github.com/InstaPy/InstaPy/issues/6615  How do you not get the error here? instapy should not be running right now how did you solve this problem @mavilar 
Solution:
pip uninstall emoji
pip install emoji==1.7
@metapodcod, I didn't solve that issue you're referring to. I was only talking about this one: the `ImportError` exception.

Resolving patch:
diff --git a/instapy/util.py b/instapy/util.py
--- a/instapy/util.py
+++ b/instapy/util.py
@@ -24,7 +24,7 @@
 import emoji
 import regex
 from bs4 import BeautifulSoup
-from emoji.unicode_codes import UNICODE_EMOJI
+from emoji.unicode_codes import EMOJI_DATA
 
 # import exceptions
 from selenium.common.exceptions import (
@@ -2117,7 +2117,7 @@ def deform_emojis(text):
     emojis_in_text = []
 
     for word in data:
-        if any(char in UNICODE_EMOJI for char in word):
+        if any(char in EMOJI_DATA for char in word):
             word_emoji = emoji.demojize(word).replace(":", "").replace("_", " ")
             if word_emoji not in emojis_in_text:  # do not add an emoji if
                 # already exists in text


Test patch: