-
-
Notifications
You must be signed in to change notification settings - Fork 31.6k
Derby #1: Convert 137 sites to Argument Clinic in Modules/posixmodule.c #64369
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
This issue is part of the Great Argument Clinic Conversion Derby, This issue asks you to change the following bundle of files: Talk to me (larry) if you only want to attack part of a bundle. For instructions on how to convert a function to work with Argument |
Submitting this just so I beat the deadline. I'm *about* half done, but I'm still working on it, so I'm just going to keep going--should only be another couple of hours. (If somebody else pulls this stunt, I guess I'll accept their final patch too.) |
Here's a complete patch, converts everything that I think should be converted for 3.4. With this patch applied, all unit tests pass on my 64-bit Linux box. I plan to also run tests with the buildbots before checking it in. The patch... well, it's 14,000 lines. 409k bytes. Do we have any takers? |
By the way, my plan is to turn on the file preset just before checkin. The patch is *much* easier to read without turning that on first; with the file preset, now you have to keep two windows in sync to compare calls to PyArg_*(). |
Sorry for the fresh update, but here's revision 3. Only changes:
#ifdef HAVE_SOMETHING and
(I used to randomly have blank lines there. No more!) |
Actually, forget about the file output preset. It wouldn't work for posixmodule. > 80% of the entry points are #ifdef conditional on platform functionality. Which means the Clinic generated stuff needs to be #ifdef too. It wouldn't be that hard to add the ability to #ifdef your generated code... but then what? Should it generate an #endif too, right before the end of the block? If it closed the #ifdef, then it'd look dumb: /*[clinic input]*
ifdef HAVE_WHATNOT
os.whatnot
[clinic start generated code]*/
#ifdef HAVE_WHATNOT
...
static PyObject *
os_whatnot(PyModuleType *)
#endif /* HAVE_WHATNOT */
/*[clinic end generated code: output=... ]*/
#ifdef HAVE_WHATNOT
{
...
}
#endif /* HAVE_WHATNOT */ If it didn't close the #ifdef, well, that looks dumb too: /*[clinic input]*
ifdef HAVE_WHATNOT
os.whatnot
[clinic start generated code]*/
#ifdef HAVE_WHATNOT
...
static PyObject *
os_whatnot(PyModuleType *)
/*[clinic end generated code: output=... ]*/
{
...
}
#endif /* HAVE_WHATNOT */ though maybe that's less dumb. |
The curses module also has many conditionally implemented functions. I think Argument Clinic can detect preprocessor instructions (#if/#ifdef/#ifndef/#else/#endif) and generate needed #if/#endif in generated file. This would be more robust than explicitly repeat condition in clinic declaration, because external conditions can be changed. |
That's a really good idea! I'm still thinking about how I'd do it, but I think I'm gonna give it a try. |
This patch doesn't apply anymore (to c55300337932); please update it. |
Here's an updated patch. I cleaned it up a little. I think it's about ready to go in. Zachary, iirc you're a Windows guy and have helped with ensuring patches apply cleanly to Windows in the past. Can you give this a try on Windows? |
MSVC is not happy, here's some build output: "P:\ath\to\cpython\PCbuild\pcbuild.sln" (Build target) (1) -> "P:\ath\to\cpython\PCbuild\pcbuild.sln" (Build target) (1) ->
|
thanks! I'm flying from London to Brisbane (via Singapore), gonna take about a day. Now I have something to do on the flight ;-) (that and nullable ints) |
Here's a fresh diff. I did some cleanup this time (Clinic now generates the #ifndef versions of the METHODDEF structures) and I believe solved everything MSVC complains about. Zachary, can you try this one? |
Close, but no cigar :). Posted Rietveld comments to address the last two compile issues (one of which also appears to be a major bug, but only a warning at compile time). Also, Victor has added os.get_blocking() and os.set_blocking(), which prevent your patch from applying cleanly (I tested against the parent of Victor's changeset). After fixing the two issues I pointed out on Rietveld, I still get major failure on test: ====================================================================== Traceback (most recent call last):
File "P:\ath\to\cpython\lib\test\test_os.py", line 214, in tearDown
os.rmdir(support.TESTFN)
OSError: [WinError 145] The directory is not empty: '@test_13492_tmp' ====================================================================== Traceback (most recent call last):
File "P:\ath\to\cpython\lib\test\test_os.py", line ###, in setUp
os.mkdir(support.TESTFN)
FileExistsError: [WinError 183] Cannot create a file when that file already exists: '@test_13492_tmp' ====================================================================== Traceback (most recent call last):
File "P:\ath\to\cpython\lib\test\test_os.py", line 1138, in test_urandom_fd_reopened
with open(support.TESTFN, 'wb') as f:
PermissionError: [Errno 13] Permission denied: '@test_13492_tmp' ====================================================================== Traceback (most recent call last):
File "P:\ath\to\cpython\lib\test\test_os.py", line 1274, in test_chdir
self.assertRaises(OSError, os.chdir, support.TESTFN)
AssertionError: OSError not raised by chdir Ran 164 tests in 5.122s The problem appears to be in unlink or rmdir, but I can't see anything amiss in either one. I'll keep looking, but you may have a better idea what's going wrong. |
Two small fixes from Zach (thanks again Zach!) and I updated against current trunk so it should apply cleanly. How's it look now? |
The patch applies and compiles cleanly, and I finally tracked down what was causing the errors I reported yesterday: os_utime_impl was changed to use Py_RETURN_NONE instead of just setting return_value = Py_None, so Windows skipped the exit routine and left an open handle on any call to os.utime. Commented on the bad line on Rietveld. |
Another nit to pick: long lines in docstrings. There are several lines about 75-78 characters long in several different docstrings, which look absolutely terrible when you try "import os;help(os)" on an 80-character-wide terminal due to an 8 character indent. Blame can be spread pretty far and wide on this, but I wonder if Clinic should enforce a 72 character limit on docstring lines to try to mitigate this? Other than that (and the fix to utime mentioned earlier), I don't see anything obviously wrong with the patch, though I admit to not having read through the whole thing (it's huge!). |
Diff tweaked to undo the ill-concieved Py_RETURN_NONE change. Thanks, Zachary! Does it now compile and pass tests on Windows? |
Yep, Windows is happy with the latest patch. Since this is such an enormous patch, I'm assuming it's only going into 3.5 and have changed the version field accordingly. |
Yeah, I've been meaning to mark all the Derby patches as 3.5. We're not adding new Clinic conversions to 3.4. |
New changeset 0c57aba6b1a3 by Larry Hastings in branch 'default': |
Gonna keep an eye on the buildbots and make sure I haven't caused any new breakage. Otherwise... fingers crossed, I think it's done! Thanks for the help everybody (particularly Zach!). |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: