[issue20226] Argument Clinic: support for simple expressions?

2014-01-25 Thread Larry Hastings

Changes by Larry Hastings :


--
stage: commit review -> committed/rejected

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue20226] Argument Clinic: support for simple expressions?

2014-01-16 Thread Roundup Robot

Roundup Robot added the comment:

New changeset cd3fdf21a6e4 by Larry Hastings in branch 'default':
Issue #20226: Added tests for new features and regressions.
http://hg.python.org/cpython/rev/cd3fdf21a6e4

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue20226] Argument Clinic: support for simple expressions?

2014-01-16 Thread Larry Hastings

Changes by Larry Hastings :


--
resolution:  -> fixed
stage: patch review -> commit review
status: open -> closed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue20226] Argument Clinic: support for simple expressions?

2014-01-16 Thread Larry Hastings

Larry Hastings added the comment:

Done!

Georg: Thanks for the suggestion, and for the reviews!  Argument Clinic is 
improved this day.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue20226] Argument Clinic: support for simple expressions?

2014-01-16 Thread Roundup Robot

Roundup Robot added the comment:

New changeset abf87e1fbc62 by Larry Hastings in branch 'default':
Issue #20226: Major improvements to Argument Clinic.
http://hg.python.org/cpython/rev/abf87e1fbc62

--
nosy: +python-dev

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue20226] Argument Clinic: support for simple expressions?

2014-01-16 Thread Georg Brandl

Georg Brandl added the comment:

Thx! (without soundcheck)

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue20226] Argument Clinic: support for simple expressions?

2014-01-16 Thread Georg Brandl

Georg Brandl added the comment:

Rietveld doesn't like your new patch?

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue20226] Argument Clinic: support for simple expressions?

2014-01-16 Thread Larry Hastings

Larry Hastings added the comment:

Sorry, forgot to update trunk, here you go.

--
Added file: 
http://bugs.python.org/file33500/larry.clinic.rollup.patch.two.diff.4.txt

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue20226] Argument Clinic: support for simple expressions?

2014-01-16 Thread Larry Hastings

Larry Hastings added the comment:

Third patch, changes based on Georg's review.  Thanks, Georg!

--
Added file: 
http://bugs.python.org/file33499/larry.clinic.rollup.patch.two.diff.3.txt

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue20226] Argument Clinic: support for simple expressions?

2014-01-16 Thread Larry Hastings

Larry Hastings added the comment:

Py_buffer is currently inflexible.  The only default value it accepts is None.  
If you want it to be required, give it no default value.  If you want it to be 
optional, give it a default value of None.

Do you have a use case for any other default value?

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue20226] Argument Clinic: support for simple expressions?

2014-01-16 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

Excellent! I'm rewriting the zlib module and the code becomes much cleaner with 
this patch.

There is one problem left -- Py_buffer doesn't support default value at all.

Such code

/*[clinic input]
zlib.compressobj
zdict: Py_buffer = unspecified
[clinic start generated code]*/

produces error:

When you specify a named constant ('unspecified') as your default value,
you MUST specify a valid c_default.

But this code

/*[clinic input]
zlib.compressobj
zdict: Py_buffer(c_default="{NULL, NULL}") = unspecified
[clinic start generated code]*/

produces error too:

The only legal default value for Py_buffer is None.

And specifying c_default=None returns first error.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue20226] Argument Clinic: support for simple expressions?

2014-01-16 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

It would be better if you commit a patch which changes PyTuple_Size to 
PyTuple_GET_SIZE in separate commit.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue20226] Argument Clinic: support for simple expressions?

2014-01-16 Thread Larry Hastings

Larry Hastings added the comment:

Second rollup patch.  More small fixes, many suggested by other folks.

--
Added file: 
http://bugs.python.org/file33492/larry.clinic.rollup.patch.two.diff.2.txt

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue20226] Argument Clinic: support for simple expressions?

2014-01-16 Thread Larry Hastings

Larry Hastings added the comment:

Isn't that what it does?

I may actually remove py_default.  Nobody uses it, and I don't think you need 
it--you just specify what you want as the real default value.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue20226] Argument Clinic: support for simple expressions?

2014-01-16 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

Why not allow arbitrary string as py_default?

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue20226] Argument Clinic: support for simple expressions?

2014-01-16 Thread Larry Hastings

Larry Hastings added the comment:

