This issue tracker has been migrated to GitHub ,
and is currently read-only.
For more information,
see the GitHub FAQs in the Python's Developer Guide.
Created on 2013年04月12日 16:54 by Julian, last changed 2022年04月11日 14:57 by admin. This issue is now closed.
| Files | ||||
|---|---|---|---|---|
| File name | Uploaded | Description | Edit | |
| cpython-3.3-17705.patch | Jason.Michalski, 2013年04月13日 20:57 | review | ||
| Messages (6) | |||
|---|---|---|---|
| msg186653 - (view) | Author: Julian Berman (Julian) * | Date: 2013年04月12日 16:54 | |
The docs say:
"The fill character can be any character other than ‘{‘ or ‘}’."
http://docs.python.org/dev/library/string.html#format-specification-mini-language
But:
>>> "{0:\x01>8.2f}".format(12)
'\x01\x01\x0112.00'
whereas:
>>> "{0:\x00>8.2f}".format(12)
' 12.00'
|
|||
| msg186724 - (view) | Author: Stefan Krah (skrah) * (Python committer) | Date: 2013年04月13日 14:47 | |
Unsurprisingly (libmpdec is a C library) this also does not work in _decimal. I could add a special case in _decimal.c at the cost of two additional if statements for all regular use cases. Is padding with NUL a legitimate use case? IOW, is the slowdown justified? |
|||
| msg186726 - (view) | Author: Mark Dickinson (mark.dickinson) * (Python committer) | Date: 2013年04月13日 14:51 | |
> Is padding with NUL a legitimate use case? I don't see a good reason to disallow it, and it seems like a fairly plausible need. Numpy, for example, pads strings will NUL bytes when placing a short string in long fixed-width field. |
|||
| msg186731 - (view) | Author: Stefan Krah (skrah) * (Python committer) | Date: 2013年04月13日 15:13 | |
Mark Dickinson <report@bugs.python.org> wrote: > Numpy, for example, pads strings will NUL bytes when placing a short > string in long fixed-width field. I was hoping to escape the work, but that's quite convincing. ;) Changing libmpdec doesn't look very appealing, so probably I'll use "{" as a placeholder for NUL and then rewrite the result. |
|||
| msg186842 - (view) | Author: Jason Michalski (Jason.Michalski) * | Date: 2013年04月13日 20:57 | |
I worked on a patch that allows NUL padding for longs, floats and complex numbers. It seems NUL was being used as a sentinel in the format string parsing when no padding character is given. It was then replaced with a space in each call to fill_padding if it was NUL. |
|||
| msg215456 - (view) | Author: Stefan Krah (skrah) * (Python committer) | Date: 2014年04月03日 16:14 | |
This looks like a duplicate of #12546. |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022年04月11日 14:57:44 | admin | set | github: 61905 |
| 2014年04月03日 16:15:23 | skrah | set | superseder: builtin __format__ methods cannot fill with \x00 char |
| 2014年04月03日 16:14:29 | skrah | set | status: open -> closed versions: + Python 3.5, - Python 2.7, Python 3.3 messages: + msg215456 resolution: duplicate stage: patch review -> resolved |
| 2013年05月04日 20:31:38 | pitrou | set | stage: patch review |
| 2013年04月19日 18:57:24 | terry.reedy | set | versions: - Python 3.2 |
| 2013年04月13日 23:24:10 | eric.smith | set | assignee: eric.smith |
| 2013年04月13日 20:57:04 | Jason.Michalski | set | files:
+ cpython-3.3-17705.patch nosy: + Jason.Michalski messages: + msg186842 keywords: + patch |
| 2013年04月13日 15:13:26 | skrah | set | messages: + msg186731 |
| 2013年04月13日 14:51:55 | mark.dickinson | set | nosy:
+ mark.dickinson messages: + msg186726 |
| 2013年04月13日 14:47:32 | skrah | set | nosy:
+ skrah messages: + msg186724 |
| 2013年04月12日 22:34:57 | eric.smith | set | nosy:
+ eric.smith |
| 2013年04月12日 16:54:55 | Julian | create | |