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
No float formatting in PyString_FromFormat #47062
Comments
There appears to be most of the formatting options in the *printf |
Do you expect to have support for float, double and long double ? |
Well, precision modifiers would be nice, but I don't think that they're |
Attached is a patch attempting to provide support for %f with precision in PyString_FromFormat* based on file Objects/stringobject.c of Python 2.6b1. Note, only %f is support but %lf is not and silently ignored. |
Attached is another patch for file Objects/stringobject.c(relative to However, %Lf is included only if symbol LDBL_DIG is defined in header This patch also handles the long and size_t flags correctly in the first Btw, it does not make sense to handle float since there is not formnat |
Jean, you can increase *hugely* the possibility of this being accepted Thanks!! |
Another rev of the patch now including updates to 2 documentation files: Where should test cases for the new formats in the PyString_FromFormat* |
The tests for PyString_FromFormat are in file Modules/_testcapimodule.c. Attached is yet another update of the patch, this one also includes 3 |
Here is another patch for PyString_FromFormat* adding support for 'l' and Updates for the c-api tests and the documentation for exceptions and Like before, the patch is a forward delta to the files of Python 2.6b1. |
From the code: /* assume %f produces at most (L)DBL_DIG This is not correct. DBL_DIG is 15 on my x86 Linux machine. It would be easier to review this if the %p change weren't also unicodeobject.c should also be modified. In 3.x, it's unicodeobject.c |
I also think it would be good to use PyOS_double_to_string here. That As far as I can see, Python doesn't use long double anywhere outside the |
Jean, do you intend taking this issue any further or can it be closed? |
I'll take a look at this. |
Mark L, No, I do not intend to take this issue further. Rather the opposite, it should probably be paired down based on the recent comments. Specifically, use PyOS_double_to_string, remove support for long double and perhaps more. Also, the patches I created are more than 2 years old and will need to be updated against the current stringobject.c code. There are quite a few changes in the 2.7 version of that file since early 2.6. |
Closing as Jean has no interest in keeping it open. |
Jean may have no interest in moving this forward, but I do. (Which is why I assigned the issue to me.) |
Okay, I've failed to take this forward. Reclosing as out of date. |
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: