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
Derby: Convert the _sre module to use Argument Clinic #64347
Comments
Here is preliminary patch which converts the _sre module to use Argument Clinic. 22 functions are converted. There are thre problems: |
Obviously we can't live with manually editing the output from Argument Clinic, so I'll get you a fix for O! today. Maybe we could use a better literal value? Like 2**31 - 1? I don't understand the pydoc thing. Can you elaborate? |
This only a placeholder. It will be replaced by named constant in final patch.
Pydoc for _sre.compile doesn't output signature and docstring, but only |
Can you refresh the patch? I think all the problems you cited are fixed, and also the comments Argument Clinic uses were all changed. I'll review when you have a fresh patch. |
Here is refreshed patch. |
Serhiy: Assigning to you because you wrote a patch; if you don't want the issue, sorry, please undo it. |
Now all methods except Match.group() (which needs *args) use Argument Clinic. Most important change is that first parameters of some Pattern methods are renamed from "pattern" or "source" to "string". This was obvious bug (bpo-20283). "string" conforms to the documentation and to the name of the Match.string attribute. |
Here is updated patch. |
Synchronized with the tip again. |
Updated to the tip. |
New changeset d5f78a855355 by Serhiy Storchaka in branch 'default': |
This broke Windows builds because of unnecessary "static" qualifiers on the forward declarations at lines 1429, 2472 and 2715 (as discussed on bpo-20323). Removing "static" from these lines fixes the build. |
Removing "static" breaks GCC on Linux (gcc 4.9.2 on Ubuntu 15.04 x86-64): ./Modules/_sre.c:2780:20: error: static declaration of ‘pattern_methods’ follows non-static declaration IMO MSVS is the one being unreasonable here. But obviously we need to find some way of doing this that makes both compilers happy. |
Steve, does this patch fix the build for Windows? By all rights it oughta. |
This line (1429 before patch, 1433 after patch) is still being troublesome: static PyMethodDef pattern_methods[]; |
But looks like it's unnecessary and just wasn't removed in the patch. Everything builds fine without it |
Sorry--you can simply remove that line, it's no longer needed. |
Does your patch just move type definition to the end of the file? I think this is only the way to make happy GCC and MS compiler. Strange that no IRC bot complained about compilation failure. |
Yes, it moves the type declaration to the bottom of the file, and adds forward static declarations for the types to the top of the file. |
AFAIK the only buildbot with a nearly-up-to-date MSVC is still marked as unstable (http://buildbot.python.org/all/builders/AMD64%20Windows8%203.x). I keep meaning to get it promoted, but haven't quite gotten around to it yet... |
Oh, this is only happening on the *beta* compiler? In that case, I genuinely suggest you file a bug. We can still check in the workaround, but I really do think MSVS's behavior is wrong here. (Why is it only for forward static declarations of arrays of unspecified size?) |
Then the patch LGTM. It is easier to make these changes by hand than make a review for moved code on Rietveld. I'm not sure, but may be forward static declarations of arrays of unspecified size is C99-ism? |
It fails on VC10, 11, 12 and 14, so I doubt it's going to be changed. That said, it looks like the non-static forward definition may be some sort of extension, since it causes a redefinition error (mismatched storage class) on all versions when using /Za to disable extensions. It could be a C99 feature ("tentative definitions" I think), as Serhiy suggests, but if so then it's very likely not going to be added between the RC (released last week) and final versions of the compiler. |
According to http://compgroups.net/comp.std.c/why-does-the-standard-prohibit-static-int-a/2569729, it's invalid in both C89 and C99, but some compilers accept it as an extension. IMO we should avoid relying on compiler extensions, at least in the code files that are supposed to be portable. |
I agree. I looked it up in the C99 standard. 6.9.2.2 says: "If the declaration of an identifier for an object is a tentative definition and has internal linkage, the declared type shall not be an incomplete type." And if you'd hurry up and bless my patch for Modules/_tkinter.c in bug bpo-20168, I'd check this fix in ;-) |
(sorry, 6.9.2.3) |
Sorry, wasn't watching the other issue. :) |
New changeset 7a76c462c7f6 by Larry Hastings in branch 'default': |
Steve, please close this issue when you've confirmed it's now building correctly on Windows. |
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: