drop Python 2.6 support (closes #245) (#386)

* drop Python 2.6 support (closes #245)

* fix NullHandler import

* README: explicitly mention Py3 and PyPy compatibility
This commit is contained in:
Rahiel Kasim 2016-08-20 22:01:07 +02:00 committed by GitHub
parent e9c5ee7ad6
commit 00bba73673
47 changed files with 51 additions and 238 deletions

View file

@ -1,6 +1,5 @@
language: python language: python
python: python:
- "2.6"
- "2.7" - "2.7"
- "3.3" - "3.3"
- "3.4" - "3.4"
@ -13,6 +12,6 @@ install:
- pip install -r requirements-dev.txt - pip install -r requirements-dev.txt
script: script:
- nosetests -v --with-flaky --no-flaky-report --with-coverage --cover-package=telegram/ - nosetests -v --with-flaky --no-flaky-report --with-coverage --cover-package=telegram/
- 'if [ $TRAVIS_PYTHON_VERSION != 2.6 ] && [ $TRAVIS_PYTHON_VERSION != 3.3 ] && [ $TRAVIS_PYTHON_VERSION != pypy3 ]; then pre-commit run --all-files; fi' - 'if [ $TRAVIS_PYTHON_VERSION != 3.3 ] && [ $TRAVIS_PYTHON_VERSION != pypy3 ]; then pre-commit run --all-files; fi'
after_success: after_success:
coveralls coveralls

View file

@ -73,8 +73,7 @@ Introduction
This library provides a pure Python interface for the This library provides a pure Python interface for the
`Telegram Bot API <https://core.telegram.org/bots/api>`_. `Telegram Bot API <https://core.telegram.org/bots/api>`_.
It works with Python versions from 2.6+ (**Note:** Support for 2.6 will be dropped at some point It's compatible with Python versions 2.7, 3.3+ and `PyPy <http://pypy.org/>`_.
this year. 2.7 will still be supported).
It also works with `Google App Engine <https://cloud.google.com/appengine>`_. It also works with `Google App Engine <https://cloud.google.com/appengine>`_.
In addition to the pure API implementation, this library features a number of high-level classes to In addition to the pure API implementation, this library features a number of high-level classes to

View file

@ -2,7 +2,6 @@ flake8
nose nose
pep257 pep257
pylint pylint
unittest2
flaky flaky
yapf yapf
pre-commit pre-commit

View file

@ -45,7 +45,6 @@ with codecs.open('README.rst', 'r', 'utf-8') as fd:
'Topic :: Internet', 'Topic :: Internet',
'Programming Language :: Python', 'Programming Language :: Python',
'Programming Language :: Python :: 2', 'Programming Language :: Python :: 2',
'Programming Language :: Python :: 2.6',
'Programming Language :: Python :: 2.7', 'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3', 'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.3', 'Programming Language :: Python :: 3.3',

View file

@ -43,7 +43,6 @@ from .forcereply import ForceReply
from .error import TelegramError from .error import TelegramError
from .inputfile import InputFile from .inputfile import InputFile
from .file import File from .file import File
from .nullhandler import NullHandler
from .emoji import Emoji from .emoji import Emoji
from .parsemode import ParseMode from .parsemode import ParseMode
from .messageentity import MessageEntity from .messageentity import MessageEntity
@ -101,14 +100,9 @@ __all__ = ['Audio', 'Bot', 'Chat', 'ChatMember', 'ChatAction', 'ChosenInlineResu
'InlineQueryResultVenue', 'InlineQueryResultVideo', 'InlineQueryResultVoice', 'InlineQueryResultVenue', 'InlineQueryResultVideo', 'InlineQueryResultVoice',
'InputContactMessageContent', 'InputFile', 'InputLocationMessageContent', 'InputContactMessageContent', 'InputFile', 'InputLocationMessageContent',
'InputMessageContent', 'InputTextMessageContent', 'InputVenueMessageContent', 'InputMessageContent', 'InputTextMessageContent', 'InputVenueMessageContent',
'KeyboardButton', 'Location', 'Message', 'MessageEntity', 'NullHandler', 'ParseMode', 'KeyboardButton', 'Location', 'Message', 'MessageEntity', 'ParseMode', 'PhotoSize',
'PhotoSize', 'ReplyKeyboardHide', 'ReplyKeyboardMarkup', 'ReplyMarkup', 'Sticker', 'ReplyKeyboardHide', 'ReplyKeyboardMarkup', 'ReplyMarkup', 'Sticker', 'TelegramError',
'TelegramError', 'TelegramObject', 'Update', 'User', 'UserProfilePhotos', 'Venue', 'TelegramObject', 'Update', 'User', 'UserProfilePhotos', 'Venue', 'Video', 'Voice',
'Video', 'Voice', 'MAX_MESSAGE_LENGTH', 'MAX_CAPTION_LENGTH', 'SUPPORTED_WEBHOOK_PORTS', 'MAX_MESSAGE_LENGTH', 'MAX_CAPTION_LENGTH', 'SUPPORTED_WEBHOOK_PORTS',
'MAX_FILESIZE_DOWNLOAD', 'MAX_FILESIZE_UPLOAD', 'MAX_MESSAGES_PER_SECOND_PER_CHAT', 'MAX_FILESIZE_DOWNLOAD', 'MAX_FILESIZE_UPLOAD', 'MAX_MESSAGES_PER_SECOND_PER_CHAT',
'MAX_MESSAGES_PER_SECOND', 'MAX_MESSAGES_PER_MINUTE_PER_GROUP'] 'MAX_MESSAGES_PER_SECOND', 'MAX_MESSAGES_PER_MINUTE_PER_GROUP']
if version_info < (2, 7):
from warnings import warn
warn("python-telegram-bot will stop supporting Python 2.6 in a future release. "
"Please upgrade your Python version to at least Python 2.7!")

View file

@ -23,11 +23,11 @@ import functools
import logging import logging
from telegram import (User, Message, Update, Chat, ChatMember, UserProfilePhotos, File, from telegram import (User, Message, Update, Chat, ChatMember, UserProfilePhotos, File,
ReplyMarkup, TelegramObject, NullHandler) ReplyMarkup, TelegramObject)
from telegram.error import InvalidToken from telegram.error import InvalidToken
from telegram.utils import request from telegram.utils import request
logging.getLogger(__name__).addHandler(NullHandler()) logging.getLogger(__name__).addHandler(logging.NullHandler())
class Bot(TelegramObject): class Bot(TelegramObject):

View file

@ -1,11 +1,10 @@
import logging import logging
from telegram import NullHandler
from future.moves.urllib.parse import quote from future.moves.urllib.parse import quote
from future.moves.urllib.error import HTTPError, URLError from future.moves.urllib.error import HTTPError, URLError
from future.moves.urllib.request import urlopen, Request from future.moves.urllib.request import urlopen, Request
logging.getLogger(__name__).addHandler(NullHandler()) logging.getLogger(__name__).addHandler(logging.NullHandler())
class Botan(object): class Botan(object):

View file

@ -26,13 +26,13 @@ from queue import Queue, Empty
from future.builtins import range from future.builtins import range
from telegram import (TelegramError, NullHandler) from telegram import TelegramError
from telegram.utils import request from telegram.utils import request
from telegram.ext.handler import Handler from telegram.ext.handler import Handler
from telegram.utils.deprecate import deprecate from telegram.utils.deprecate import deprecate
from telegram.utils.promise import Promise from telegram.utils.promise import Promise
logging.getLogger(__name__).addHandler(NullHandler()) logging.getLogger(__name__).addHandler(logging.NullHandler())
ASYNC_QUEUE = Queue() ASYNC_QUEUE = Queue()
ASYNC_THREADS = set() ASYNC_THREADS = set()

View file

@ -28,12 +28,12 @@ import subprocess
from signal import signal, SIGINT, SIGTERM, SIGABRT from signal import signal, SIGINT, SIGTERM, SIGABRT
from queue import Queue from queue import Queue
from telegram import Bot, TelegramError, NullHandler from telegram import Bot, TelegramError
from telegram.ext import dispatcher, Dispatcher, JobQueue from telegram.ext import dispatcher, Dispatcher, JobQueue
from telegram.error import Unauthorized, InvalidToken from telegram.error import Unauthorized, InvalidToken
from telegram.utils.webhookhandler import (WebhookServer, WebhookHandler) from telegram.utils.webhookhandler import (WebhookServer, WebhookHandler)
logging.getLogger(__name__).addHandler(NullHandler()) logging.getLogger(__name__).addHandler(logging.NullHandler())
class Updater(object): class Updater(object):

View file

@ -1,32 +0,0 @@
#!/usr/bin/env python
#
# A library that provides a Python interface to the Telegram Bot API
# Copyright (C) 2015-2016
# Leandro Toledo de Souza <devs@python-telegram-bot.org>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser Public License for more details.
#
# You should have received a copy of the GNU Lesser Public License
# along with this program. If not, see [http://www.gnu.org/licenses/].
"""This module contains a object that represents a logging NullHandler."""
import logging
class NullHandler(logging.Handler):
"""This object represents a logging NullHandler."""
def emit(self, record):
"""
Args:
record (str):
"""
pass

View file

@ -1,6 +1,6 @@
import logging import logging
from telegram import Update, NullHandler from telegram import Update
from future.utils import bytes_to_native_str from future.utils import bytes_to_native_str
from threading import Lock from threading import Lock
import json import json
@ -9,7 +9,7 @@ try:
except ImportError: except ImportError:
import http.server as BaseHTTPServer import http.server as BaseHTTPServer
logging.getLogger(__name__).addHandler(NullHandler()) logging.getLogger(__name__).addHandler(logging.NullHandler())
class _InvalidPost(Exception): class _InvalidPost(Exception):

View file

@ -23,14 +23,10 @@ import io
import re import re
from datetime import datetime from datetime import datetime
import sys import sys
import unittest
from flaky import flaky from flaky import flaky
if sys.version_info[0:2] == (2, 6):
import unittest2 as unittest
else:
import unittest
sys.path.append('.') sys.path.append('.')
import telegram import telegram

View file

@ -20,11 +20,7 @@
ChosenInlineResult""" ChosenInlineResult"""
import sys import sys
import unittest
if sys.version_info[0:2] == (2, 6):
import unittest2 as unittest
else:
import unittest
sys.path.append('.') sys.path.append('.')

View file

@ -17,14 +17,10 @@
"""Test the Telegram constants.""" """Test the Telegram constants."""
import sys import sys
import unittest
from flaky import flaky from flaky import flaky
if sys.version_info[0:2] == (2, 6):
import unittest2 as unittest
else:
import unittest
sys.path.append('.') sys.path.append('.')
import telegram import telegram

View file

@ -22,13 +22,9 @@ This module contains a object that represents Tests for ConversationHandler
""" """
import logging import logging
import sys import sys
import unittest
from time import sleep from time import sleep
if sys.version_info[0:2] == (2, 6):
import unittest2 as unittest
else:
import unittest
try: try:
# python2 # python2
from urllib2 import urlopen, Request, HTTPError from urllib2 import urlopen, Request, HTTPError

View file

@ -20,11 +20,7 @@
"""This module contains a object that represents Tests for Telegram InlineKeyboardButton""" """This module contains a object that represents Tests for Telegram InlineKeyboardButton"""
import sys import sys
import unittest
if sys.version_info[0:2] == (2, 6):
import unittest2 as unittest
else:
import unittest
sys.path.append('.') sys.path.append('.')

View file

@ -20,11 +20,7 @@
InlineQuery""" InlineQuery"""
import sys import sys
import unittest
if sys.version_info[0:2] == (2, 6):
import unittest2 as unittest
else:
import unittest
sys.path.append('.') sys.path.append('.')

View file

@ -20,11 +20,7 @@
InlineQueryResultArticle""" InlineQueryResultArticle"""
import sys import sys
import unittest
if sys.version_info[0:2] == (2, 6):
import unittest2 as unittest
else:
import unittest
sys.path.append('.') sys.path.append('.')

View file

@ -20,11 +20,7 @@
InlineQueryResultAudio""" InlineQueryResultAudio"""
import sys import sys
import unittest
if sys.version_info[0:2] == (2, 6):
import unittest2 as unittest
else:
import unittest
sys.path.append('.') sys.path.append('.')

View file

@ -20,11 +20,7 @@
InlineQueryResultCachedAudio""" InlineQueryResultCachedAudio"""
import sys import sys
import unittest
if sys.version_info[0:2] == (2, 6):
import unittest2 as unittest
else:
import unittest
sys.path.append('.') sys.path.append('.')

View file

@ -20,11 +20,7 @@
InlineQueryResultCachedDocument""" InlineQueryResultCachedDocument"""
import sys import sys
import unittest
if sys.version_info[0:2] == (2, 6):
import unittest2 as unittest
else:
import unittest
sys.path.append('.') sys.path.append('.')

View file

@ -20,11 +20,7 @@
InlineQueryResultCachedGif""" InlineQueryResultCachedGif"""
import sys import sys
import unittest
if sys.version_info[0:2] == (2, 6):
import unittest2 as unittest
else:
import unittest
sys.path.append('.') sys.path.append('.')

View file

@ -20,11 +20,7 @@
InlineQueryResultCachedMpeg4Gif""" InlineQueryResultCachedMpeg4Gif"""
import sys import sys
import unittest
if sys.version_info[0:2] == (2, 6):
import unittest2 as unittest
else:
import unittest
sys.path.append('.') sys.path.append('.')

View file

@ -20,11 +20,7 @@
InlineQueryResultCachedPhoto""" InlineQueryResultCachedPhoto"""
import sys import sys
import unittest
if sys.version_info[0:2] == (2, 6):
import unittest2 as unittest
else:
import unittest
sys.path.append('.') sys.path.append('.')

View file

@ -20,11 +20,7 @@
InlineQueryResultCachedSticker""" InlineQueryResultCachedSticker"""
import sys import sys
import unittest
if sys.version_info[0:2] == (2, 6):
import unittest2 as unittest
else:
import unittest
sys.path.append('.') sys.path.append('.')

View file

@ -20,11 +20,7 @@
InlineQueryResultCachedVideo""" InlineQueryResultCachedVideo"""
import sys import sys
import unittest
if sys.version_info[0:2] == (2, 6):
import unittest2 as unittest
else:
import unittest
sys.path.append('.') sys.path.append('.')

View file

@ -20,11 +20,7 @@
InlineQueryResultCachedVoice""" InlineQueryResultCachedVoice"""
import sys import sys
import unittest
if sys.version_info[0:2] == (2, 6):
import unittest2 as unittest
else:
import unittest
sys.path.append('.') sys.path.append('.')

View file

@ -20,11 +20,7 @@
InlineQueryResultContact""" InlineQueryResultContact"""
import sys import sys
import unittest
if sys.version_info[0:2] == (2, 6):
import unittest2 as unittest
else:
import unittest
sys.path.append('.') sys.path.append('.')

View file

@ -20,11 +20,7 @@
InlineQueryResultDocument""" InlineQueryResultDocument"""
import sys import sys
import unittest
if sys.version_info[0:2] == (2, 6):
import unittest2 as unittest
else:
import unittest
sys.path.append('.') sys.path.append('.')

View file

@ -20,11 +20,7 @@
InlineQueryResultGif""" InlineQueryResultGif"""
import sys import sys
import unittest
if sys.version_info[0:2] == (2, 6):
import unittest2 as unittest
else:
import unittest
sys.path.append('.') sys.path.append('.')

View file

@ -20,11 +20,7 @@
InlineQueryResultLocation""" InlineQueryResultLocation"""
import sys import sys
import unittest
if sys.version_info[0:2] == (2, 6):
import unittest2 as unittest
else:
import unittest
sys.path.append('.') sys.path.append('.')

View file

@ -20,11 +20,7 @@
InlineQueryResultMpeg4Gif""" InlineQueryResultMpeg4Gif"""
import sys import sys
import unittest
if sys.version_info[0:2] == (2, 6):
import unittest2 as unittest
else:
import unittest
sys.path.append('.') sys.path.append('.')

View file

@ -20,11 +20,7 @@
InlineQueryResultPhoto""" InlineQueryResultPhoto"""
import sys import sys
import unittest
if sys.version_info[0:2] == (2, 6):
import unittest2 as unittest
else:
import unittest
sys.path.append('.') sys.path.append('.')

View file

@ -20,11 +20,7 @@
InlineQueryResultVenue""" InlineQueryResultVenue"""
import sys import sys
import unittest
if sys.version_info[0:2] == (2, 6):
import unittest2 as unittest
else:
import unittest
sys.path.append('.') sys.path.append('.')

View file

@ -20,11 +20,7 @@
InlineQueryResultVideo""" InlineQueryResultVideo"""
import sys import sys
import unittest
if sys.version_info[0:2] == (2, 6):
import unittest2 as unittest
else:
import unittest
sys.path.append('.') sys.path.append('.')

View file

@ -20,11 +20,7 @@
InlineQueryResultVoice""" InlineQueryResultVoice"""
import sys import sys
import unittest
if sys.version_info[0:2] == (2, 6):
import unittest2 as unittest
else:
import unittest
sys.path.append('.') sys.path.append('.')

View file

@ -20,11 +20,7 @@
InputContactMessageContent""" InputContactMessageContent"""
import sys import sys
import unittest
if sys.version_info[0:2] == (2, 6):
import unittest2 as unittest
else:
import unittest
sys.path.append('.') sys.path.append('.')

View file

@ -20,11 +20,7 @@
InputLocationMessageContent""" InputLocationMessageContent"""
import sys import sys
import unittest
if sys.version_info[0:2] == (2, 6):
import unittest2 as unittest
else:
import unittest
sys.path.append('.') sys.path.append('.')

View file

@ -20,11 +20,7 @@
InputMessageContent""" InputMessageContent"""
import sys import sys
import unittest
if sys.version_info[0:2] == (2, 6):
import unittest2 as unittest
else:
import unittest
sys.path.append('.') sys.path.append('.')

View file

@ -20,11 +20,7 @@
InputTextMessageContent""" InputTextMessageContent"""
import sys import sys
import unittest
if sys.version_info[0:2] == (2, 6):
import unittest2 as unittest
else:
import unittest
sys.path.append('.') sys.path.append('.')

View file

@ -20,11 +20,7 @@
InputVenueMessageContent""" InputVenueMessageContent"""
import sys import sys
import unittest
if sys.version_info[0:2] == (2, 6):
import unittest2 as unittest
else:
import unittest
sys.path.append('.') sys.path.append('.')

View file

@ -22,13 +22,9 @@ This module contains a object that represents Tests for JobQueue
""" """
import logging import logging
import sys import sys
import unittest
from time import sleep from time import sleep
if sys.version_info[0:2] == (2, 6):
import unittest2 as unittest
else:
import unittest
sys.path.append('.') sys.path.append('.')
from telegram.utils.request import stop_con_pool from telegram.utils.request import stop_con_pool

View file

@ -21,11 +21,7 @@
KeyboardButton""" KeyboardButton"""
import sys import sys
import unittest
if sys.version_info[0:2] == (2, 6):
import unittest2 as unittest
else:
import unittest
sys.path.append('.') sys.path.append('.')

View file

@ -20,11 +20,7 @@
MessageEntity""" MessageEntity"""
import sys import sys
import unittest
if sys.version_info[0:2] == (2, 6):
import unittest2 as unittest
else:
import unittest
sys.path.append('.') sys.path.append('.')

View file

@ -20,11 +20,7 @@
ReplyMarkup""" ReplyMarkup"""
import sys import sys
import unittest
if sys.version_info[0:2] == (2, 6):
import unittest2 as unittest
else:
import unittest
sys.path.append('.') sys.path.append('.')

View file

@ -26,17 +26,13 @@ import signal
import sys import sys
import os import os
import re import re
import unittest
from datetime import datetime from datetime import datetime
from time import sleep from time import sleep
from random import randrange from random import randrange
from future.builtins import bytes from future.builtins import bytes
if sys.version_info[0:2] == (2, 6):
import unittest2 as unittest
else:
import unittest
try: try:
# python2 # python2
from urllib2 import urlopen, Request, HTTPError from urllib2 import urlopen, Request, HTTPError

View file

@ -19,11 +19,7 @@
"""This module contains a object that represents Tests for Telegram Venue""" """This module contains a object that represents Tests for Telegram Venue"""
import sys import sys
import unittest
if sys.version_info[0:2] == (2, 6):
import unittest2 as unittest
else:
import unittest
sys.path.append('.') sys.path.append('.')