<div dir="ltr"><div><div><div><div><div><div><div>Hi Andrea and Serhiy,<br><br></div>Thank you for your responses and clarifying that it is specifically the CALL_FUNCTION. I tested this in my megascript and it will fail when trying to call the functions directly and receive an error then (Py 2.x: fail at call invocation, Py 3.y w/ y<7: fail at function definition).<br><br></div>@Serhiy I looked through the commits and had found <a href="https://github.com/python/cpython/commit/5bb8b9134b0bb35a73c76657f41cafa3e4361fcd#diff-4d35cf8992b795c5e97e9c8b6167cb34">https://github.com/python/cpython/commit/5bb8b9134b0bb35a73c76657f41cafa3e4361fcd#diff-4d35cf8992b795c5e97e9c8b6167cb34</a> but the commit that removed the 255 checks also explains that this is specifically about the call function ( <a href="https://github.com/python/cpython/commit/214678e44bf7773c0ed9c3684818354001d8f9ca#diff-4d35cf8992b795c5e97e9c8b6167cb34">https://github.com/python/cpython/commit/214678e44bf7773c0ed9c3684818354001d8f9ca#diff-4d35cf8992b795c5e97e9c8b6167cb34</a> ), so indeed I should have been able to answer this myself.<br><br></div>The reason why I originally had encountered this was (as discussed in one of the bug reports) from code that was generating a class hierarchy to represent Doxygen's XML schema. The class constructors had >255 arguments, but in executing the code it actually does still work in python 2.x. The reason is because all of the arguments are defaulted to None, and during execution of typical sample XML files, the explicit construction with all >255 arguments virtually never happens.<br><br><span style="font-family:monospace,monospace"> f.write("def foo_2({0}):\n".format(", ".join(["a{0}=None".format(str(i)) for i in range(300)])))<br> f.write(" print('foo_2 executed')\n\n")<br></span></div><span style="font-family:monospace,monospace"> # ... in generated __main__ ...<br> f.write(" foo_2()\n\n")</span><br><br></div><span style="font-family:monospace,monospace">foo_2()</span> will succeed in python 2.x because the <span style="font-family:monospace,monospace">CALL_FUNCTION</span> is not explicitly getting more than 255 parameters. Very interesting!<br><br></div>Thank you both again for your responses, I am grateful to finally understand the way in which success / failure works here :)<br><br></div>-Stephen<br><br></div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Aug 6, 2018 at 2:17 AM, Serhiy Storchaka <span dir="ltr"><<a href="mailto:storchaka@gmail.com" target="_blank">storchaka@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">06.08.18 08:13, Stephen McDowell пише:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
I've looked at the C code for a while and it is entirely non-obvious what would lead to python *2* /allowing/ >255 arguments. Anybody happen to know how / why the python *2* versions *succeed*?<br>
</blockquote>
<br>
The error message is misleading. It should be "more than 255 parameters". This limitation is due to the optimization used in Python 3 for call variables (see <a href="https://bugs.python.org/issue12399" rel="noreferrer" target="_blank">https://bugs.python.org/issue1<wbr>2399</a> for details).<br>
<br>
In all versions <3.7 there is a limitation on the number of explicit function arguments because of the limitation of the CALL_FUNCTION opcode.<span class=""><br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Thank you for reading, this is not a problem, just a burning desire for closure (even if anecdotal) as to how this can be. I deeply love python, and am not complaining! I stumbled across this and found it truly confounding, and thought the gurus here may happen to recall what changed in 3.x that lead the the error condition actually being asserted :)<br>
</blockquote>
<br></span>
Read the history of the code. Commit messages usually contain explanations or references to issues.<span class=""><br>
<br>
______________________________<wbr>_________________<br>
Python-Dev mailing list<br>
<a href="mailto:Python-Dev@python.org" target="_blank">Python-Dev@python.org</a><br>
<a href="https://mail.python.org/mailman/listinfo/python-dev" rel="noreferrer" target="_blank">https://mail.python.org/mailma<wbr>n/listinfo/python-dev</a><br></span>
Unsubscribe: <a href="https://mail.python.org/mailman/options/python-dev/sjm324%40cornell.edu" rel="noreferrer" target="_blank">https://mail.python.org/mailma<wbr>n/options/python-dev/sjm324%<wbr>40cornell.edu</a><br>
</blockquote></div><br></div>