Re: [Python-Dev] why _PyGen_Finalize(gen) propagates close() to _PyGen_yf() ?

2017-03-31 Thread Martin Panter
On 31 March 2017 at 05:22, Nathaniel Smith  wrote:
>>> On Mon, Mar 20, 2017 at 11:30 AM, Oleg Nesterov  wrote:
>>> > [Aborting "yield" in a "for" loop leaves a sub-generator open, but 
>>> > aborting "yield from" cleans up the sub-generator]
>
> In any case the short answer to your original question is that PEP 342
> says that generator finalization calls the generator's close() method,
> which throws a GeneratorExit into the generator, and PEP 380 says that
> as a special case, when a GeneratorExit is thrown into a yield from,
> then this is propagated by calling .close() on the yielded-from
> iterator (if such a method exists) and then re-raised in the original
> generator.

I think the Python documentation could be improved regarding this.
When I wrote the documentation for coroutine methods
,
I included details about the "close" and "throw" methods delegating to
inner iterators. I thought I was going to propose similar updates to
the generator documentation
,
but it seems I never got around to it. (In the mean time,

was added, to which this may also be relevant, but that is too
complicated for me.)

There is a parallel with another annoyance with Python generator
cleanup: . There are two ways you
can require generators to be used. With a simple generator, you can
partially iterate it and then throw it away without any special
cleaning up. But with more complex generators that "own" expensive
resources, it would be nice to produce a ResourceWarning I you forget
to clean them up.

With the "for / yield" case, the sub-generator is not cleaned up, so
if a resource-intensive sub-generator has to be cleaned up you have to
do it yourself. With "yield from", the cleanup is implicit and
unavoidable, which means you can't use it if you want keep the
sub-generator alive for later. But the automatic cleanup may be useful
in other cases.
___
Python-Dev mailing list
Python-Dev@python.org
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] Questions on the CPython Git master branch: how to exclude commits of 3.x branches?

2017-03-31 Thread Victor Stinner
2017-03-31 18:36 GMT+02:00 Ryan Gonzalez :
> I think you want:
>
> git log --no-merges --first-parent

Oh, I mised --first-parent: it seems like it fixed my issue, thanks!

But --no-merges is not what I want. I want to see merge commits which
are only in the master branch.

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


Re: [Python-Dev] Questions on the CPython Git master branch: how to exclude commits of 3.x branches?

2017-03-31 Thread Ryan Gonzalez
On Mar 31, 2017 10:48 AM, "Victor Stinner"  wrote:

Hi,

The CPython repository was converted from Mercurial to Git. Before
with Mercurial, we used extensively merges. For example, a bug was
fixed in branche 3.5, merged into 3.6 and then merged into master.
With the conversion to Git, some merges commit are removed, some
others are kept.

My question is how to list commits which are only part of the "master"
branch, as "hg log default" in Mercurial. "git log origin/master"
lists also commits coming from 3.x branches and their merges. The
problem is that if you pick a commit from a different branch, you
compile Python 3.x, instead of compiling Python for the master branch.


I think you want:

git log --no-merges --first-parent


Right now, my need is to find the first commit in the "master" branch
after a specific date. For example, find the first commit after
2016-01-01 00:00.

Naive solution:
---
$ git log --since="2016-01-01 00:00" origin/master --reverse|head

commit 75e3630c6071819d3674d956ea754ccb4fed5271
Author: Benjamin Peterson 
Date:   Fri Jan 1 10:23:45 2016 -0600

2016 will be another year of writing copyrighted code
---

If you compile the revision 75e3630c6071819d3674d956ea754ccb4fed5271,
you get Python 3.3:
---
$ grep PY_M Include/patchlevel.h
#define PY_MAJOR_VERSION3
#define PY_MINOR_VERSION3
#define PY_MICRO_VERSION6
---

But if you exclude manually commits which are in branches 3.x, you get
the commit 71db903563906cedfc098418659d1200043cd14c which gives a
different Python version:
---
$ grep PY_M Include/patchlevel.h
#define PY_MAJOR_VERSION3
#define PY_MINOR_VERSION6
#define PY_MICRO_VERSION0
---

In fact, I wrote a tool to manually exclude commits of branches 3.x:

https://github.com/haypo/misc/blob/master/misc/find_git_revisions_by_date.py

But it's super slow! Are there builtin options to only show Git
commits which are in master branch but not in 3.x branches?

Asked differently: how can I only see two commits on the following
range? What are [options]?

git rev-list 288cb25f1a208fe09b9e06ba479e11c1157da4b5..
71db903563906cedfc098418659d1200043cd14c
[options]

