You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Argument Clinic generates multiple definitions in non-block mode for functions with alternating signature. See example file. If FOO is not defines, SPAM_METHODDEF is defined twice.
May be first commit this non-perfect solution? Generated code is correct, it is just not optimal. This issue is a dependency of bpo-23501, that is a dependency of bpo-23492, that is a dependency of my patch for optimizing argument parsing in 1-argument functions.
It doesn't fix the issue, because the #ifndef stanza is emitted before second definition. Try to run clinic.py with your patch on sample.c. But may be this idea can be used with my patch.
Updated patch, removed all references to two-pass. Also realized I needed to make the default behavior for methoddef_ifndef go to the end. And, finally, I forgot to merge the "only print each #ifndef block once" code I wrote before when I redid the patch, so that's in now.
Activity
serhiy-storchaka commentedon Feb 22, 2015
Argument Clinic generates multiple definitions in non-block mode for functions with alternating signature. See example file. If FOO is not defines, SPAM_METHODDEF is defined twice.
First time in:
Second time in:
larryhastings commentedon Feb 22, 2015
Can you give me a test case?
serhiy-storchaka commentedon Feb 22, 2015
Oh, sorry. Here is a sample. Other sample see in bpo-23501.
serhiy-storchaka commentedon Mar 4, 2015
Here is a patch which moves all methoddef_ifndef to the end of the buffer or file, so they are not conflicts with other definitions.
serhiy-storchaka commentedon Mar 4, 2015
Here is a sample file generated by fixed clinic.py.
larryhastings commentedon Mar 4, 2015
In your sample output we still get two #ifndef SPAM_METHODDEF stanzas. Wouldn't it be better to only have one?
Maybe Clinic needs to be smarter about generating those anyway. Let me think about it.
serhiy-storchaka commentedon Mar 4, 2015
Actually in this sample output no one #ifndef SPAM_METHODDEF stanza is needed, because SPAM_METHODDEF is defined in any case.
serhiy-storchaka commentedon Mar 14, 2015
May be first commit this non-perfect solution? Generated code is correct, it is just not optimal. This issue is a dependency of bpo-23501, that is a dependency of bpo-23492, that is a dependency of my patch for optimizing argument parsing in 1-argument functions.
larryhastings commentedon Mar 15, 2015
How about this approach? Only ever emit the #ifndef stanza once per symbol.
larryhastings commentedon Mar 15, 2015
(see larry.ac_multiple_macro_definitions.diff.1.txt posted above)
larryhastings commentedon Mar 15, 2015
Oops, I should have run "make clinic", so you could see all the changes that result from this patch.
serhiy-storchaka commentedon Mar 15, 2015
It doesn't fix the issue, because the #ifndef stanza is emitted before second definition. Try to run clinic.py with your patch on sample.c. But may be this idea can be used with my patch.
6 remaining items
serhiy-storchaka commentedon Apr 3, 2015
Looks as you didn't notice my comments on Rietveld.
larryhastings commentedon Apr 3, 2015
I did, I just didn't respond. I'll do that now.
larryhastings commentedon Apr 3, 2015
Updated patch, removed all references to two-pass. Also realized I needed to make the default behavior for methoddef_ifndef go to the end. And, finally, I forgot to merge the "only print each #ifndef block once" code I wrote before when I redid the patch, so that's in now.
serhiy-storchaka commentedon Apr 3, 2015
larry.ac_multiple_macro_definitions.diff.5.txt LGTM.
python-dev commentedon Apr 3, 2015
New changeset 25eef0ecb9c1 by Larry Hastings in branch 'default':
Issue bpo-23500: Argument Clinic is now smarter about generating the "#ifndef"
https://hg.python.org/cpython/rev/25eef0ecb9c1
larryhastings commentedon Apr 3, 2015
Does this really need a backport to 3.4?
serhiy-storchaka commentedon Apr 3, 2015
I think this is not needed.
serhiy-storchaka commentedon Apr 3, 2015
Thank you Larry.
larryhastings commentedon Apr 3, 2015
Removing 3.4 from the version list as I close the bug, then. If we decide we need it backported please reopen (or create a new bug, either is fine).
pythongh-104146: Remove unused 'second_pass_replacements' from clinic.py
pythongh-104146: Remove unused 'second_pass_replacements' from clinic.py
gh-104146: Remove unused 'second_pass_replacements' from clinic.py (#…