Merge lp:~vila/bzr/1644003-lazy-regex into lp:bzr/2.7

Proposed by Vincent Ladeuil on 2017-01-15
Status: Merged
Approved by: Vincent Ladeuil on 2017-01-16
Approved revision: 6620
Merged at revision: 6621
Proposed branch: lp:~vila/bzr/1644003-lazy-regex
Merge into: lp:bzr/2.7
Diff against target: 50 lines (+15/-2)
4 files modified
bzrlib/lazy_regex.py (+10/-0)
bzrlib/tests/test_http.py (+1/-1)
bzrlib/transport/http/_pycurl.py (+1/-1)
doc/en/release-notes/bzr-2.7.txt (+3/-0)
To merge this branch: bzr merge lp:~vila/bzr/1644003-lazy-regex
Reviewer Review Type Date Requested Status
Jelmer Vernooij (community) 2017-01-15 Approve on 2017-01-15
Review via email: mp+314788@code.launchpad.net

Commit message

Fix python re monkey-patching leak.

Description of the change

This fixes bug #1644003 by extending the monkey-patching of python's re.

'finditer' is public and once bzr starts replacing Regex objects with LazyRegexps objects, finditer() calls break.

To post a comment you must log in.
Jelmer Vernooij (jelmer) :
review: Approve
bzr PQM (bzr-pqm) wrote :
Download full text (3.1 MiB)

The attempt to merge lp:~vila/bzr/1644003-lazy-regex into lp:bzr/2.7 failed. Below is the output from the failed tests.

python tools/rst2html.py --link-stylesheet --footnote-references=superscript --halt=warning --stylesheet=../../default.css doc/en/tutorials/tutorial.txt "doc/en/tutorials/tutorial.html"
python tools/rst2html.py --link-stylesheet --footnote-references=superscript --halt=warning --stylesheet=../../default.css doc/en/tutorials/using_bazaar_with_launchpad.txt "doc/en/tutorials/using_bazaar_with_launchpad.html"
python tools/rst2html.py --link-stylesheet --footnote-references=superscript --halt=warning --stylesheet=../../default.css doc/en/tutorials/centralized_workflow.txt "doc/en/tutorials/centralized_workflow.html"
python tools/rst2html.py --link-stylesheet --footnote-references=superscript --halt=warning --stylesheet=../../default.css doc/ru/tutorials/centralized_workflow.txt "doc/ru/tutorials/centralized_workflow.html"
python tools/rst2html.py --link-stylesheet --footnote-references=superscript --halt=warning --stylesheet=../../default.css doc/ru/tutorials/using_bazaar_with_launchpad.txt "doc/ru/tutorials/using_bazaar_with_launchpad.html"
python tools/rst2html.py --link-stylesheet --footnote-references=superscript --halt=warning --stylesheet=../../default.css doc/ru/tutorials/tutorial.txt "doc/ru/tutorials/tutorial.html"
python tools/rst2html.py --link-stylesheet --footnote-references=superscript --halt=warning --stylesheet=../../default.css doc/ja/tutorials/tutorial.txt "doc/ja/tutorials/tutorial.html"
python tools/rst2html.py --link-stylesheet --footnote-references=superscript --halt=warning --stylesheet=../../default.css doc/ja/tutorials/using_bazaar_with_launchpad.txt "doc/ja/tutorials/using_bazaar_with_launchpad.html"
python tools/rst2html.py --link-stylesheet --footnote-references=superscript --halt=warning --stylesheet=../../default.css doc/ja/tutorials/centralized_workflow.txt "doc/ja/tutorials/centralized_workflow.html"
python tools/rst2html.py --link-stylesheet --footnote-references=superscript --halt=warning --stylesheet=../../default.css doc/en/mini-tutorial/index.txt "doc/en/mini-tutorial/index.html"
python tools/rst2html.py --link-stylesheet --footnote-references=superscript --halt=warning --stylesheet=../../default.css doc/ja/mini-tutorial/index.txt "doc/ja/mini-tutorial/index.html"
python tools/rst2html.py --link-stylesheet --footnote-references=superscript --halt=warning --stylesheet=../../default.css doc/ru/mini-tutorial/index.txt "doc/ru/mini-tutorial/index.html"
python tools/rst2html.py --link-stylesheet --footnote-references=superscript --halt=warning --stylesheet=../../default.css doc/es/mini-tutorial/index.txt "doc/es/mini-tutorial/index.html"
python tools/rst2html.py --link-stylesheet --footnote-references=superscript --halt=warning --stylesheet=../../default.css doc/en/user-guide/index-plain.txt doc/en/user-guide/index-plain.html
python tools/rst2html.py --link-stylesheet --footnote-references=superscript --halt=warning --stylesheet=../../default.css doc/ja/user-guide/index-plain.txt "doc/ja/user-guide/index-plain.html"
python tools/rst2html.py --link-stylesheet --footnote-references=superscript --ha...

