Re: [Python-Dev] New work-in-progress bisection tool for the Python test suite (in regrtest)

2017-07-04 Thread Victor Stinner
On Python 2, the addition of Lib/test/bisect.py caused conflict with
Lib/bisect.py when running the Python test suite :-( I chose to rename
Lib/test/bisect.py to Lib/test/bisectcmd.py to reduce changes caused
by this new debug tool. So only in Python 2.7, you have to run:

./python -m test.bisectcmd ...

instead of

./python -m tes.bisect ...

See http://bugs.python.org/issue30843 for more information.

Victor

2017-06-16 18:05 GMT+02:00 Victor Stinner :
> Hi,
>
> Last weeks, I worked on a new tool to bisect failing tests because
> it's painful to bisect manually reference leaks (I remove as much code
> as possible until the code is small enough to be reviewable manually).
>
> See the bisect_test.py script attached to this issue:
> http://bugs.python.org/issue29512
>
> With the help of Louie Lu, I added new --list-cases option to "python
> -m test", so you can now list all test cases and write it into a text
> file:
>
>./python -m test --list-cases test_os > tests
>
> I also added a new --matchfile option, to filter tests using a text
> file which contains one pattern per line:
>
>./python -m test --matchfile=tests test_os
>
> fnmatch is used to match test names, so "*" joker character can be
> used in test names.
>
>
> My bisection tool takes a text file with the --matchfile format (one
> pattern per line) and creates a random subset of tests with half of
> the tests. If tests still fail, use the subset. Otherwise, create a
> new random subset. Loop until the subset contains a single test
> (configurable threshold, -n command line option).
>
> The long term plan is to integrate the bisection feature directly into 
> regrtest.
>
>
>
> Right now, my script is hardcoded to bisect reference leak bugs, but
> it should be easy to modify it to bisect other test issues like test
> creating files without removing it ("ENV_CHANGED" failure in
> regrtest).
>
> For example, a core file is dumped when running test_subprocess on
> FreeBSD buildbots:
>
>http://bugs.python.org/issue30448
>
> But I'm unable to reproduce the issue on my FreeBSD. It would be nice
> to be able to automate the bisection on the buildbot directly.
>
>
> --list-cases and --matchfile options are now available in 2.7, 3.5,
> 3.6 and master (3.7) branches.
>
> TODO: doctest tests are only partially supported, see:
>
>   http://bugs.python.org/issue30683
>
> Victor
___
Python-Dev mailing list
[email protected]
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] New work-in-progress bisection tool for the Python test suite (in regrtest)

2017-07-04 Thread Nick Coghlan
On 4 July 2017 at 19:55, Victor Stinner  wrote:
> On Python 2, the addition of Lib/test/bisect.py caused conflict with
> Lib/bisect.py when running the Python test suite :-( I chose to rename
> Lib/test/bisect.py to Lib/test/bisectcmd.py to reduce changes caused
> by this new debug tool. So only in Python 2.7, you have to run:
>
> ./python -m test.bisectcmd ...

I know it's longer, but perhaps it would make sense to put the
bisection helper under "python -m test.support.bisect" in both Python
2 & 3?

Even in Python 3 "test.bisect" looks a bit like the test suite for the
bisect module to me - you have to "just know" that the latter actually
lives at "test.test_bisect".

Cheers,
Nick.

-- 
Nick Coghlan   |   [email protected]   |   Brisbane, Australia
___
Python-Dev mailing list
[email protected]
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] New work-in-progress bisection tool for the Python test suite (in regrtest)

2017-07-04 Thread Victor Stinner
2017-07-04 12:52 GMT+02:00 Nick Coghlan :
> I know it's longer, but perhaps it would make sense to put the
> bisection helper under "python -m test.support.bisect" in both Python
> 2 & 3?

For me, test.support is a toolkit to *write* tests, not really to run tests.

I don't really care where my bisect tool lives. Serhiy proposed
test.bisect, I like because it's short and easy to remind.

Technically it is possible to get test.bisect on Python 2, it just
requires to modify 4 .py files which import Lib/bisect.py to add "from
__future__ import absolute_import":

Lib/urllib2.py:import bisect
Lib/mhlib.py:from bisect import bisect
Lib/test/test_bisect.py:import bisect as py_bisect
Lib/multiprocessing/heap.py:import bisect

