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 2016年05月12日 08:04 by xiang.zhang, last changed 2022年04月11日 14:58 by admin. This issue is now closed.
| Messages (9) | |||
|---|---|---|---|
| msg265376 - (view) | Author: Xiang Zhang (xiang.zhang) * (Python committer) | Date: 2016年05月12日 08:04 | |
The error message of ``ord`` is not that right. It says 'ord() expected string of length 1'. I don't think in Py3.x string can refer to both bytes and unicodes. |
|||
| msg265377 - (view) | Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) | Date: 2016年05月12日 08:18 | |
This not the only place where "string" means unicode string or bytes string. I don't think this is large issue. |
|||
| msg265378 - (view) | Author: Xiang Zhang (xiang.zhang) * (Python committer) | Date: 2016年05月12日 08:23 | |
If you think it's OK, it's fine. Please close this thread. |
|||
| msg265380 - (view) | Author: Xiang Zhang (xiang.zhang) * (Python committer) | Date: 2016年05月12日 08:35 | |
BTW, what do you think about the second TypeError in ``ord``. Shouldn't it be ValueError? |
|||
| msg265382 - (view) | Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) | Date: 2016年05月12日 08:53 | |
In any case it doesn't make much sense to change just one separate docstring. If you want to avoid misleading and support consistent wording, you should examine all occurrences of the word "string" in the documentation, docstrings, error messages and comments -- does it mean Unicode string, bytes-like object that supports the buffer protocol (including memoryview), bytes-like object that supports str-like interface (including bytes, bytearray, but excluding memoryview), either Unicode or bytes string? I tried to do this but abandoned the work on half-way. This is too large work. > BTW, what do you think about the second TypeError in ``ord``. Shouldn't it be ValueError? It could be ValueError. But for compatibility it should stay TypeError. This is not wrong if we consider strings of size 1 as separate type. |
|||
| msg265384 - (view) | Author: Xiang Zhang (xiang.zhang) * (Python committer) | Date: 2016年05月12日 09:11 | |
Ohh, you have tried to do that. It must be a large work. But on the other hand, if this is a too large work, why not solve this case by case? This work is too large to get someone work on it, even you, the most active developer in the community I see have abandoned. And then maybe improving the situation a little bit every time is the only solution. > This is not wrong if we consider strings of size 1 as separate type This sounds weird. But I can understand the importance of compatibility. |
|||
| msg265401 - (view) | Author: R. David Murray (r.david.murray) * (Python committer) | Date: 2016年05月12日 12:46 | |
You are right, if it is too big a job to do it all at once, then we can fix them as we find them. Do you want to propose a patch? However, in this case I think there is arguably not a bug. It looks as though the intent is that ord only support strings (see the documentation). The fact that it supports bytes-like objects is redudant (ord(b'a') == b'a'[0]). I'd call it a bug that it supports bytes-like objects, but we probably kept (and should keep it) it to make it easier to port python2 code to python3. So, if any change were to be made here, it would probably be to change the error message if and only if the input is not in fact a string, and perhaps even recommend using the indexing syntax. On the gripping hand, I've never been a fan of the fact that indexing a byte string gets you an integer :) |
|||
| msg265409 - (view) | Author: Xiang Zhang (xiang.zhang) * (Python committer) | Date: 2016年05月12日 14:38 | |
I also notice the document. I get surprised when I see the implementation also supports bytes while the doc says one unicode character. But then I tell myself that maybe unicode character also includes bytes? I am not sure about the English description. But giving your opinion that maybe the bytes supports are not intended now, I think leaving the error message untouched is quite OK. It describes what it is intended to do, same as the doc. Really glad to have your comments, Serhiy and David. |
|||
| msg265415 - (view) | Author: R. David Murray (r.david.murray) * (Python committer) | Date: 2016年05月12日 16:11 | |
All right, we'll close this then. |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022年04月11日 14:58:31 | admin | set | github: 71195 |
| 2016年05月12日 16:11:08 | r.david.murray | set | status: open -> closed resolution: not a bug messages: + msg265415 stage: resolved |
| 2016年05月12日 14:38:15 | xiang.zhang | set | messages: + msg265409 |
| 2016年05月12日 12:46:13 | r.david.murray | set | messages: + msg265401 |
| 2016年05月12日 09:11:55 | xiang.zhang | set | messages: + msg265384 |
| 2016年05月12日 08:53:47 | serhiy.storchaka | set | nosy:
+ r.david.murray messages: + msg265382 |
| 2016年05月12日 08:35:05 | xiang.zhang | set | messages: + msg265380 |
| 2016年05月12日 08:23:56 | xiang.zhang | set | messages: + msg265378 |
| 2016年05月12日 08:18:19 | serhiy.storchaka | set | nosy:
+ serhiy.storchaka messages: + msg265377 |
| 2016年05月12日 08:04:50 | xiang.zhang | create | |