Vincent Ladeuil (vila) wrote :

08:32:24 O: ======================================================================
08:32:24 O: FAIL: bzrlib.tests.test_smart_transport.TestSmartTCPServer.test_graceful_shutdown_waits_for_clients_to_stop
08:32:24 O: ----------------------------------------------------------------------
08:32:24 O: Traceback (most recent call last):
08:32:24 O: testtools.testresult.real._StringException: log: {{{
08:32:24 O: INFO Requested to stop gracefully
08:32:24 O: 242.660 Stopping SmartServerSocketStreamMedium(client=('127.0.0.1', 37227))
08:32:24 O: INFO Requested to stop gracefully
08:32:24 O: }}}
08:32:24 O:
08:32:24 O: Traceback (most recent call last):
08:32:24 O: File "/home/ubuntu/work/bzrlib/tests/test_smart_transport.py", line 1466, in test_graceful_shutdown_waits_for_clients_to_stop
08:32:24 O: """, flags=doctest.ELLIPSIS|doctest.REPORT_UDIFF))
08:32:24 O: File "/usr/lib/python2.7/dist-packages/testtools/testcase.py", line 435, in assertThat
08:32:24 O: raise mismatch_error
08:32:48 O: testtools.matchers._impl.MismatchError: Expected:
08:32:48 O: INFO Requested to stop gracefully
08:32:48 O: ... Stopping SmartServerSocketStreamMedium(client=('127.0.0.1', ...
08:32:48 O: INFO Waiting for 1 client(s) to finish
08:32:48 O: Got:
08:32:48 O: INFO Requested to stop gracefully
08:32:48 O: 242.660 Stopping SmartServerSocketStreamMedium(client=('127.0.0.1', 37227))
08:32:48 O:

Known transient failure for which a debian patch is carried.

Now that we can reproduce (previous CI never showed this) this may be worth fixing.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'bzrlib/lazy_regex.py'
2--- bzrlib/lazy_regex.py 2011-12-19 13:23:58 +0000
3+++ bzrlib/lazy_regex.py 2017-01-15 20:40:52 +0000
4@@ -131,3 +131,13 @@
5 raise AssertionError(
6 "re.compile has already been overridden as lazy_compile, but this would" \
7 " cause infinite recursion")
8+
9+
10+# re.finditer get confused if it receives a LazyRegex
11+if getattr(re, 'finditer', None is not None):
12+ def finditer_public(pattern, string, flags=0):
13+ if isinstance(pattern, LazyRegex):
14+ return pattern.finditer(string)
15+ else:
16+ return _real_re_compile(pattern, flags).finditer(string)
17+re.finditer = finditer_public
18
19=== modified file 'bzrlib/tests/test_http.py'
20--- bzrlib/tests/test_http.py 2017-01-15 16:30:55 +0000
21+++ bzrlib/tests/test_http.py 2017-01-15 20:40:52 +0000
22@@ -1,4 +1,4 @@
23-# Copyright (C) 2005-2012, 2015, 2016 Canonical Ltd
24+# Copyright (C) 2005-2012, 2015, 2016, 2017 Canonical Ltd
25 #
26 # This program is free software; you can redistribute it and/or modify
27 # it under the terms of the GNU General Public License as published by
28
29=== modified file 'bzrlib/transport/http/_pycurl.py'
30--- bzrlib/transport/http/_pycurl.py 2017-01-15 16:30:55 +0000
31+++ bzrlib/transport/http/_pycurl.py 2017-01-15 20:40:52 +0000
32@@ -1,4 +1,4 @@
33-# Copyright (C) 2006-2010 Canonical Ltd
34+# Copyright (C) 2006-2011, 2017 Canonical Ltd
35 #
36 # This program is free software; you can redistribute it and/or modify
37 # it under the terms of the GNU General Public License as published by
38
39=== modified file 'doc/en/release-notes/bzr-2.7.txt'
40--- doc/en/release-notes/bzr-2.7.txt 2017-01-15 18:54:42 +0000
41+++ doc/en/release-notes/bzr-2.7.txt 2017-01-15 20:40:52 +0000
42@@ -30,6 +30,9 @@
43 Bug Fixes
44 *********
45
46+* Complete monkey-patching of re.finditer or LazyRegexps leak.
47+ (Vincent Ladeuil, #1644003)
48+
49 * Cope with paramiko making argument to SFTPFile.prefetch() mandatory.
50 (Jelmer Vernooij, #1579093)
51

Subscribers

People subscribed via source and target branches