I modified Lib/test/test_bisect.py, but I missed these other ones in
my first commit. And then I got a failure in multiprocessing.

I chose the conservative approach: rename the new Lib/test/bisect.py file.

Do you prefer to get test.bisect, and so modify the 4 files to add
"from __future__ import absolute_import"?

I didn't recall the subtle details of "relative import" in Python 2.
Since I'm now used to Python 3, the Python 2 behaviour now really
looks weird to me :-)

Victor
___
Python-Dev mailing list
[email protected]
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] New work-in-progress bisection tool for the Python test suite (in regrtest)

2017-07-04 Thread Lele Gaifax
Nick Coghlan  writes:

> On 4 July 2017 at 19:55, Victor Stinner  wrote:
>> On Python 2, the addition of Lib/test/bisect.py caused conflict with
>> Lib/bisect.py when running the Python test suite :-( I chose to rename
>> Lib/test/bisect.py to Lib/test/bisectcmd.py to reduce changes caused
>> by this new debug tool. So only in Python 2.7, you have to run:
>>
>> ./python -m test.bisectcmd ...
>
> I know it's longer, but perhaps it would make sense to put the
> bisection helper under "python -m test.support.bisect" in both Python
> 2 & 3?

Or test.tool.bisect, similar to json.tool.

ciao, lele.
-- 
nickname: Lele Gaifax | Quando vivrò di quello che ho pensato ieri
real: Emanuele Gaifas | comincerò ad aver paura di chi mi copia.
[email protected]  | -- Fortunato Depero, 1929.

___
Python-Dev mailing list
[email protected]
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] New work-in-progress bisection tool for the Python test suite (in regrtest)

2017-07-04 Thread Nick Coghlan
On 4 July 2017 at 21:03, Victor Stinner  wrote:
> 2017-07-04 12:52 GMT+02:00 Nick Coghlan :
>> I know it's longer, but perhaps it would make sense to put the
>> bisection helper under "python -m test.support.bisect" in both Python
>> 2 & 3?
>
> For me, test.support is a toolkit to *write* tests, not really to run tests.
>
> I don't really care where my bisect tool lives. Serhiy proposed
> test.bisect, I like because it's short and easy to remind.
>
> Technically it is possible to get test.bisect on Python 2, it just
> requires to modify 4 .py files which import Lib/bisect.py to add "from
> __future__ import absolute_import":
>
> Lib/urllib2.py:import bisect
> Lib/mhlib.py:from bisect import bisect
> Lib/test/test_bisect.py:import bisect as py_bisect
> Lib/multiprocessing/heap.py:import bisect

That doesn't sound right, as implicit relative imports in Python 2 are
relative to the *package* (they're akin to writing "from . import
name").

That means if test.bisect is shadowing the top level bisect module
when backported, it suggests that the test.regrtest directory is
ending up on sys.path for the affected test run (e.g. because the
tests were run as "python Lib/test/regrtest.py" rather than via the -m
switch).

Checking test.regrtest in 2.7, it looks to me like it's missing the
stanza added to Py3 that makes sure "Lib/test/" isn't present on
sys.path - if you add a similar operation to Py2.7, I'd expect the
test.bisect name for the command to work there as well.

Cheers,
Nick.

P.S. As far the multiprocessing failure you saw goes, my guess would
be that the 2.7 version actually is relying on implicit relative
imports to find peer modules, and would need some "from . import ..."
adjustments to handle "from __future__ import absolute_import" at the
top of the file. However, as noted above, I don't think that's
actually what's happening - I think the "Lib/test/" directory is still
sometimes ending up on sys.path while running the tests in 2.7.

-- 
Nick Coghlan   |   [email protected]   |   Brisbane, Australia
___
Python-Dev mailing list
[email protected]
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] New work-in-progress bisection tool for the Python test suite (in regrtest)

2017-07-04 Thread Victor Stinner
2017-07-04 13:22 GMT+02:00 Nick Coghlan :
> That means if test.bisect is shadowing the top level bisect module
> when backported, it suggests that the test.regrtest directory is
> ending up on sys.path for the affected test run (e.g. because the
> tests were run as "python Lib/test/regrtest.py" rather than via the -m
> switch).

