Skip to content

Commit 5971cb3

Browse files
committed
fix merge conflict snakes with master
2 parents 5e5510d + 6e5302c commit 5971cb3

17 files changed

+125
-229
lines changed

CHANGES.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
**2016-04-29**
2+
3+
*Released 4.0.2*
4+
5+
- Bugfixes
6+
- ``KeyboardReplyMarkup`` now accepts ``str`` again
7+
18
**2016-04-27**
29

310
*Released 4.0.1*

docs/source/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@
6060
# The short X.Y version.
6161
version = '4.0'
6262
# The full version, including alpha/beta/rc tags.
63-
release = '4.0.1'
63+
release = '4.0.2'
6464

6565
# The language for content autogenerated by Sphinx. Refer to documentation
6666
# for a list of supported languages.

examples/timerbot.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ def main():
7575
# on different commands - answer in Telegram
7676
dp.add_handler(CommandHandler("start", start))
7777
dp.add_handler(CommandHandler("help", start))
78-
dp.add_handler(CommandHandler("set", set))
78+
dp.add_handler(CommandHandler("set", set, pass_args=True))
7979

8080
# log all errors
8181
dp.add_error_handler(error)

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ def requirements():
2626

2727
setup(
2828
name='python-telegram-bot',
29-
version='4.0.1',
29+
version='4.0.2',
3030
author='Leandro Toledo',
3131
author_email='devs@python-telegram-bot.org',
3232
license='LGPLv3',

telegram/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@
8383

8484

8585
__author__ = 'devs@python-telegram-bot.org'
86-
__version__ = '4.0.1'
86+
__version__ = '4.0.2'
8787
__all__ = ['Audio',
8888
'Bot',
8989
'Chat',

telegram/bot.py

Lines changed: 35 additions & 116 deletions
Large diffs are not rendered by default.

telegram/inputfile.py

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,17 +20,19 @@
2020

2121
"""This module contains a object that represents a Telegram InputFile."""
2222

23-
import mimetypes
24-
import os
25-
import sys
26-
import imghdr
27-
2823
try:
24+
# python 3
2925
from email.generator import _make_boundary as choose_boundary
30-
from urllib.request import urlopen
3126
except ImportError:
27+
# python 2
3228
from mimetools import choose_boundary
33-
from urllib2 import urlopen
29+
30+
import imghdr
31+
import mimetypes
32+
import os
33+
import sys
34+
35+
from future.moves.urllib.request import urlopen
3436

3537
from telegram import TelegramError
3638

@@ -81,6 +83,8 @@ def __init__(self,
8183
if 'filename' in data:
8284
self.filename = self.data.pop('filename')
8385
elif hasattr(self.input_file, 'name'):
86+
# on py2.7, pylint fails to understand this properly
87+
# pylint: disable=E1101
8488
self.filename = os.path.basename(self.input_file.name)
8589
elif from_url:
8690
self.filename = os.path.basename(self.input_file.url) \

telegram/replykeyboardmarkup.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,12 @@ def to_dict(self):
7373
data = super(ReplyKeyboardMarkup, self).to_dict()
7474

7575
data['keyboard'] = []
76-
for keyboard in self.keyboard:
77-
data['keyboard'].append([x.to_dict() for x in keyboard])
78-
76+
for row in self.keyboard:
77+
r = []
78+
for button in row:
79+
if hasattr(button, 'to_dict'):
80+
r.append(button.to_dict()) # telegram.KeyboardButton
81+
else:
82+
r.append(button) # str
83+
data['keyboard'].append(r)
7984
return data

telegram/utils/request.py

Lines changed: 4 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#!/usr/bin/env python
2-
# pylint: disable=no-name-in-module,unused-import
32
#
43
# A library that provides a Python interface to the Telegram Bot API
54
# Copyright (C) 2015-2016
@@ -25,22 +24,9 @@
2524
import socket
2625
from ssl import SSLError
2726

28-
try:
29-
# python2
30-
from httplib import HTTPException
31-
except ImportError:
32-
# python3
33-
from http.client import HTTPException
34-
35-
try:
36-
# python3
37-
from urllib.request import urlopen, urlretrieve, Request
38-
from urllib.error import HTTPError, URLError
39-
except ImportError:
40-
# python2
41-
from urllib import urlretrieve
42-
from urllib2 import urlopen, Request, URLError
43-
from urllib2 import HTTPError
27+
from future.moves.http.client import HTTPException
28+
from future.moves.urllib.error import HTTPError, URLError
29+
from future.moves.urllib.request import urlopen, urlretrieve, Request
4430

4531
from telegram import (InputFile, TelegramError)
4632
from telegram.error import Unauthorized, NetworkError, TimedOut
@@ -130,8 +116,7 @@ def get(url):
130116
@_try_except_req
131117
def post(url,
132118
data,
133-
timeout=None,
134-
network_delay=2.):
119+
timeout=None):
135120
"""Request an URL.
136121
Args:
137122
url:
@@ -141,11 +126,6 @@ def post(url,
141126
timeout:
142127
float. If this value is specified, use it as the definitive timeout (in
143128
seconds) for urlopen() operations. [Optional]
144-
network_delay:
145-
float. If using the timeout specified in `data` (which is a timeout for
146-
the Telegram servers operation), then `network_delay` as an extra delay
147-
(in seconds) to compensate for network latency.
148-
default: 2 [Optional]
149129
150130
Notes:
151131
If neither `timeout` nor `data['timeout']` is specified. The underlying
@@ -159,8 +139,6 @@ def post(url,
159139

160140
if timeout is not None:
161141
urlopen_kwargs['timeout'] = timeout
162-
elif 'timeout' in data:
163-
urlopen_kwargs['timeout'] = data['timeout'] + network_delay
164142

165143
if InputFile.is_inputfile(data):
166144
data = InputFile(data)

tests/base.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,13 @@
1616
#
1717
# You should have received a copy of the GNU General Public License
1818
# along with this program. If not, see [http://www.gnu.org/licenses/].
19+
1920
"""This module contains a object that represents a Base class for tests"""
2021

21-
import signal
22+
import os
2223
import sys
24+
import signal
2325

24-
import os
2526
from nose.tools import make_decorator
2627

2728
sys.path.append('.')
@@ -61,6 +62,7 @@ def is_dict(dictionary):
6162

6263

6364
class TestTimedOut(AssertionError):
65+
6466
def __init__(self, time_limit, frame):
6567
super(TestTimedOut, self).__init__('time_limit={0}'.format(time_limit))
6668
self.time_limit = time_limit

0 commit comments

Comments
 (0)