Skip to content

Conversation

@serhiy-storchaka
Copy link
Member

@serhiy-storchakaserhiy-storchaka commented Apr 4, 2020

@ZackerySpytz
Copy link
Contributor

It seems that some of the code added in this PR does not adhere to PEP 8.

@serhiy-storchaka
Copy link
MemberAuthor

Do you mean that some line is 84 characters long? It is slightly longer that the limit recommended by PEP 8. But there are much longer lines in the surrounded code (up to 104 characters), and I prefer to keep the consistent style.

@ammaraskar
Copy link
Member

ammaraskar commented Apr 12, 2020

Should we consider adding a direct test for this in clinic.test with something like:

/*[clinic input]output pushoutput preset buffer[clinic start generated code]*/#ifdefCONDITION_A/*[clinic input]test_preprocessor_guarded_condition_a[clinic start generated code]*/#elifCONDITION_B/*[clinic input]test_preprocessor_guarded_elif_condition_b[clinic start generated code]*/#else/*[clinic input]test_preprocessor_guarded_else[clinic start generated code]*/#endif/*[clinic input]dump bufferoutput pop[clinic start generated code]*/
Fully expands to:
/*[clinic input]output pushoutput preset buffer[clinic start generated code]*//*[clinic end generated code: output=da39a3ee5e6b4b0d input=5bff3376ee0df0b5]*/#ifdefCONDITION_A/*[clinic input]test_preprocessor_guarded_condition_a[clinic start generated code]*/staticPyObject*test_preprocessor_guarded_condition_a_impl(PyObject*module) /*[clinic end generated code: output=ad012af18085add6 input=8edb8706a98cda7e]*/#elifCONDITION_B/*[clinic input]test_preprocessor_guarded_elif_condition_b[clinic start generated code]*/staticPyObject*test_preprocessor_guarded_elif_condition_b_impl(PyObject*module) /*[clinic end generated code: output=615f2dee82b138d1 input=53777cebbf7fee32]*/#else/*[clinic input]test_preprocessor_guarded_else[clinic start generated code]*/staticPyObject*test_preprocessor_guarded_else_impl(PyObject*module) /*[clinic end generated code: output=13af7670aac51b12 input=6657ab31d74c29fc]*/#endif/*[clinic input]dump bufferoutput pop[clinic start generated code]*/#if defined(CONDITION_A) PyDoc_STRVAR(test_preprocessor_guarded_condition_a__doc__, "test_preprocessor_guarded_condition_a($module, /)\n""--\n""\n"); #defineTEST_PREPROCESSOR_GUARDED_CONDITION_A_METHODDEF \{"test_preprocessor_guarded_condition_a", (PyCFunction)test_preprocessor_guarded_condition_a, METH_NOARGS, test_preprocessor_guarded_condition_a__doc__}, staticPyObject*test_preprocessor_guarded_condition_a(PyObject*module, PyObject*Py_UNUSED(ignored)){returntest_preprocessor_guarded_condition_a_impl(module)} #endif/* defined(CONDITION_A) */#if !defined(CONDITION_A) && (CONDITION_B) PyDoc_STRVAR(test_preprocessor_guarded_elif_condition_b__doc__, "test_preprocessor_guarded_elif_condition_b($module, /)\n""--\n""\n"); #defineTEST_PREPROCESSOR_GUARDED_ELIF_CONDITION_B_METHODDEF \{"test_preprocessor_guarded_elif_condition_b", (PyCFunction)test_preprocessor_guarded_elif_condition_b, METH_NOARGS, test_preprocessor_guarded_elif_condition_b__doc__}, staticPyObject*test_preprocessor_guarded_elif_condition_b(PyObject*module, PyObject*Py_UNUSED(ignored)){returntest_preprocessor_guarded_elif_condition_b_impl(module)} #endif/* !defined(CONDITION_A) && (CONDITION_B) */#if !defined(CONDITION_A) && !(CONDITION_B) PyDoc_STRVAR(test_preprocessor_guarded_else__doc__, "test_preprocessor_guarded_else($module, /)\n""--\n""\n"); #defineTEST_PREPROCESSOR_GUARDED_ELSE_METHODDEF \{"test_preprocessor_guarded_else", (PyCFunction)test_preprocessor_guarded_else, METH_NOARGS, test_preprocessor_guarded_else__doc__}, staticPyObject*test_preprocessor_guarded_else(PyObject*module, PyObject*Py_UNUSED(ignored)){returntest_preprocessor_guarded_else_impl(module)} #endif/* !defined(CONDITION_A) && !(CONDITION_B) */#ifndefTEST_PREPROCESSOR_GUARDED_CONDITION_A_METHODDEF#defineTEST_PREPROCESSOR_GUARDED_CONDITION_A_METHODDEF#endif/* !defined(TEST_PREPROCESSOR_GUARDED_CONDITION_A_METHODDEF) */#ifndefTEST_PREPROCESSOR_GUARDED_ELIF_CONDITION_B_METHODDEF#defineTEST_PREPROCESSOR_GUARDED_ELIF_CONDITION_B_METHODDEF#endif/* !defined(TEST_PREPROCESSOR_GUARDED_ELIF_CONDITION_B_METHODDEF) */#ifndefTEST_PREPROCESSOR_GUARDED_ELSE_METHODDEF#defineTEST_PREPROCESSOR_GUARDED_ELSE_METHODDEF#endif/* !defined(TEST_PREPROCESSOR_GUARDED_ELSE_METHODDEF) *//*[clinic end generated code: output=3804bb18d454038c input=3fc80c9989d2f2e1]*/

@serhiy-storchaka
Copy link
MemberAuthor

Great idea @ammaraskar! I tried to add tests, but without output preset buffer Argument Clinic did not produce useful output. Thank you for your tests!

Co-authored-by: Ammar Askar <ammar@ammaraskar.com>
@serhiy-storchaka
Copy link
MemberAuthor

@larryhastings could you please take a look? It is a blocker for #19360.

@serhiy-storchakaserhiy-storchaka merged commit 12446e6 into python:masterApr 18, 2020
@miss-islington
Copy link
Contributor

Thanks @serhiy-storchaka for the PR 🌮🎉.. I'm working now to backport this PR to: 3.7, 3.8.
🐍🍒⛏🤖

@miss-islington
Copy link
Contributor

Sorry, @serhiy-storchaka, I could not cleanly backport this to 3.8 due to a conflict.
Please backport using cherry_picker on command line.
cherry_picker 12446e6a605f066d837d3a595d0a73e4f3b43b65 3.8

@miss-islington
Copy link
Contributor

Sorry @serhiy-storchaka, I had trouble checking out the 3.7 backport branch.
Please backport using cherry_picker on command line.
cherry_picker 12446e6a605f066d837d3a595d0a73e4f3b43b65 3.7

serhiy-storchaka added a commit to serhiy-storchaka/cpython that referenced this pull request Apr 18, 2020
…nGH-19364) Co-authored-by: Ammar Askar <ammar@ammaraskar.com>. (cherry picked from commit 12446e6) Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
@bedevere-bot
Copy link

GH-19583 is a backport of this pull request to the 3.8 branch.

serhiy-storchaka added a commit to serhiy-storchaka/cpython that referenced this pull request Apr 18, 2020
…nGH-19364) Co-authored-by: Ammar Askar <ammar@ammaraskar.com>. (cherry picked from commit 12446e6) Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
@bedevere-bot
Copy link

GH-19584 is a backport of this pull request to the 3.7 branch.

serhiy-storchaka added a commit that referenced this pull request Apr 18, 2020
… (GH-19583) Co-authored-by: Ammar Askar <ammar@ammaraskar.com> (cherry picked from commit 12446e6)
serhiy-storchaka added a commit that referenced this pull request Apr 18, 2020
… (GH-19584) Co-authored-by: Ammar Askar <ammar@ammaraskar.com> (cherry picked from commit 12446e6)
CuriousLearner added a commit to CuriousLearner/cpython that referenced this pull request May 29, 2020
* master: (1985 commits) bpo-40179: Fix translation of #elif in Argument Clinic (pythonGH-19364) bpo-35967: Skip test with `uname -p` on Android (pythonGH-19577) bpo-40257: Improve help for the typing module (pythonGH-19546) Fix two typos in multiprocessing (pythonGH-19571) bpo-40286: Use random.randbytes() in tests (pythonGH-19575) bpo-40286: Makes simpler the relation between randbytes() and getrandbits() (pythonGH-19574) bpo-39894: Route calls from pathlib.Path.samefile() to os.stat() via the path accessor (pythonGH-18836) bpo-39897: Remove needless `Path(self.parent)` call, which makes `is_mount()` misbehave in `Path` subclasses. (pythonGH-18839) bpo-40282: Allow random.getrandbits(0) (pythonGH-19539) bpo-40302: UTF-32 encoder SWAB4() macro use a|b rather than a+b (pythonGH-19572) bpo-40302: Replace PY_INT64_T with int64_t (pythonGH-19573) bpo-40286: Add randbytes() method to random.Random (pythonGH-19527) bpo-39901: Move `pathlib.Path.owner()` and `group()` implementations into the path accessor. (pythonGH-18844) bpo-40300: Allow empty logging.Formatter.default_msec_format. (pythonGH-19551) bpo-40302: Add pycore_byteswap.h header file (pythonGH-19552) bpo-40287: Fix SpooledTemporaryFile.seek() return value (pythonGH-19540) Minor modernization and readability improvement to the tokenizer example (pythonGH-19558) bpo-40294: Fix _asyncio when module is loaded/unloaded multiple times (pythonGH-19542) Fix parameter names in assertIn() docs (pythonGH-18829) bpo-39793: use the same domain on make_msgid tests (python#18698) ...
@serhiy-storchakaserhiy-storchaka removed their assignment Dec 29, 2020
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type-bugAn unexpected behavior, bug, or error

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants

@serhiy-storchaka@ZackerySpytz@ammaraskar@miss-islington@bedevere-bot@the-knights-who-say-ni