I don't think that Lib/test/ is in sys.path. It's more subtle than
test. When you run "./python -m test test_bisect",
Lib/test/regrtest.py imports "test.test_bisect", and so test_bisect is
imported with __package__=['test'].

With test_bisect.__package__=['test'], "import bisect" in
Lib/test/test_bisect.py imports Lib/test/bisect.py.

The question is more when Lib/multiprocessing/heap.py got
Lib/test/bisect.py instead of Lib/bisect.py. I didn't dig into this
issue. The Python 2 import machinery blows my mind :-)

Victor
___
Python-Dev mailing list
[email protected]
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] Star the CPython GitHub project if you like Python!

2017-07-04 Thread Victor Stinner
4 days later, we got +2,389 new stars, thank you! (8,539 => 10,928)

Python moved from the 11th place to the 9th, before Elixir and Julia.

Python is still behind Ruby (12,511) and PHP (12,318), but it's
already much better than before!

Victor

2017-06-30 15:59 GMT+02:00 Victor Stinner :
> Hi,
>
> GitHub has a showcase page of hosted programming languages:
>
>https://github.com/showcases/programming-languages
>
> Python is only #11 with 8,539 stars, behind PHP and Ruby!
>
> Hey, you should "like" ("star"?) the CPython project if you like Python!
>
>https://github.com/python/cpython/
>Click on "Star" at the top right.
>
> Thank you!
> Victor
___
Python-Dev mailing list
[email protected]
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] Buildbot report (almost July)

2017-07-04 Thread Victor Stinner
2017-06-29 17:09 GMT+02:00 Victor Stinner :
> Correct me if I'm wrong, but, for the first time, *all reference
> leaks* have been fixed on *all branches* (2.7, 3.5, 3.6 and master),
> on *Linux and Windows*! Before, we mostly focused on the master branch
> (called "default" in Mercurial) on Linux.
>
> I also started to fix a few "memory block" leaks, most (or all?) of
> them should also be fixed (on all branches, on Linux and Windows).

The "AMD64 Windows8.1 Refleaks" now pass on 2.7, 3.5, 3.6 and master
branches. I finished to backport my changes to fix false alarms in
hunting reference and memory leaks.

The next introduced reference leak should now send an email to the
buildbot-status mailing list ;-)

Victor
___
Python-Dev mailing list
[email protected]
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] Star the CPython GitHub project if you like Python!

2017-07-04 Thread Ben Hoyt
Nice!

I also posted it on reddit.com/r/Python, where it got a bit of traction:
https://www.reddit.com/r/Python/comments/6kg4w0/cpython_recently_moved_to_github_star_the_project/

-Ben

On Tue, Jul 4, 2017 at 9:15 AM, Victor Stinner 
wrote:

> 4 days later, we got +2,389 new stars, thank you! (8,539 => 10,928)
>
> Python moved from the 11th place to the 9th, before Elixir and Julia.
>
> Python is still behind Ruby (12,511) and PHP (12,318), but it's
> already much better than before!
>
> Victor
>
> 2017-06-30 15:59 GMT+02:00 Victor Stinner :
> > Hi,
> >
> > GitHub has a showcase page of hosted programming languages:
> >
> >https://github.com/showcases/programming-languages
> >
> > Python is only #11 with 8,539 stars, behind PHP and Ruby!
> >
> > Hey, you should "like" ("star"?) the CPython project if you like Python!
> >
> >https://github.com/python/cpython/
> >Click on "Star" at the top right.
> >
> > Thank you!
> > Victor
> ___
> Python-Dev mailing list
> [email protected]
> https://mail.python.org/mailman/listinfo/python-dev
> Unsubscribe: https://mail.python.org/mailman/options/python-dev/
> benhoyt%40gmail.com
>
___
Python-Dev mailing list
[email protected]
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] New work-in-progress bisection tool for the Python test suite (in regrtest)

2017-07-04 Thread Nick Coghlan
On 4 July 2017 at 22:10, Victor Stinner  wrote:
> 2017-07-04 13:22 GMT+02:00 Nick Coghlan :
>> That means if test.bisect is shadowing the top level bisect module
>> when backported, it suggests that the test.regrtest directory is
>> ending up on sys.path for the affected test run (e.g. because the
>> tests were run as "python Lib/test/regrtest.py" rather than via the -m
>> switch).
>
> I don't think that Lib/test/ is in sys.path. It's more subtle than
> test. When you run "./python -m test test_bisect",
> Lib/test/regrtest.py imports "test.test_bisect", and so test_bisect is
> imported with __package__=['test'].
>
> With test_bisect.__package__=['test'], "import bisect" in
> Lib/test/test_bisect.py imports Lib/test/bisect.py.

