internlm/SWE-Fixer-Train-110K huggingface dataset:
Repository: python-telegram-bot/python-telegram-bot

Issue:
Sommer/Winter time with Jobs
### Steps to reproduce
1. Live in Europe

2. Run a weekly job with something like

```
first = datetime(foo)
job_queue.run_repeating(job,
                        interval = timedelta(7),
                        first = first)
```


### Expected behaviour
Job runs once a week at the specified time

### Actual behaviour
The clock change from winter to sommer time is not handled correctly and the job runs an hour early/late.

### Proposal:
Since the problem occurs only twice a year and is easily fixed by restarting the bot **and** this nonsence of constantly changing clocks hopefully [ends by 2021](https://www.bbc.com/news/world-europe-47704345), I guess this can be "fixed" by documenting it in the docstring of ``JobQueue.run_daily()`` and ``JobQueue.run_repeating()``.
If I get a LGTM for this "solution", I'll open a PR for it :)


Discussion:

Resolving patch:
diff --git a/telegram/ext/jobqueue.py b/telegram/ext/jobqueue.py
--- a/telegram/ext/jobqueue.py
+++ b/telegram/ext/jobqueue.py
@@ -172,6 +172,11 @@ def run_repeating(self, callback, interval, first=None, context=None, name=None)
             :class:`telegram.ext.Job`: The new ``Job`` instance that has been added to the job
             queue.
 
+        Notes:
+             `interval` is always respected "as-is". That means that if DST changes during that
+             interval, the job might not run at the time one would expect. It is always recommended
+             to pin servers to UTC time, then time related behaviour can always be expected.
+
         """
         job = Job(callback,
                   interval=interval,
@@ -202,6 +207,11 @@ def run_daily(self, callback, time, days=Days.EVERY_DAY, context=None, name=None
             :class:`telegram.ext.Job`: The new ``Job`` instance that has been added to the job
             queue.
 
+        Notes:
+             Daily is just an alias for "24 Hours". That means that if DST changes during that
+             interval, the job might not run at the time one would expect. It is always recommended
+             to pin servers to UTC time, then time related behaviour can always be expected.
+
         """
         job = Job(callback,
                   interval=datetime.timedelta(days=1),


Test patch:
Repository: python-telegram-bot/python-telegram-bot

Issue:
wrong indentation in parse*entity methods
Here: https://github.com/python-telegram-bot/python-telegram-bot/blob/5c45e469d5837b244f9cd589ec787036e5be9970/telegram/message.py#L869

Return line must be inside else branch

Both `parse_entity` and `parse_caption_entity` methods should be fixed.


Discussion:
Hi,

Thanks for notifying us.
Although the end result and workings are the same, it would be more visually appropriate to fix this.

Whould you be interested in making a PR to `fix` the problem?

Resolving patch:
diff --git a/telegram/message.py b/telegram/message.py
--- a/telegram/message.py
+++ b/telegram/message.py
@@ -841,7 +841,7 @@ def parse_entity(self, entity):
             entity_text = self.text.encode('utf-16-le')
             entity_text = entity_text[entity.offset * 2:(entity.offset + entity.length) * 2]
 
-        return entity_text.decode('utf-16-le')
+            return entity_text.decode('utf-16-le')
 
     def parse_caption_entity(self, entity):
         """Returns the text from a given :class:`telegram.MessageEntity`.
@@ -866,7 +866,7 @@ def parse_caption_entity(self, entity):
             entity_text = self.caption.encode('utf-16-le')
             entity_text = entity_text[entity.offset * 2:(entity.offset + entity.length) * 2]
 
-        return entity_text.decode('utf-16-le')
+            return entity_text.decode('utf-16-le')
 
     def parse_entities(self, types=None):
         """


Test patch:
Repository: python-telegram-bot/python-telegram-bot

Issue:
Error KeyError: 'age' - case insensitive in persistentconversationbot.py
There is an error in this:

https://github.com/python-telegram-bot/python-telegram-bot/blob/2cde878d1e5e0bb552aaf41d5ab5df695ec4addb/examples/persistentconversationbot.py#L69

we extract the category using the function "lower", despite the fact that we added without this function:
https://github.com/python-telegram-bot/python-telegram-bot/blob/2cde878d1e5e0bb552aaf41d5ab5df695ec4addb/examples/persistentconversationbot.py#L86-L87
example error:KeyError: 'age'


Discussion:

Resolving patch:
diff --git a/examples/persistentconversationbot.py b/examples/persistentconversationbot.py
--- a/examples/persistentconversationbot.py
+++ b/examples/persistentconversationbot.py
@@ -62,13 +62,13 @@ def start(update, context):
 
 
 def regular_choice(update, context):
-    text = update.message.text
+    text = update.message.text.lower()
     context.user_data['choice'] = text
     if context.user_data.get(text):
         reply_text = 'Your {}, I already know the following ' \
-                     'about that: {}'.format(text.lower(), context.user_data[text.lower()])
+                     'about that: {}'.format(text, context.user_data[text])
     else:
-        reply_text = 'Your {}? Yes, I would love to hear about that!'.format(text.lower())
+        reply_text = 'Your {}? Yes, I would love to hear about that!'.format(text)
     update.message.reply_text(reply_text)
 
     return TYPING_REPLY


Test patch:
Repository: python-telegram-bot/python-telegram-bot

Issue:
Use UTC dates
https://github.com/python-telegram-bot/python-telegram-bot/blob/439790375ed8ed493c43e464aa8e2b60a77939db/telegram/utils/helpers.py#L78-L90

Should probably be using `tz=timezone.utc`. Python's `datetime` isn't the best, and `fromtimestamp` by default sets no `tz` information, which uses the local time, which in turn is generally a bad idea.


Discussion:
@Lonami I guess we all agree it should be UTC, but it is a breaking change. Maybe we can get it in before official v12 release?
I agree, since there's a breaking change spree for v12, might as well add this in

Resolving patch:
diff --git a/telegram/utils/helpers.py b/telegram/utils/helpers.py
--- a/telegram/utils/helpers.py
+++ b/telegram/utils/helpers.py
@@ -87,7 +87,7 @@ def from_timestamp(unixtime):
     if not unixtime:
         return None
 
-    return datetime.fromtimestamp(unixtime)
+    return datetime.utcfromtimestamp(unixtime)
 
 
 def mention_html(user_id, name):


Test patch:
Repository: python-telegram-bot/python-telegram-bot

Issue:
Forbid setting user and chat data attributes
Inevitably users will attempt to do `context.user_data = {'my': 'dict'}` or `context.chat_data = whatever`. This will lead to confusing behaviour.

I propose making those fields properties without a setter, which will more helpfully error. Depending on how far we want to go, we can also suggest the user to use `update(other_dict)` if they attempt to set the field.

See https://t.me/pythontelegrambotgroup/222138 onwards.


Discussion:

Resolving patch:
diff --git a/telegram/ext/callbackcontext.py b/telegram/ext/callbackcontext.py
--- a/telegram/ext/callbackcontext.py
+++ b/telegram/ext/callbackcontext.py
@@ -73,13 +73,31 @@ def __init__(self, dispatcher):
             raise ValueError('CallbackContext should not be used with a non context aware '
                              'dispatcher!')
         self._dispatcher = dispatcher
-        self.chat_data = None
-        self.user_data = None
+        self._chat_data = None
+        self._user_data = None
         self.args = None
         self.matches = None
         self.error = None
         self.job = None
 
+    @property
+    def chat_data(self):
+        return self._chat_data
+
+    @chat_data.setter
+    def chat_data(self, value):
+        raise AttributeError("You can not assign a new value to chat_data, see "
+                             "https://git.io/fjxKe")
+
+    @property
+    def user_data(self):
+        return self._user_data
+
+    @user_data.setter
+    def user_data(self, value):
+        raise AttributeError("You can not assign a new value to user_data, see "
+                             "https://git.io/fjxKe")
+
     @classmethod
     def from_error(cls, update, error, dispatcher):
         self = cls.from_update(update, dispatcher)
@@ -94,9 +112,9 @@ def from_update(cls, update, dispatcher):
             user = update.effective_user
 
             if chat:
-                self.chat_data = dispatcher.chat_data[chat.id]
+                self._chat_data = dispatcher.chat_data[chat.id]
             if user:
-                self.user_data = dispatcher.user_data[user.id]
+                self._user_data = dispatcher.user_data[user.id]
         return self
 
     @classmethod


Test patch:
diff --git a/tests/test_callbackcontext.py b/tests/test_callbackcontext.py
--- a/tests/test_callbackcontext.py
+++ b/tests/test_callbackcontext.py
@@ -105,3 +105,15 @@ def test_match(self, cdp):
         callback_context.matches = ['test', 'blah']
 
         assert callback_context.match == 'test'
+
+    def test_data_assignment(self, cdp):
+        update = Update(0, message=Message(0, User(1, 'user', False), None, Chat(1, 'chat')))
+
+        callback_context = CallbackContext.from_update(update, cdp)
+
+        with pytest.raises(AttributeError):
+            callback_context.chat_data = {"test": 123}
+        with pytest.raises(AttributeError):
+            callback_context.user_data = {}
+        with pytest.raises(AttributeError):
+            callback_context.chat_data = "test"
Repository: python-telegram-bot/python-telegram-bot

Issue:
Bot dict return wrong value for first_name
<!--
Thanks for reporting issues of python-telegram-bot!

Use this template to notify us if you found a bug, or if you want to request a new feature.
If you're looking for help with programming your bot using our library, feel free to ask your
questions in out telegram group at: https://t.me/pythontelegrambotgroup

To make it easier for us to help you please enter detailed information below.

Please note, we only support the latest version of python-telegram-bot and
master branch. Please make sure to upgrade & recreate the issue on the latest
version prior to opening an issue.
-->
### Steps to reproduce
1. ``from telegram import Bot``

2. ``bot: Bot = Bot(token='708626524:abc-token')``

3. ``print(bot.to_dict())``

### Expected behaviour
``{'id': 708626524, 'username': 'for_testx_bot', 'first_name': 'For Test'}``

### Actual behaviour
``{'id': 708626524, 'username': 'for_testx_bot', 'first_name': 'for_testx_bot'}``

### Configuration
Microsoft Windows [Version 10.0.16299.15]
(c) 2017 Microsoft Corporation. All rights reserved.

(venv) E:\Working\Running_Projects\abc>python -m telegram
python-telegram-bot 12.1.1
certifi 2019.09.11
future 0.17.1
Python 3.7.3 (v3.7.3:ef4ec6ed12, Mar 25 2019, 21:26:53) [MSC v.1916 32 bit (Intel)]


### More Info
![bot_issue](https://user-images.githubusercontent.com/55732633/65488023-f31bf800-dec9-11e9-8d7a-82befc3e14f9.PNG)




Discussion:
I would like to try to work on this for hacktoberfest.
way to go :)

Resolving patch:
diff --git a/telegram/bot.py b/telegram/bot.py
--- a/telegram/bot.py
+++ b/telegram/bot.py
@@ -3439,7 +3439,7 @@ def stop_poll(self,
         return Poll.de_json(result, self)
 
     def to_dict(self):
-        data = {'id': self.id, 'username': self.username, 'first_name': self.username}
+        data = {'id': self.id, 'username': self.username, 'first_name': self.first_name}
 
         if self.last_name:
             data['last_name'] = self.last_name


Test patch:
Repository: python-telegram-bot/python-telegram-bot

Issue:
Fix the ConversationHandler docstring as it still states inability to work with group chats and channels. 
As Eldin said me yesterday, this part of the CH docs is no longer true: 

`Note that neither posts in Telegram Channels, nor group interactions with multiple users are managed by instances of this class.`

I didn't check if that's true, so I don't exactly know whether ConversationHandlers can really work in group chats or channels. But if yes, docstrings should be updated on this case and any additional notes on using CH in such cases. 


Discussion:

Resolving patch:
diff --git a/telegram/ext/conversationhandler.py b/telegram/ext/conversationhandler.py
--- a/telegram/ext/conversationhandler.py
+++ b/telegram/ext/conversationhandler.py
@@ -38,8 +38,7 @@ def __init__(self, conversation_key, update, dispatcher):
 class ConversationHandler(Handler):
     """
     A handler to hold a conversation with a single user by managing four collections of other
-    handlers. Note that neither posts in Telegram Channels, nor group interactions with multiple
-    users are managed by instances of this class.
+    handlers.
 
     The first collection, a ``list`` named :attr:`entry_points`, is used to initiate the
     conversation, for example with a :class:`telegram.ext.CommandHandler` or
diff --git a/telegram/ext/jobqueue.py b/telegram/ext/jobqueue.py
--- a/telegram/ext/jobqueue.py
+++ b/telegram/ext/jobqueue.py
@@ -42,7 +42,8 @@ class JobQueue(object):
     Attributes:
         _queue (:obj:`PriorityQueue`): The queue that holds the Jobs.
         bot (:class:`telegram.Bot`): The bot instance that should be passed to the jobs.
-            DEPRECATED: Use set_dispatcher instead.
+            DEPRECATED: Use :attr:`set_dispatcher` instead.
+
     """
 
     def __init__(self, bot=None):
@@ -68,6 +69,13 @@ def __init__(self):
         self._running = False
 
     def set_dispatcher(self, dispatcher):
+        """Set the dispatcher to be used by this JobQueue. Use this instead of passing a
+        :class:`telegram.Bot` to the JobQueue, which is deprecated.
+
+        Args:
+            dispatcher (:class:`telegram.ext.Dispatcher`): The dispatcher.
+
+        """
         self._dispatcher = dispatcher
 
     def _put(self, job, next_t=None, last_t=None):


Test patch:
Repository: python-telegram-bot/python-telegram-bot

Issue:
[BUG] Message.forward is missing *args and **kwargs



Discussion:

Resolving patch:
diff --git a/telegram/message.py b/telegram/message.py
--- a/telegram/message.py
+++ b/telegram/message.py
@@ -742,13 +742,14 @@ def reply_poll(self, *args, **kwargs):
         self._quote(kwargs)
         return self.bot.send_poll(self.chat_id, *args, **kwargs)
 
-    def forward(self, chat_id, disable_notification=False):
+    def forward(self, chat_id, *args, **kwargs):
         """Shortcut for::
 
             bot.forward_message(chat_id=chat_id,
                                 from_chat_id=update.message.chat_id,
-                                disable_notification=disable_notification,
-                                message_id=update.message.message_id)
+                                message_id=update.message.message_id,
+                                *args,
+                                **kwargs)
 
         Returns:
             :class:`telegram.Message`: On success, instance representing the message forwarded.
@@ -757,8 +758,9 @@ def forward(self, chat_id, disable_notification=False):
         return self.bot.forward_message(
             chat_id=chat_id,
             from_chat_id=self.chat_id,
-            disable_notification=disable_notification,
-            message_id=self.message_id)
+            message_id=self.message_id,
+            *args,
+            **kwargs)
 
     def edit_text(self, *args, **kwargs):
         """Shortcut for::


Test patch:
Repository: python-telegram-bot/python-telegram-bot

Issue:
[FEATURE] Add telegram.ext.filters.Filters.poll for native poll messages
#### Is your feature request related to a problem? Please describe.
Since version 4.2, Bot API added poll message support, and PTB has also followed up with that in the API. However, as of PTB 12.2.0, ther is no support of poll messages in built in filters like other message types.

#### Describe the solution you'd like
Add a filter `telegram.ext.filters.Filters.poll`, namely:

```python
    class _Poll(BaseFilter):
        name = 'Filters.poll'

        def filter(self, message):
            return bool(message.poll)

    poll = _Poll()
    """Messages that contain :class:`telegram.Poll`."""
```

#### Describe alternatives you've considered
I’m having this filter in my own code so far.

#### Additional context
None



Discussion:
@blueset This would make a great addition. Could you make a PR according to our contributers guide?

Resolving patch:
diff --git a/telegram/ext/filters.py b/telegram/ext/filters.py
--- a/telegram/ext/filters.py
+++ b/telegram/ext/filters.py
@@ -956,6 +956,15 @@ def filter(self, message):
     passport_data = _PassportData()
     """Messages that contain a :class:`telegram.PassportData`"""
 
+    class _Poll(BaseFilter):
+        name = 'Filters.poll'
+
+        def filter(self, message):
+            return bool(message.poll)
+
+    poll = _Poll()
+    """Messages that contain a :class:`telegram.Poll`."""
+
     class language(BaseFilter):
         """Filters messages to only allow those which are from users with a certain language code.
 


Test patch:
diff --git a/tests/test_filters.py b/tests/test_filters.py
--- a/tests/test_filters.py
+++ b/tests/test_filters.py
@@ -599,6 +599,11 @@ def test_filters_passport_data(self, update):
         update.message.passport_data = 'test'
         assert Filters.passport_data(update)
 
+    def test_filters_poll(self, update):
+        assert not Filters.poll(update)
+        update.message.poll = 'test'
+        assert Filters.poll(update)
+
     def test_language_filter_single(self, update):
         update.message.from_user.language_code = 'en_US'
         assert (Filters.language('en_US'))(update)
Repository: python-telegram-bot/python-telegram-bot

Issue:
Fix Filters.text (docs)
As a legacy `filters.text` has a check that the message does not start with `/`. In order to not conflict with `Commandhandler`
https://github.com/python-telegram-bot/python-telegram-bot/blob/master/telegram/ext/filters.py#L246
This is no longer needed because Commandhandler now uses entities to check for a command. In any case this bahavior is not documented.
A user can well be confused by `MessageHandler(Filters.text, callback)` will not respond to a message that starts with a `/`. At least the docs should be fixed, but I prefer it to remove the check and just pass any message with text to the user.


Discussion:

Resolving patch:
diff --git a/telegram/ext/filters.py b/telegram/ext/filters.py
--- a/telegram/ext/filters.py
+++ b/telegram/ext/filters.py
@@ -243,7 +243,7 @@ def __init__(self, iterable):
                 self.name = 'Filters.text({})'.format(iterable)
 
             def filter(self, message):
-                if message.text and not message.text.startswith('/'):
+                if message.text:
                     return message.text in self.iterable
                 return False
 
@@ -257,7 +257,7 @@ def __call__(self, update):
                 return self._TextIterable(update)
 
         def filter(self, message):
-            return bool(message.text and not message.text.startswith('/'))
+            return bool(message.text)
 
     text = _Text()
     """Text Messages. If an iterable of strings is passed, it filters messages to only allow those


Test patch:
diff --git a/tests/test_filters.py b/tests/test_filters.py
--- a/tests/test_filters.py
+++ b/tests/test_filters.py
@@ -45,11 +45,11 @@ def test_filters_text(self, update):
         update.message.text = 'test'
         assert (Filters.text)(update)
         update.message.text = '/test'
-        assert not (Filters.text)(update)
+        assert (Filters.text)(update)
 
     def test_filters_text_iterable(self, update):
-        update.message.text = 'test'
-        assert Filters.text({'test', 'test1'})(update)
+        update.message.text = '/test'
+        assert Filters.text({'/test', 'test1'})(update)
         assert not Filters.text(['test1', 'test2'])(update)
 
     def test_filters_caption(self, update):
@@ -625,7 +625,7 @@ def test_and_filters(self, update):
         update.message.forward_date = datetime.datetime.utcnow()
         assert (Filters.text & Filters.forwarded)(update)
         update.message.text = '/test'
-        assert not (Filters.text & Filters.forwarded)(update)
+        assert (Filters.text & Filters.forwarded)(update)
         update.message.text = 'test'
         update.message.forward_date = None
         assert not (Filters.text & Filters.forwarded)(update)
Repository: python-telegram-bot/python-telegram-bot

Issue:
[BUG] duplicate assignment of job_queue in dispatcher class
Hi I was going through dispatcher.py, I found job_queue class object initialized twice at line 115 and 141,which seems not helping anywhere.
Should I remove it and raise PR?

Thanks


Discussion:

Resolving patch:
diff --git a/telegram/ext/dispatcher.py b/telegram/ext/dispatcher.py
--- a/telegram/ext/dispatcher.py
+++ b/telegram/ext/dispatcher.py
@@ -138,8 +138,6 @@ def __init__(self,
         else:
             self.persistence = None
 
-        self.job_queue = job_queue
-
         self.handlers = {}
         """Dict[:obj:`int`, List[:class:`telegram.ext.Handler`]]: Holds the handlers per group."""
         self.groups = []


Test patch:
Repository: python-telegram-bot/python-telegram-bot

Issue:
Problems with run_repeating
Hi! 
After update to version 12.3, this code start to work wrong. The first command that sends is get_links_state, than, after one second, sends get_alarms_state. After rollback to version 12.2.0 all started to work normally. Code remains unchanged. 
Sorry for mistakes, English isn`t my mother tongue)
Code: 
```
    updater = Updater("TOKEN", use_context=True)
    queue_updater = updater.job_queue

    queue_updater.run_repeating(get_alarms_state, interval=60, first=0)
    queue_updater.run_repeating(get_links_state, interval=70, first=20)

```


Discussion:
I am pretty sure you haven't updated to 13.0, given that this version isn't existing. And what exactly went wrong after the update?
> I am pretty sure you haven't updated to 13.0, given that this version isn't existing. And what exactly went wrong after the update?

The first comand didn't started at 0, it started after 60 seconds 
Hi @Suhoy571. I ran the example and can't reproduce the described behaviour. Can you set logging level to debug and post the full log (make sure to remove personal information such as the bot token)?
Mh, stupid me didn't run the example on v12.3 :man_facepalming: Can reproduce now, will have a look

Resolving patch:
diff --git a/telegram/ext/jobqueue.py b/telegram/ext/jobqueue.py
--- a/telegram/ext/jobqueue.py
+++ b/telegram/ext/jobqueue.py
@@ -95,7 +95,8 @@ def _put(self, job, time_spec=None, previous_t=None):
 
         """
         # get time at which to run:
-        time_spec = time_spec or job.interval
+        if time_spec is None:
+            time_spec = job.interval
         if time_spec is None:
             raise ValueError("no time specification given for scheduling non-repeating job")
         next_t = to_float_timestamp(time_spec, reference_timestamp=previous_t)


Test patch:
diff --git a/tests/test_jobqueue.py b/tests/test_jobqueue.py
--- a/tests/test_jobqueue.py
+++ b/tests/test_jobqueue.py
@@ -119,6 +119,11 @@ def test_run_repeating_first(self, job_queue):
         sleep(0.07)
         assert self.result == 1
 
+    def test_run_repeating_first_immediate(self, job_queue):
+        job_queue.run_repeating(self.job_run_once, 0.1, first=0)
+        sleep(0.05)
+        assert self.result == 1
+
     def test_run_repeating_first_timezone(self, job_queue, timezone):
         """Test correct scheduling of job when passing a timezone-aware datetime as ``first``"""
         first = (dtm.datetime.utcnow() + timezone.utcoffset(None)).replace(tzinfo=timezone)