Issue11436
Created on 2011-03-07 18:29 by terry.reedy, last changed 2022-04-11 14:57 by admin. This issue is now closed.
| Files | ||||
|---|---|---|---|---|
| File name | Uploaded | Description | Edit | |
| zstruct.diff | terry.reedy, 2011-03-07 18:30 | |||
| Messages (7) | |||
|---|---|---|---|
| msg130275 - (view) | Author: Terry J. Reedy (terry.reedy) * ![]() |
Date: 2011-03-07 18:29 | |
The struct doc does not specify the meaning of 's', without a count. The attached patch adds the sentence:
If a count is not given, it defaults to 1; ``'s'`` means the same as ``'1s'``.
(Until I experimented, I had thought no count meant indefinite length).
>>> struct.pack('sss', b'', b'a', b'ab')
b'\x00aa'
>>> struct.pack('1s1s1s', b'', b'a', b'ab')
b'\x00aa'
|
|||
| msg130277 - (view) | Author: Terry J. Reedy (terry.reedy) * ![]() |
Date: 2011-03-07 18:30 | |
patch |
|||
| msg139924 - (view) | Author: Senthil Kumaran (orsenthil) * ![]() |
Date: 2011-07-06 06:42 | |
Is this not implicit? Do we really need this stmt? I am -0 on this. If you agree, you can close this issue. |
|||
| msg139926 - (view) | Author: Terry J. Reedy (terry.reedy) * ![]() |
Date: 2011-07-06 07:01 | |
A default of 1 in not implicit for output formatting.
%s and {:s} mean however long needed, not %1s or {:1s}
|
|||
| msg139927 - (view) | Author: Senthil Kumaran (orsenthil) * ![]() |
Date: 2011-07-06 07:41 | |
That is for the string formatting character, correct? In this issue, we are talking about format character for struct and not just 's' but 'c','h','b','i' all without numeric prefix imply single value. |
|||
| msg139964 - (view) | Author: Terry J. Reedy (terry.reedy) * ![]() |
Date: 2011-07-07 01:44 | |
Those others field types have a standard or system-dependent fixed size and a number is an optional repeat count. Format 's' is always a single field because number prefix for that is special -- a field size. "For the 's' format character, the count is interpreted as the length of the bytes, not a repeat count like for the other format characters; for example, '10s' means a single 10-byte string, while '10c' means 10 characters. " I happen to think is could use a few more words of special explanation. Looking again, I think ", which defaults to 1" after the first 'count' above, would be sufficient. We nearly always docucument defaults. |
|||
| msg140522 - (view) | Author: Roundup Robot (python-dev) ![]() |
Date: 2011-07-17 09:32 | |
New changeset 90cdf403132e by Senthil Kumaran in branch '3.2': Fix closes Issue11436 - Minor clarification to struct documentation for 's' format character. http://hg.python.org/cpython/rev/90cdf403132e |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022-04-11 14:57:14 | admin | set | github: 55645 |
| 2011-07-17 09:32:24 | python-dev | set | status: open -> closed nosy:
+ python-dev resolution: fixed |
| 2011-07-07 01:44:02 | terry.reedy | set | messages: + msg139964 |
| 2011-07-06 07:41:38 | orsenthil | set | messages: + msg139927 |
| 2011-07-06 07:01:00 | terry.reedy | set | messages:
+ msg139926 versions: - Python 3.1 |
| 2011-07-06 06:42:49 | orsenthil | set | nosy:
+ orsenthil messages:
+ msg139924 |
| 2011-03-07 18:30:34 | terry.reedy | set | files: + zstruct.diff |
| 2011-03-07 18:29:36 | terry.reedy | create | |