Commits after 2016-01-01:
---
$ git checkout 71db903563906cedfc098418659d1200043cd14c
$ git log --graph
*   commit 71db903563906cedfc098418659d1200043cd14c
|\  Merge: 288cb25 4c70293
| | Author: Benjamin Peterson 
| | Date:   Fri Jan 1 10:25:22 2016 -0600
| |
| | merge 3.5
| |
| *   commit 4c70293755ce8ea0adc5b224c714da2b7625d232
| |\  Merge: 42bf8fc e8c2a95
| | | Author: Benjamin Peterson 
| | | Date:   Fri Jan 1 10:25:12 2016 -0600
| | |
| | | merge 3.4
| | |
| | *   commit e8c2a957c87980a1fd79c39597d40e5c5aeb7048
| | |\  Merge: 52d6c2c 75e3630
| | | | Author: Benjamin Peterson 
| | | | Date:   Fri Jan 1 10:24:21 2016 -0600
| | | |
| | | | merge 3.3
| | | |
| | | * commit 75e3630c6071819d3674d956ea754ccb4fed5271
| | | | Author: Benjamin Peterson 
| | | | Date:   Fri Jan 1 10:23:45 2016 -0600
| | | |
| | | | 2016 will be another year of writing copyrighted code
| | | |
* | | |   commit 288cb25f1a208fe09b9e06ba479e11c1157da4b5
|\ \ \ \  Merge: 58f8833 42bf8fc
| |/ / /  Author: Serhiy Storchaka 
| | | |   Date:   Wed Dec 30 21:41:53 2015 +0200
| | | |
| | | |   Issue #25961: Disallowed null characters in the type name.
| | | |   Simplified testing for null characters in __name__ setter.
| | | |
---

Victor
___
Python-Dev mailing list
Python-Dev@python.org
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: https://mail.python.org/mailman/options/python-dev/
rymg19%40gmail.com



--
Ryan (ライアン)
Yoko Shimomura > ryo (supercell/EGOIST) > Hiroyuki Sawano >> everyone else
http://refi64.com
___
Python-Dev mailing list
Python-Dev@python.org
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


[Python-Dev] Summary of Python tracker Issues

2017-03-31 Thread Python tracker

ACTIVITY SUMMARY (2017-03-24 - 2017-03-31)
Python tracker at http://bugs.python.org/

To view or respond to any of the issues listed below, click on the issue.
Do NOT respond to this message.

Issues counts and deltas:
  open5855 ( -8)
  closed 35854 (+65)
  total  41709 (+57)

Open issues with patches: 2419 


Issues opened (36)
==

#11913: sdist refuses README.rst
http://bugs.python.org/issue11913  reopened by pitrou

#29880: python3.6 install readline ,and then cpython exit
http://bugs.python.org/issue29880  reopened by pz

#29897: itertools.chain behaves strangly when copied with copy.copy
http://bugs.python.org/issue29897  opened by MSeifert

#29898: PYTHONLEGACYWINDOWSIOENCODING isn't implemented
http://bugs.python.org/issue29898  opened by eryksun

#29899: zlib missing when --enable--optimizations option appended
http://bugs.python.org/issue29899  opened by kyren 原子喵

#29902: copy breaks staticmethod
http://bugs.python.org/issue29902  opened by dangyogi

#29903: struct.Struct Addition
http://bugs.python.org/issue29903  opened by palaviv

#29905: TypeErrors not formatting values correctly
http://bugs.python.org/issue29905  opened by Jim Fasarakis-Hilliard

#29906: Add callback parameter to concurrent.futures.Executor.map
http://bugs.python.org/issue29906  opened by aron.bordin

#29909: types.coroutine monkey patches original function
http://bugs.python.org/issue29909  opened by Omnifarious

#29910: Ctrl-D eats a character on IDLE
http://bugs.python.org/issue29910  opened by serhiy.storchaka

#29911: Uninstall command line in Windows registry does not uninstall
http://bugs.python.org/issue29911  opened by Christian.Ullrich

#29914: Incorrect signatures of object.__reduce__() and object.__reduc
http://bugs.python.org/issue29914  opened by serhiy.storchaka

#29915: Drop Mac OS X Tiger support in Python 3.7?
http://bugs.python.org/issue29915  opened by haypo

#29916: No explicit documentation for PyGetSetDef and getter and sette
http://bugs.python.org/issue29916  opened by MSeifert

#29920: Document cgitb.text and cgitb.html
http://bugs.python.org/issue29920  opened by xmorel

#29922: error message when __aexit__ is not async
http://bugs.python.org/issue29922  opened by Tadhg McDonald-Jensen

