jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/423704 )
Change subject: [doc] Prepare next release
......................................................................
[doc] Prepare next release
Change-Id: I2d95732d235d27652ed44ffc4a1f61acfe0b08a6
---
M HISTORY.rst
M docs/conf.py
2 files changed, 8 insertions(+), 1 deletion(-)
Approvals:
Dalba: Looks good to me, approved
jenkins-bot: Verified
diff --git a/HISTORY.rst b/HISTORY.rst
index 525006e..067510d 100644
--- a/HISTORY.rst
+++ b/HISTORY.rst
@@ -3,6 +3,13 @@
Current release
---------------
+
+* Bugfixes and improvements
+* Localisation updates
+
+3.0.20180403
+------------
+
* Deprecation warning: support for py2.7.2 and py2.7.3 will be dropped
* Dropped support for Python 2.6 (T154771)
* Dropped support for Python 3.3 (T184508)
diff --git a/docs/conf.py b/docs/conf.py
index 9ead2b0..2c140a4 100644
--- a/docs/conf.py
+++ b/docs/conf.py
@@ -67,7 +67,7 @@
# The short X.Y version.
version = '3.0'
# The full version, including alpha/beta/rc tags.
-release = '3.0.20180304'
+release = '3.0.20180403'
# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
--
To view, visit https://gerrit.wikimedia.org/r/423704
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: I2d95732d235d27652ed44ffc4a1f61acfe0b08a6
Gerrit-Change-Number: 423704
Gerrit-PatchSet: 2
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: Dalba <dalba.wiki(a)gmail.com>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: Zoranzoki21 <zorandori4444(a)gmail.com>
Gerrit-Reviewer: jenkins-bot <>
jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/423702 )
Change subject: [cleanup] Cleanup TODO list
......................................................................
[cleanup] Cleanup TODO list
remove "Rewrite help parser to support earlier releases" from TODO list.
MW 1.10 seems early enough.
Change-Id: Idaae1e38cf2234dfbb8a994cf48a790602e824ed
---
M pywikibot/data/api.py
1 file changed, 0 insertions(+), 2 deletions(-)
Approvals:
Dalba: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/data/api.py b/pywikibot/data/api.py
index 278ff81..29030fe 100644
--- a/pywikibot/data/api.py
+++ b/pywikibot/data/api.py
@@ -172,8 +172,6 @@
It does not support the format modules.
- TODO: Rewrite help parser to support earlier releases.
-
TODO: establish a data structure in the class which prefills
the param information available for a site given its
version, using the API information available for each
--
To view, visit https://gerrit.wikimedia.org/r/423702
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: Idaae1e38cf2234dfbb8a994cf48a790602e824ed
Gerrit-Change-Number: 423702
Gerrit-PatchSet: 1
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: Dalba <dalba.wiki(a)gmail.com>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: Zoranzoki21 <zorandori4444(a)gmail.com>
Gerrit-Reviewer: jenkins-bot <>
jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/423483 )
Change subject: [cleanup] Remove old for dropped python versions
......................................................................
[cleanup] Remove old for dropped python versions
- tools module:
python 2.7.0 and python 2.6 aren't supported anymore
Therefore the ContextManagerWrapper code part
for bz2 and gzip files could be removed
- bot module:
total_seconds() was introduced with 2.7
- deprecate ContextManagerWrapper
Change-Id: I50cc95bc7b9a8845b11d2515a97313511668cdcd
---
M pywikibot/bot.py
M pywikibot/tools/__init__.py
M tests/tools_tests.py
3 files changed, 56 insertions(+), 61 deletions(-)
Approvals:
Dalba: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/bot.py b/pywikibot/bot.py
index ceb9459..802ab04 100644
--- a/pywikibot/bot.py
+++ b/pywikibot/bot.py
@@ -96,7 +96,7 @@
)
from pywikibot.logging import critical
from pywikibot.tools import (
- deprecated, deprecate_arg, deprecated_args, PY2, PYTHON_VERSION,
+ deprecated, deprecate_arg, deprecated_args, PY2,
)
from pywikibot.tools._logging import (
LoggingFormatter as _LoggingFormatter,
@@ -1380,10 +1380,7 @@
% (self._treat_counter, self._save_counter))
if hasattr(self, '_start_ts'):
delta = (pywikibot.Timestamp.now() - self._start_ts)
- if PYTHON_VERSION >= (2, 7):
- seconds = int(delta.total_seconds())
- else:
- seconds = delta.seconds + delta.days * 86400
+ seconds = int(delta.total_seconds())
if delta.days:
pywikibot.output("Execution time: %d days, %d seconds"
% (delta.days, delta.seconds))
diff --git a/pywikibot/tools/__init__.py b/pywikibot/tools/__init__.py
index 95eae41..4df67fc 100644
--- a/pywikibot/tools/__init__.py
+++ b/pywikibot/tools/__init__.py
@@ -988,48 +988,6 @@
raise StopIteration
-class ContextManagerWrapper(object):
-
- """
- Wraps an object in a context manager.
-
- It is redirecting all access to the wrapped object and executes 'close' when
- used as a context manager in with-statements. In such statements the value
- set via 'as' is directly the wrapped object. For example:
-
- >>> class Wrapper(object):
- ... def close(self): pass
- >>> an_object = Wrapper()
- >>> wrapped = ContextManagerWrapper(an_object)
- >>> with wrapped as another_object:
- ... assert another_object is an_object
-
- It does not subclass the object though, so isinstance checks will fail
- outside a with-statement.
- """
-
- def __init__(self, wrapped):
- """Create a new wrapper."""
- super(ContextManagerWrapper, self).__init__()
- super(ContextManagerWrapper, self).__setattr__('_wrapped', wrapped)
-
- def __enter__(self):
- """Enter a context manager and use the wrapped object directly."""
- return self._wrapped
-
- def __exit__(self, exc_type, exc_value, traceback):
- """Call close on the wrapped object when exiting a context manager."""
- self._wrapped.close()
-
- def __getattr__(self, name):
- """Get the attribute from the wrapped object."""
- return getattr(self._wrapped, name)
-
- def __setattr__(self, name, value):
- """Set the attribute in the wrapped object."""
- setattr(self._wrapped, name, value)
-
-
def open_archive(filename, mode='rb', use_extension=True):
"""
Open a file and uncompress it if needed.
@@ -1060,17 +1018,8 @@
It is also raised by bz2 when its content is invalid. gzip does not
immediately raise that error but only on reading it.
@return: A file-like object returning the uncompressed data in binary mode.
- Before Python 2.7 the GzipFile object and before 2.7.1 the BZ2File are
- wrapped in a ContextManagerWrapper with its advantages/disadvantages.
@rtype: file-like object
"""
- def wrap(wrapped, sub_ver):
- """Wrap in a wrapper when this is below Python version 2.7."""
- if PYTHON_VERSION < (2, 7, sub_ver):
- return ContextManagerWrapper(wrapped)
- else:
- return wrapped
-
if mode in ('r', 'a', 'w'):
mode += 'b'
elif mode not in ('rb', 'ab', 'wb'):
@@ -1097,9 +1046,9 @@
if extension == 'bz2':
if isinstance(bz2, ImportError):
raise bz2
- return wrap(bz2.BZ2File(filename, mode), 1)
+ return bz2.BZ2File(filename, mode)
elif extension == 'gz':
- return wrap(gzip.open(filename, mode), 0)
+ return gzip.open(filename, mode)
elif extension == '7z':
if mode != 'rb':
raise NotImplementedError('It is not possible to write a 7z file.')
@@ -1785,8 +1734,53 @@
sha.update(read_bytes)
return sha.hexdigest()
+# deprecated parts ############################################################
+
+
+class ContextManagerWrapper(object):
+
+ """
+ DEPRECATED. Wraps an object in a context manager.
+
+ It is redirecting all access to the wrapped object and executes 'close'
+ when used as a context manager in with-statements. In such statements the
+ value set via 'as' is directly the wrapped object. For example:
+
+ >>> class Wrapper(object):
+ ... def close(self): pass
+ >>> an_object = Wrapper()
+ >>> wrapped = ContextManagerWrapper(an_object)
+ >>> with wrapped as another_object:
+ ... assert another_object is an_object
+
+ It does not subclass the object though, so isinstance checks will fail
+ outside a with-statement.
+ """
+
+ def __init__(self, wrapped):
+ """Create a new wrapper."""
+ super(ContextManagerWrapper, self).__init__()
+ super(ContextManagerWrapper, self).__setattr__('_wrapped', wrapped)
+
+ def __enter__(self):
+ """Enter a context manager and use the wrapped object directly."""
+ return self._wrapped
+
+ def __exit__(self, exc_type, exc_value, traceback):
+ """Call close on the wrapped object when exiting a context manager."""
+ self._wrapped.close()
+
+ def __getattr__(self, name):
+ """Get the attribute from the wrapped object."""
+ return getattr(self._wrapped, name)
+
+ def __setattr__(self, name, value):
+ """Set the attribute in the wrapped object."""
+ setattr(self._wrapped, name, value)
+
wrapper = ModuleDeprecationWrapper(__name__)
wrapper._add_deprecated_attr('Counter', collections.Counter)
wrapper._add_deprecated_attr('OrderedDict', collections.OrderedDict)
wrapper._add_deprecated_attr('count', itertools.count)
+wrapper._add_deprecated_attr('ContextManagerWrapper', replacement_name='')
diff --git a/tests/tools_tests.py b/tests/tools_tests.py
index ab58205..e0429c0 100644
--- a/tests/tools_tests.py
+++ b/tests/tools_tests.py
@@ -16,7 +16,7 @@
import warnings
from pywikibot import tools
-from pywikibot.tools import classproperty
+from pywikibot.tools import classproperty, suppress_warnings
from tests import join_xml_data_path, mock
from tests.aspects import (
@@ -49,7 +49,9 @@
def test_wrapper(self):
"""Create a test instance and verify the wrapper redirects."""
obj = self.DummyClass()
- wrapped = tools.ContextManagerWrapper(obj)
+ with suppress_warnings(
+ 'pywikibot.tools.ContextManagerWrapper is deprecated.'):
+ wrapped = tools.ContextManagerWrapper(obj)
self.assertIs(wrapped.class_var, obj.class_var)
self.assertIs(wrapped.instance_var, obj.instance_var)
self.assertIs(wrapped._wrapped, obj)
@@ -63,7 +65,9 @@
def test_exec_wrapper(self):
"""Check that the wrapper permits exceptions."""
- wrapper = tools.ContextManagerWrapper(self.DummyClass())
+ with suppress_warnings(
+ 'pywikibot.tools.ContextManagerWrapper is deprecated.'):
+ wrapper = tools.ContextManagerWrapper(self.DummyClass())
self.assertFalse(wrapper.closed)
with self.assertRaisesRegex(ZeroDivisionError,
'(integer division or modulo by zero|division by zero)'):
--
To view, visit https://gerrit.wikimedia.org/r/423483
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: I50cc95bc7b9a8845b11d2515a97313511668cdcd
Gerrit-Change-Number: 423483
Gerrit-PatchSet: 5
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: Dalba <dalba.wiki(a)gmail.com>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: Zoranzoki21 <zorandori4444(a)gmail.com>
Gerrit-Reviewer: jenkins-bot <>
jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/423461 )
Change subject: Deprecation warning; python 2.7.2 and 2.7.3 will be dropped
......................................................................
Deprecation warning; python 2.7.2 and 2.7.3 will be dropped
Bug: T191192
Change-Id: I82ffb279f10e4388c8a6094477ab35fc88993e06
---
M HISTORY.rst
M pywikibot/__init__.py
M tests/utils.py
3 files changed, 13 insertions(+), 1 deletion(-)
Approvals:
Dalba: Looks good to me, approved
jenkins-bot: Verified
diff --git a/HISTORY.rst b/HISTORY.rst
index 3c7d1e2..525006e 100644
--- a/HISTORY.rst
+++ b/HISTORY.rst
@@ -3,7 +3,7 @@
Current release
---------------
-
+* Deprecation warning: support for py2.7.2 and py2.7.3 will be dropped
* Dropped support for Python 2.6 (T154771)
* Dropped support for Python 3.3 (T184508)
* Bugfixes and improvements
diff --git a/pywikibot/__init__.py b/pywikibot/__init__.py
index cd3e18c..0d612f3 100644
--- a/pywikibot/__init__.py
+++ b/pywikibot/__init__.py
@@ -135,6 +135,14 @@
deprecate_arg = redirect_func(_deprecate_arg)
+if sys.version_info[:2] == (2, 7) and sys.version_info[2] in (2, 3):
+ warn(
+ 'Pywikibot will soon drop support for Python 2.7.2 and 2.7.3, '
+ 'please update your Python.',
+ DeprecationWarning,
+ )
+
+
class Timestamp(datetime.datetime):
"""Class for handling MediaWiki timestamps.
diff --git a/tests/utils.py b/tests/utils.py
index 2f7837a..8178427 100644
--- a/tests/utils.py
+++ b/tests/utils.py
@@ -638,6 +638,10 @@
@param command: executable to run and arguments to use
@type command: list of unicode
"""
+ if PYTHON_VERSION[:2] == (2, 7) and PYTHON_VERSION[2] in (2, 3):
+ command.insert(1, '-W ignore:{0}:DeprecationWarning'.format(
+ 'Pywikibot will soon drop support for Python 2.7.2 and 2.7.3, '
+ 'please update your Python.'))
# Any environment variables added on Windows must be of type
# str() on Python 2.
env = os.environ.copy()
--
To view, visit https://gerrit.wikimedia.org/r/423461
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: I82ffb279f10e4388c8a6094477ab35fc88993e06
Gerrit-Change-Number: 423461
Gerrit-PatchSet: 2
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: Dalba <dalba.wiki(a)gmail.com>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: Zoranzoki21 <zorandori4444(a)gmail.com>
Gerrit-Reviewer: jenkins-bot <>
jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/423451 )
Change subject: textlib.py: Avoid zero-width matching groups
......................................................................
textlib.py: Avoid zero-width matching groups
This is a little trick to circumvent https://bugs.python.org/issue12177 .
The Memory error of re in Python 2.7.2 and 2.7.3 has something to do with
zero-width matching groups.
Here, by using + instead of * in other_chars group we avoid a zero-width match
and to make the group optional again we make the whole positive lookahead and
its group optional.
Bug: T191161
Change-Id: Ibfc8b8f961bdb13284aa5592fd9b7597e47f9d97
---
M pywikibot/textlib.py
1 file changed, 6 insertions(+), 6 deletions(-)
Approvals:
Xqt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/textlib.py b/pywikibot/textlib.py
index f959673..694e781 100644
--- a/pywikibot/textlib.py
+++ b/pywikibot/textlib.py
@@ -107,9 +107,9 @@
\[\[\s*
(?:%s) # namespace aliases
\s*:
- (?=(?P<filename>
- [^]|]*
- ))(?P=filename)
+ ((?=(?P<filename>
+ [^]|]+ # * quantifier may crash on Python 2.7.2 (T191161)
+ ))(?P=filename))?
(
\|
(
@@ -118,9 +118,9 @@
\[\[.*?\]\]
))(?P=inner_link)
)?
- (?=(?P<other_chars>
- [^\[\]]*
- ))(?P=other_chars)
+ ((?=(?P<other_chars>
+ [^\[\]]+ # * quantifier may crash on Python 2.7.2 (T191161)
+ ))(?P=other_chars))?
|
(?=(?P<not_wikilink>
\[[^]]*\]
--
To view, visit https://gerrit.wikimedia.org/r/423451
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: Ibfc8b8f961bdb13284aa5592fd9b7597e47f9d97
Gerrit-Change-Number: 423451
Gerrit-PatchSet: 2
Gerrit-Owner: Dalba <dalba.wiki(a)gmail.com>
Gerrit-Reviewer: Dalba <dalba.wiki(a)gmail.com>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: Zoranzoki21 <zorandori4444(a)gmail.com>
Gerrit-Reviewer: jenkins-bot <>
jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/423366 )
Change subject: setup.py: Use PYTHON_VERSION for version comparisons
......................................................................
setup.py: Use PYTHON_VERSION for version comparisons
sys.version_info == (2, 7, 2) is always False. The tuple form of
sys.version_info is something like (2, 7, 6, 'final', 0).
To avoid any future mistakes also replace other occurrences of
sys.version_info.
Bug: T191190
Change-Id: I247033d0908d0f1966e2eb9376d3fead4ce240c2
---
M setup.py
1 file changed, 5 insertions(+), 5 deletions(-)
Approvals:
Xqt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/setup.py b/setup.py
index 90d1649..4561aec 100644
--- a/setup.py
+++ b/setup.py
@@ -99,7 +99,7 @@
import unittest2
sys.modules['unittest'] = unittest2
-if sys.version_info[0] == 2:
+if PY2:
# tools.ip does not have a hard dependency on an IP address module,
# as it falls back to using regexes if one is not available.
# The functional backport of py3 ipaddress is acceptable:
@@ -110,10 +110,10 @@
# ipaddr 2.1.10+ is distributed with Debian and Fedora. See T105443.
dependencies.append('ipaddr>=2.1.10')
- if sys.version_info == (2, 7, 2):
+ if PYTHON_VERSION == (2, 7, 2):
dependencies.append('future>=0.15.0') # Bug fixes for HTMLParser
- if sys.version_info < (2, 7, 9):
+ if PYTHON_VERSION < (2, 7, 9):
# Python versions before 2.7.9 will cause urllib3 to trigger
# InsecurePlatformWarning warnings for all HTTPS requests. By
# installing with security extras, requests will automatically set
@@ -155,11 +155,11 @@
if 'requests[security]' in test_deps:
# Bug T105767 on Python 2.7 release 9+
- if sys.version_info[:2] == (2, 7) and sys.version_info[2] >= 9:
+ if PY2 and PYTHON_VERSION[2] >= 9:
test_deps.remove('requests[security]')
# These extra dependencies are needed other unittest fails to load tests.
-if sys.version_info[0] == 2:
+if PY2:
test_deps += extra_deps['csv'] + ['mock']
else:
test_deps += ['six']
--
To view, visit https://gerrit.wikimedia.org/r/423366
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: I247033d0908d0f1966e2eb9376d3fead4ce240c2
Gerrit-Change-Number: 423366
Gerrit-PatchSet: 1
Gerrit-Owner: Dalba <dalba.wiki(a)gmail.com>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: Zoranzoki21 <zorandori4444(a)gmail.com>
Gerrit-Reviewer: jenkins-bot <>