Okay, I have a fix for the help(os.chmod) problem, that'll be in the next 
refreshed patch.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue20226] Argument Clinic: support for simple expressions?

2014-01-15 Thread Zachary Ware

Zachary Ware added the comment:

Actually, I can reproduce on tip with just this patch applied; os.chmod shows 
it.  And I was wrong, params that have a default are correct, it's just ones 
without.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue20226] Argument Clinic: support for simple expressions?

2014-01-15 Thread Larry Hastings

Larry Hastings added the comment:

I'd prefer it if you emailed me as I asked.  That will help me get to it a lot 
quicker.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue20226] Argument Clinic: support for simple expressions?

2014-01-15 Thread Zachary Ware

Zachary Ware added the comment:

Just confirmed that this patch fixes the traceback I was getting from winreg in 
#20172, but this has a new oddity:

>>> help(winreg)
...
ConnectRegistry(computer_name=, key=)
...

Every param of every function has this kind of thing, positional or keyword, 
default or no.  I'll try to look into it, but my hopes aren't high (much of 
clinic's inner workings are still mysterious to me).

--
nosy: +zach.ware

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue20226] Argument Clinic: support for simple expressions?

2014-01-15 Thread Larry Hastings

Larry Hastings added the comment:

That's okay, email me a sample at

larry at hastings dot org

and I'll take a look at it.  Be sure to tell me which patch(es) were applied at 
the time.

(Note: all you need to send is the Clinic block.)

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue20226] Argument Clinic: support for simple expressions?

2014-01-14 Thread Meador Inge

Meador Inge added the comment:

Larry, nice.  I am verified that your latest patch fixes my third sqlite3
nit from issue20178.

--
nosy: +meador.inge

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue20226] Argument Clinic: support for simple expressions?

2014-01-14 Thread Larry Hastings

Larry Hastings added the comment:

The attached patch extends Argument Clinic and the inspect module: now you may 
use simple (!) expressions as default values.  So for example "sys.maxsize - 1" 
should now work fine.

* Names may be in the current module; as a backup they will also be looked up 
in sys.modules.
* You may look up attributes of names.
* You may subscript into names.
* You may use math operators, both unary and binary.
* int/float/string literals are (still) fine.
* You may not use: function calls, list/set/dict/tuple/bytes literals, 
generator expressions or comprehensions, if expressions, anything fun.

Other changes in this diff:
* "doc_default" is gone, it no longer makes sense.
* "py_default" and "c_default" handling is simpler and more predictable.
* Minor doc fix suggested on tracker.

The docs still need work.  More tests would be good too but I'm already 
overwhelmed by work--could one of you guys contribute some tests?

--
stage:  -> patch review
type:  -> enhancement
Added file: 
http://bugs.python.org/file33473/larry.clinic.rollup.patch.two.diff.1.txt

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue20226] Argument Clinic: support for simple expressions?

2014-01-12 Thread Georg Brandl

Georg Brandl added the comment:

Nice, thanks.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue20226] Argument Clinic: support for simple expressions?

2014-01-12 Thread Larry Hastings

Larry Hastings added the comment:

Yes, this is supported, just undocumented (for now).  The magic you want is, 
for example in Modules/_sre.c:

endpos: Py_ssize_t(c_default="PY_SSIZE_T_MAX") = sys.maxsize

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue20226] Argument Clinic: support for simple expressions?

2014-01-12 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

See also a discussion in issue20193. zlib needs this in many functions.

--
nosy: +serhiy.storchaka
versions: +Python 3.4

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue20226] Argument Clinic: support for simple expressions?

2014-01-12 Thread Georg Brandl

Changes by Georg Brandl :


--
assignee:  -> larry
nosy: +larry

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue20226] Argument Clinic: support for simple expressions?

2014-01-12 Thread Georg Brandl

New submission from Georg Brandl:

Take for example select.epoll.__new__():

static PyObject *
pyepoll_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
{
int flags = 0, sizehint = FD_SETSIZE - 1;
static char *kwlist[] = {"sizehint", "flags", NULL};

if (!PyArg_ParseTupleAndKeywords(args, kwds, "|ii:epoll", kwlist,
 &sizehint, &flags))
return NULL;

How should that be handled?  Currently I can't specify ``FD_SETSIZE - 1`` as 
the default value, but I don't want a magic ``-909`` either :)

--
messages: 207946
nosy: georg.brandl
priority: normal
severity: normal
status: open
title: Argument Clinic: support for simple expressions?

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com