# Buggy code
def _output(obj, output, config, **extra):
    # logging.info("[<] " + str(datetime.now()) + ':: output+_output')
    if config.Lowercase:
        if isinstance(obj, str):
            obj = obj.lower()
        elif str(type(obj)) == "<class 'twint.user.user'>":
            pass
        else:
            obj.username = obj.username.lower()
            for i in range(len(obj.mentions)):
                obj.mentions[i] = obj.mentions[i]["screen_name"].lower()
            for i in range(len(obj.hashtags)):
                obj.hashtags[i] = obj.hashtags[i].lower()
    if config.Output != None:
        if config.Store_csv:
            try:
                write.Csv(obj, config)
            except Exception as e:
                print(str(e) + " [x] output._output")
        elif config.Store_json:
            write.Json(obj, config)
        else:
            write.Text(output, config.Output)

    if config.Pandas and config.User_full:
        panda.update(obj, config)
    if extra.get("follow_list"):
        follow_object.username = config.Username
        follow_object.action = (
            config.Following * "following" + config.Followers * "followers"
        )
        follow_object.users = _follow_list
        panda.update(follow_object, config.Essid)
    if config.Elasticsearch:
        print("", end=".", flush=True)
    else:
        if config.Store_object:
            tweets_object.append(obj)
        else:
            if not config.Hide_output:
                try:
                    print(output)
                except UnicodeEncodeError:
                    print("unicode error [x] output._output")


# Traceback (AttributeError)
Python 3.6.4 |Anaconda, Inc.| (default, Jan 16 2018, 12:04:33)
[GCC 4.2.1 Compatible Clang 4.0.1 (tags/RELEASE_401/final)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
import twint
c = twint.Config()
query= 'bar'
c.Search = query
c.Pandas = True
twint.run.Search(c)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File ".../lib/python3.6/site-packages/twint/run.py", line 201, in Search
run(config)
File ".../lib/python3.6/site-packages/twint/run.py", line 153, in run
get_event_loop().run_until_complete(Twint(config).main())
File ".../lib/python3.6/asyncio/base_events.py", line 467, in run_until_complete
return future.result()
File ".../lib/python3.6/site-packages/twint/run.py", line 140, in main
await self.tweets()
File ".../lib/python3.6/site-packages/twint/run.py", line 103, in tweets
await output.Tweets(tweet, "", self.config, self.conn)
File ".../lib/python3.6/site-packages/twint/output.py", line 161, in Tweets
await checkData(tweets, location, config, conn)
File ".../lib/python3.6/site-packages/twint/output.py", line 142, in checkData
panda.update(tweet, config)
File ".../lib/python3.6/site-packages/twint/storage/panda.py", line 61, in update
"user_rt": object.user_rt,
AttributeError: 'tweet' object has no attribute 'user_rt'


# Fixed code
def _output(obj, output, config, **extra):
    # logging.info("[<] " + str(datetime.now()) + ':: output+_output')
    if config.Lowercase:
        if isinstance(obj, str):
            obj = obj.lower()
        elif str(type(obj)) == "<class 'twint.user.user'>":
            pass
        else:
            obj.username = obj.username.lower()
            for i in range(len(obj.mentions)):
                obj.mentions[i] = obj.mentions[i]["screen_name"].lower()
            for i in range(len(obj.hashtags)):
                obj.hashtags[i] = obj.hashtags[i].lower()
    if config.Output != None:
        if config.Store_csv:
            try:
                write.Csv(obj, config)
            except Exception as e:
                print(str(e) + " [x] output._output")
        elif config.Store_json:
            write.Json(obj, config)
        else:
            write.Text(output, config.Output)

    if config.Pandas and obj.type == "user":
        panda.update(obj, config)
    if extra.get("follow_list"):
        follow_object.username = config.Username
        follow_object.action = (
            config.Following * "following" + config.Followers * "followers"
        )
        follow_object.users = _follow_list
        panda.update(follow_object, config.Essid)
    if config.Elasticsearch:
        print("", end=".", flush=True)
    else:
        if config.Store_object:
            tweets_object.append(obj)
        else:
            if not config.Hide_output:
                try:
                    print(output)
                except UnicodeEncodeError:
                    print("unicode error [x] output._output")