[issue19976] Argument Clinic: generate second arg for METH_NOARGS

2017-11-08 Thread STINNER Victor

STINNER Victor  added the comment:


New changeset 2138163621196a186975796afb2b0a6aa335231d by Victor Stinner (Petr 
Viktorin) in branch 'master':
bpo-29179: Document the Py_UNUSED macro (#4341)
https://github.com/python/cpython/commit/2138163621196a186975796afb2b0a6aa335231d


--

___
Python tracker 

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



[issue19976] Argument Clinic: generate second arg for METH_NOARGS

2017-11-08 Thread Petr Viktorin

Change by Petr Viktorin :


--
pull_requests: +4296

___
Python tracker 

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



[issue19976] Argument Clinic: generate second arg for METH_NOARGS

2014-01-09 Thread Larry Hastings

Changes by Larry Hastings :


--
assignee:  -> larry
resolution:  -> fixed
stage:  -> committed/rejected
status: open -> closed

___
Python tracker 

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



[issue19976] Argument Clinic: generate second arg for METH_NOARGS

2014-01-04 Thread Roundup Robot

Roundup Robot added the comment:

New changeset c4ababa110a2 by Larry Hastings in branch 'default':
Issue #19976: Argument Clinic METH_NOARGS functions now always
http://hg.python.org/cpython/rev/c4ababa110a2

--
nosy: +python-dev

___
Python tracker 

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



[issue19976] Argument Clinic: generate second arg for METH_NOARGS

2013-12-16 Thread STINNER Victor

STINNER Victor added the comment:

> The Visual Studio pragma disables for the rest of the file, which is 
> undesirable.  Maybe we could turn it on and off inline, but it's not clear to 
> me that that would have the desired effect of turning off the warning for 
> explicitly that parameter declaration.

Oh, I didn't know that it is file-wide. There are
__pragma(warning(push)) and __pragma(warning(pop)) commands to disable
a pragma. I don't know it is can be used using Py_UNUSED(name) macro
(is it possible to "pop" the pragma before the function body?).

If a compiler does not provide a syntax to disable the warning just in
one function, the warning should be disabled for the compilation of
the whole project.

--

___
Python tracker 

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



[issue19976] Argument Clinic: generate second arg for METH_NOARGS

2013-12-15 Thread Larry Hastings

Larry Hastings added the comment:

Here's a first attempt at a patch.

The Visual Studio pragma disables for the rest of the file, which is 
undesirable.  Maybe we could turn it on and off inline, but it's not clear to 
me that that would have the desired effect of turning off the warning for 
explicitly that parameter declaration.

Also, a little googling confirms that clang supports the GCC 
__attribute((unused)) extension, so I just went with that.

--
Added file: 
http://bugs.python.org/file33150/larry.clinic.fix.meth_noargs.1.diff.txt

___
Python tracker 

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



[issue19976] Argument Clinic: generate second arg for METH_NOARGS

2013-12-13 Thread Stefan Krah

Stefan Krah added the comment:

STINNER Victor  wrote:
> I would prefer Py_UNUSED name. This sounds like a nice addition to 
> Include/pymacros.h.

Yes, Py_UNUSED is nicer.

--

___
Python tracker 

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



[issue19976] Argument Clinic: generate second arg for METH_NOARGS

2013-12-13 Thread Stefan Krah

Stefan Krah added the comment:

Larry Hastings  wrote:
> To do it properly with Clang requires a pragma:

Hmm. I just tested and clang warns with -Wall -W, but does not warn if
__attribute__((unused)) is present.

The macro I posted really works on all obscure buildbot platforms.

--

___
Python tracker 

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



[issue19976] Argument Clinic: generate second arg for METH_NOARGS

2013-12-13 Thread Stefan Krah

Stefan Krah added the comment:

Stefan Krah  wrote:
> The macro I posted really works on all obscure buildbot platforms.

N.B. clang also defines __GNUC__, as does the intel compiler.

--

___
Python tracker 

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



[issue19976] Argument Clinic: generate second arg for METH_NOARGS

2013-12-13 Thread STINNER Victor

STINNER Victor added the comment:

> We could call the macro PY_UNUSED or something.

I would prefer Py_UNUSED name. This sounds like a nice addition to 
Include/pymacros.h.

In C++, you can omit the parameter name, so the macro should take the parameter 
name: Py_UNUSED(name). Example:

   int foo(int Py_UNUSED(bar)) { return 1 }

In Visual Studio, you can use:

#define Py_UNUSED(NAME) __pragma(warning(suppress:4100)) NAME

For Clang, you can try:

#define Py_UNUSED(NAME) _Pragma(diagnostic ignored "-Wunused") NAME

--

___
Python tracker 

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



[issue19976] Argument Clinic: generate second arg for METH_NOARGS

2013-12-13 Thread Larry Hastings

Larry Hastings added the comment:

To do it properly with Clang requires a pragma:

http://stackoverflow.com/questions/3417837/what-is-the-best-way-to-supress-unused-variable-x-warning/18724213#18724213

What a mess.

--

___
Python tracker 

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



[issue19976] Argument Clinic: generate second arg for METH_NOARGS

2013-12-13 Thread Larry Hastings

Larry Hastings added the comment:

A quick google suggests:

http://sourcefrog.net/weblog/software/languages/C/unused.html

--

___
Python tracker 

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



[issue19976] Argument Clinic: generate second arg for METH_NOARGS

2013-12-13 Thread Stefan Krah

Stefan Krah added the comment:

STINNER Victor  wrote:
> If you prefer to add the unused parameter, what do you propose to avoid 
> compiler warnings if unused parameters are checked?

This works quite portably in _decimal (I don't get warnings from gcc, icc,
suncc, Visual Studio, aCC, clang):

#if defined(__GNUC__) && !defined(__INTEL_COMPILER)
  #define UNUSED __attribute__((unused))
#else
  #define UNUSED
#endif

static PyObject *
signaldict_copy(PyObject *self, PyObject *args UNUSED)
{
return flags_as_dict(SdFlags(self));
}

We could call the macro PY_UNUSED or something.

--

___
Python tracker 

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



[issue19976] Argument Clinic: generate second arg for METH_NOARGS

2013-12-13 Thread Larry Hastings

Larry Hastings added the comment:

Stefan is right.  I'll fix Clinic.

--

___
Python tracker 

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



[issue19976] Argument Clinic: generate second arg for METH_NOARGS

2013-12-13 Thread STINNER Victor

STINNER Victor added the comment:

I prefer to omit the unused parameter, even if NULL *is* passed to the function.

If you prefer to add the unused parameter, what do you propose to avoid 
compiler warnings if unused parameters are checked?

--
nosy: +haypo

___
Python tracker 

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



[issue19976] Argument Clinic: generate second arg for METH_NOARGS

2013-12-13 Thread Stefan Krah

New submission from Stefan Krah:

I was just reading the _pickle sources and it appears that AC does not
generate a second arg for METH_NOARGS functions:

#define _PICKLE_PICKLERMEMOPROXY_CLEAR_METHODDEF\
{"clear", (PyCFunction)_pickle_PicklerMemoProxy_clear, METH_NOARGS, 
_pickle_PicklerMemoProxy_clear__doc__},

static PyObject *
_pickle_PicklerMemoProxy_clear(PicklerMemoProxyObject *self)


While this is a common occurrence in the source tree, the consensus
in #15402 was that the unused second arg should be present, e.g.:

msg166250
msg166405

--
components: Demos and Tools
messages: 206093
nosy: larry, skrah
priority: normal
severity: normal
status: open
title: Argument Clinic: generate second arg for METH_NOARGS
type: behavior
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