#29925: test_uuid fails on OS X Tiger
http://bugs.python.org/issue29925  opened by haypo

#29926: time.sleep ignores _thread.interrupt_main()
http://bugs.python.org/issue29926  opened by Mark

#29929: Eliminate implicit __main__ relative imports
http://bugs.python.org/issue29929  opened by ncoghlan

#29930: Waiting for asyncio.StreamWriter.drain() twice in parallel rai
http://bugs.python.org/issue29930  opened by metathink

#29931: ipaddress.ip_interface __lt__ check seems to be broken
http://bugs.python.org/issue29931  opened by Sanjay

#29933: asyncio: set_write_buffer_limits() doc doesn't specify unit of
http://bugs.python.org/issue29933  opened by haypo

#29937: argparse mutex group should allow mandatory parameters
http://bugs.python.org/issue29937  opened by Mark Nolan

#29939: Compiler warning in _ctypes_test.c
http://bugs.python.org/issue29939  opened by serhiy.storchaka

#29940: Add follow_wrapped=True option to help()
http://bugs.python.org/issue29940  opened by samwyse

#29941: Confusion between asserts and Py_DEBUG
http://bugs.python.org/issue29941  opened by Thomas Wouters

#29943: PySlice_GetIndicesEx change broke ABI in 3.5 and 3.6 branches
http://bugs.python.org/issue29943  opened by njs

#29944: Argumentless super() calls do not work in classes constructed 
http://bugs.python.org/issue29944  opened by assume_away

#29947: In SocketServer, why not passing a factory instance for the Re
http://bugs.python.org/issue29947  opened by dominic108

#29948: DeprecationWarning when parse ElementTree with a doctype in 2.
http://bugs.python.org/issue29948  opened by serhiy.storchaka

#29949: sizeof set after set_merge() is doubled from 3.5
http://bugs.python.org/issue29949  opened by inada.naoki

#29950: Rename SlotWrapperType to WrapperDescriptorType
http://bugs.python.org/issue29950  opened by Jim Fasarakis-Hilliard

#29951: PyArg_ParseTupleAndKeywords exception messages containing "fun
http://bugs.python.org/issue29951  opened by MSeifert

#29952: "keys and values" is preferred to "keys and elements" for name
http://bugs.python.org/issue29952  opened by cocoatomo

#29953: Memory leak in the replace() method of datetime and time objec
http://bugs.python.org/issue29953  opened by serhiy.storchaka



Most recent 15 issues with no replies (15)
==

#29953: Memory leak in the replace() method of datetime and time objec
http://bugs.python.org/issue29953

#29950: Rename SlotWrapperType to WrapperDescriptorType
http://bugs.python.org/issue29950

#29948: DeprecationWarning when parse ElementTree with a doctype in 2.
http://bugs.python.org/issue29948

#29940: Add follow_wrapped=True option to help()
http://bugs.python.org/issue29940

#29937: argparse 

Re: [Python-Dev] Questions on the CPython Git master branch: how to exclude commits of 3.x branches?

2017-03-31 Thread Mariatta Wijaya
Can you try

git log master ^3.6

I think it will give what's on master and not in 3.6



On Mar 31, 2017 8:47 AM, "Victor Stinner"  wrote:

> Hi,
>
> The CPython repository was converted from Mercurial to Git. Before
> with Mercurial, we used extensively merges. For example, a bug was
> fixed in branche 3.5, merged into 3.6 and then merged into master.
> With the conversion to Git, some merges commit are removed, some
> others are kept.
>
> My question is how to list commits which are only part of the "master"
> branch, as "hg log default" in Mercurial. "git log origin/master"
> lists also commits coming from 3.x branches and their merges. The
> problem is that if you pick a commit from a different branch, you
> compile Python 3.x, instead of compiling Python for the master branch.
>
> Right now, my need is to find the first commit in the "master" branch
> after a specific date. For example, find the first commit after
> 2016-01-01 00:00.
>
> Naive solution:
> ---
> $ git log --since="2016-01-01 00:00" origin/master --reverse|head
> commit 75e3630c6071819d3674d956ea754ccb4fed5271
> Author: Benjamin Peterson 
> Date:   Fri Jan 1 10:23:45 2016 -0600
>
> 2016 will be another year of writing copyrighted code
> ---
>
> If you compile the revision 75e3630c6071819d3674d956ea754ccb4fed5271,
> you get Python 3.3:
> ---
> $ grep PY_M Include/patchlevel.h
> #define PY_MAJOR_VERSION3
> #define PY_MINOR_VERSION3
> #define PY_MICRO_VERSION6
> ---
>
> But if you exclude manually commits which are in branches 3.x, you get
> the commit 71db903563906cedfc098418659d1200043cd14c which gives a
> different Python version:
> ---
> $ grep PY_M Include/patchlevel.h
> #define PY_MAJOR_VERSION3
> #define PY_MINOR_VERSION6
> #define PY_MICRO_VERSION0
> ---
>
> In fact, I wrote a tool to manually exclude commits of branches 3.x:
>
> https://github.com/haypo/misc/blob/master/misc/find_git_
> revisions_by_date.py
>
> But it's super slow! Are there builtin options to only show Git
> commits which are in master branch but not in 3.x branches?
>
> Asked differently: how can I only see two commits on the following
> range? What are [options]?
>
> git rev-list 288cb25f1a208fe09b9e06ba479e11c1157da4b5..
> 71db903563906cedfc098418659d1200043cd14c
> [options]
>
> Commits after 2016-01-01:
> ---
> $ git checkout 71db903563906cedfc098418659d1200043cd14c
> $ git log --graph
> *   commit 71db903563906cedfc098418659d1200043cd14c
> |\  Merge: 288cb25 4c70293
> | | Author: Benjamin Peterson 
> | | Date:   Fri Jan 1 10:25:22 2016 -0600
> | |
> | | merge 3.5
> | |
> | *   commit 4c70293755ce8ea0adc5b224c714da2b7625d232
> | |\  Merge: 42bf8fc e8c2a95
> | | | Author: Benjamin Peterson 
> | | | Date:   Fri Jan 1 10:25:12 2016 -0600
> | | |
> | | | merge 3.4
> | | |
> | | *   commit e8c2a957c87980a1fd79c39597d40e5c5aeb7048
> | | |\  Merge: 52d6c2c 75e3630
> | | | | Author: Benjamin Peterson 
> | | | | Date:   Fri Jan 1 10:24:21 2016 -0600
> | | | |
> | | | | merge 3.3
> | | | |
> | | | * commit 75e3630c6071819d3674d956ea754ccb4fed5271
> | | | | Author: Benjamin Peterson 
> | | | | Date:   Fri Jan 1 10:23:45 2016 -0600
> | | | |
> | | | | 2016 will be another year of writing copyrighted code
> | | | |
> * | | |   commit 288cb25f1a208fe09b9e06ba479e11c1157da4b5
> |\ \ \ \  Merge: 58f8833 42bf8fc
> | |/ / /  Author: Serhiy Storchaka 
> | | | |   Date:   Wed Dec 30 21:41:53 2015 +0200
> | | | |
> | | | |   Issue #25961: Disallowed null characters in the type name.
> | | | |   Simplified testing for null characters in __name__ setter.
> | | | |
> ---
>
> Victor
> ___
> Python-Dev mailing list
> Python-Dev@python.org
> https://mail.python.org/mailman/listinfo/python-dev
> Unsubscribe: https://mail.python.org/mailman/options/python-dev/
> mariatta.wijaya%40gmail.com
>
___
Python-Dev mailing list
Python-Dev@python.org
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


[Python-Dev] Questions on the CPython Git master branch: how to exclude commits of 3.x branches?

2017-03-31 Thread Victor Stinner
Hi,

The CPython repository was converted from Mercurial to Git. Before
with Mercurial, we used extensively merges. For example, a bug was
fixed in branche 3.5, merged into 3.6 and then merged into master.
With the conversion to Git, some merges commit are removed, some
others are kept.

My question is how to list commits which are only part of the "master"
branch, as "hg log default" in Mercurial. "git log origin/master"
lists also commits coming from 3.x branches and their merges. The
problem is that if you pick a commit from a different branch, you
compile Python 3.x, instead of compiling Python for the master branch.

Right now, my need is to find the first commit in the "master" branch
after a specific date. For example, find the first commit after
2016-01-01 00:00.

Naive solution:
---
$ git log --since="2016-01-01 00:00" origin/master --reverse|head
commit 75e3630c6071819d3674d956ea754ccb4fed5271
Author: Benjamin Peterson 
Date:   Fri Jan 1 10:23:45 2016 -0600

2016 will be another year of writing copyrighted code
---

If you compile the revision 75e3630c6071819d3674d956ea754ccb4fed5271,
you get Python 3.3:
---
$ grep PY_M Include/patchlevel.h
#define PY_MAJOR_VERSION3
#define PY_MINOR_VERSION3
#define PY_MICRO_VERSION6
---

But if you exclude manually commits which are in branches 3.x, you get
the commit 71db903563906cedfc098418659d1200043cd14c which gives a
different Python version:
---
$ grep PY_M Include/patchlevel.h
#define PY_MAJOR_VERSION3
#define PY_MINOR_VERSION6
#define PY_MICRO_VERSION0
---

In fact, I wrote a tool to manually exclude commits of branches 3.x:

https://github.com/haypo/misc/blob/master/misc/find_git_revisions_by_date.py

But it's super slow! Are there builtin options to only show Git
commits which are in master branch but not in 3.x branches?

Asked differently: how can I only see two commits on the following
range? What are [options]?

git rev-list 
288cb25f1a208fe09b9e06ba479e11c1157da4b5..71db903563906cedfc098418659d1200043cd14c
[options]

Commits after 2016-01-01:
---
$ git checkout 71db903563906cedfc098418659d1200043cd14c
$ git log --graph
*   commit 71db903563906cedfc098418659d1200043cd14c
|\  Merge: 288cb25 4c70293
| | Author: Benjamin Peterson 
| | Date:   Fri Jan 1 10:25:22 2016 -0600
| |
| | merge 3.5
| |
| *   commit 4c70293755ce8ea0adc5b224c714da2b7625d232
| |\  Merge: 42bf8fc e8c2a95
| | | Author: Benjamin Peterson 
| | | Date:   Fri Jan 1 10:25:12 2016 -0600
| | |
| | | merge 3.4
| | |
| | *   commit e8c2a957c87980a1fd79c39597d40e5c5aeb7048
| | |\  Merge: 52d6c2c 75e3630
| | | | Author: Benjamin Peterson 
| | | | Date:   Fri Jan 1 10:24:21 2016 -0600
| | | |
| | | | merge 3.3
| | | |
| | | * commit 75e3630c6071819d3674d956ea754ccb4fed5271
| | | | Author: Benjamin Peterson 
| | | | Date:   Fri Jan 1 10:23:45 2016 -0600
| | | |
| | | | 2016 will be another year of writing copyrighted code
| | | |
* | | |   commit 288cb25f1a208fe09b9e06ba479e11c1157da4b5
|\ \ \ \  Merge: 58f8833 42bf8fc
| |/ / /  Author: Serhiy Storchaka 
| | | |   Date:   Wed Dec 30 21:41:53 2015 +0200
| | | |
| | | |   Issue #25961: Disallowed null characters in the type name.
| | | |   Simplified testing for null characters in __name__ setter.
| | | |
---

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


Re: [Python-Dev] [Python-compilers] Developing a Python JIT and have troubld

2017-03-31 Thread Siu Kwan Lam
I have never tried PEP0523 before so I have just did a quick look and
pushed what I got to https://github.com/sklam/etude_py36_custom_jit.

If you run
https://github.com/sklam/etude_py36_custom_jit/blob/master/test.py, you
should get the following printouts:

Hello
Hey
Yes
** myjit is evaluating frame=0x10c623048 lasti=-1 lineno=10
Enter apple()
** myjit is evaluating frame=0x7f9a74e02178 lasti=-1 lineno=16
Enter orange()
Exit orange()
Exit apple()
** myjit is evaluating frame=0x10c460d48 lasti=-1 lineno=27

The frame is different for each method.

Can you try your implementation with my test so we can compare?

On Thu, Mar 30, 2017 at 11:46 PM Yuheng Zou  wrote:

I am building a Python JIT, so I want to change the interp->eval_frame to
my own function.

I built a C++ library which contains EvalFrame function, and then use dlopen
 and dlsym to use it. It looks like this:

extern "C" PyObject *EvalFrame(PyFrameObject *f, int throwflag) {
return _PyEval_EvalFrameDefault(f, throwflag);}

I added following code to Python/pylifecycle.c at function
_Py_InitializeEx_Private(Python version is 3.6.1):

void *pyjit = NULL;
pyjit = dlopen("../cmake-build-debug/libPubbon.dylib", 0);if (pyjit != NULL) {
interp->eval_frame = (_PyFrameEvalFunction)dlsym(pyjit, "EvalFrame");
//interp->eval_frame = _PyEval_EvalFrameDefault;}

Then something strange happened. I used LLDB to trace the variables. When
it ran at EvalFrame, the address of f pointer didn't change, but f->f_lineno
 changed.

Why the address of the pointer didn't change, but the context change?

I am working on Mac OS X and Python 3.6.1. I want to know how to replace
_PyEval_EvalFrameDefault in interp->eval_frame with my own function.
___
Python-compilers mailing list
python-compil...@python.org
https://mail.python.org/mailman/listinfo/python-compilers

-- 
Siu Kwan Lam
Software Engineer
Continuum Analytics
___
Python-Dev mailing list
Python-Dev@python.org
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com