Right, for test_bisect specifically, the implicit relative import
problem applies, and "from __future__ import absolute_import" is the
relevant fix.

That concern just doesn't apply to the *stdlib* modules doing a normal
top-level "import bisect".

> The question is more when Lib/multiprocessing/heap.py got
> Lib/test/bisect.py instead of Lib/bisect.py. I didn't dig into this
> issue. The Python 2 import machinery blows my mind :-)

*This* is the case that I think is due to "Lib/test" being on sys.path
when the tests are run:

```
$ ./python -i Lib/test/regrtest.py --help
[snip output]
>>> import sys
>>> sys.path[0]
'/home/ncoghlan/devel/py27/Lib/test'
```

Using test_urllib2 as the example:

```
$ touch Lib/test/bisect.py
$ ./python -m test.regrtest test_urllib2
Run tests sequentially
0:00:00 [1/1] test_urllib2
1 test OK.

Total duration: 800 ms
Tests result: SUCCESS
$ ./python Lib/test/regrtest.py test_urllib2
Run tests sequentially
0:00:00 [1/1] test_urllib2
Warning -- os.environ was modified by test_urllib2
[snip output]
test test_urllib2 failed -- multiple errors occurred; run in verbose
mode for details
1 test failed:
test_urllib2

Total duration: 107 ms
Tests result: FAILURE
```

Cheers,
Nick.

-- 
Nick Coghlan   |   [email protected]   |   Brisbane, Australia
___
Python-Dev mailing list
[email protected]
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] New work-in-progress bisection tool for the Python test suite (in regrtest)

2017-07-04 Thread Victor Stinner
2017-07-04 16:27 GMT+02:00 Nick Coghlan :
> That concern just doesn't apply to the *stdlib* modules doing a normal
> top-level "import bisect".

Hum, ok. I created a PR which removes '' and Lib/test/ from sys.path,
and rename again test.bisectcmd to test.bisect.

Would you mind to review it?
https://github.com/python/cpython/pull/2567

Victor
___
Python-Dev mailing list
[email protected]
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] Star the CPython GitHub project if you like Python!

2017-07-04 Thread Chris Jerdonek
Great work, Victor! It seems like this would be an easy thing to
mention at the beginning of conference talks and meetup presentations,
and also something to ask coworkers if you work at a company that uses
Python (e.g. on workplace Slack channels, etc).

--Chris



On Tue, Jul 4, 2017 at 6:15 AM, Victor Stinner  wrote:
> 4 days later, we got +2,389 new stars, thank you! (8,539 => 10,928)
>
> Python moved from the 11th place to the 9th, before Elixir and Julia.
>
> Python is still behind Ruby (12,511) and PHP (12,318), but it's
> already much better than before!
>
> Victor
>
> 2017-06-30 15:59 GMT+02:00 Victor Stinner :
>> Hi,
>>
>> GitHub has a showcase page of hosted programming languages:
>>
>>https://github.com/showcases/programming-languages
>>
>> Python is only #11 with 8,539 stars, behind PHP and Ruby!
>>
>> Hey, you should "like" ("star"?) the CPython project if you like Python!
>>
>>https://github.com/python/cpython/
>>Click on "Star" at the top right.
>>
>> Thank you!
>> Victor
> ___
> Python-Dev mailing list
> [email protected]
> https://mail.python.org/mailman/listinfo/python-dev
> Unsubscribe: 
> https://mail.python.org/mailman/options/python-dev/chris.jerdonek%40gmail.com
___
Python-Dev mailing list
[email protected]
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] Star the CPython GitHub project if you like Python!

2017-07-04 Thread Terry Reedy

On 7/4/2017 10:22 AM, Ben Hoyt wrote:

Nice!

I also posted it on reddit.com/r/Python , 
where it got a bit of traction: 
https://www.reddit.com/r/Python/comments/6kg4w0/cpython_recently_moved_to_github_star_the_project/


I just posted on python-list.


--
Terry Jan Reedy

___
Python-Dev mailing list
[email protected]
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com