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 2008年03月17日 17:51 by brett.cannon, last changed 2022年04月11日 14:56 by admin. This issue is now closed.
| Files | ||||
|---|---|---|---|---|
| File name | Uploaded | Description | Edit | |
| oct_and_hex_py3k.patch | benjamin.peterson, 2008年04月27日 19:04 | |||
| Messages (11) | |||
|---|---|---|---|
| msg63695 - (view) | Author: Brett Cannon (brett.cannon) * (Python committer) | Date: 2008年03月17日 17:51 | |
oct() and hex() need to use __index__ when available and then emit a Py3K warning when they fall back on __oct__ and __hex__. |
|||
| msg64270 - (view) | Author: Georg Brandl (georg.brandl) * (Python committer) | Date: 2008年03月21日 20:13 | |
Shouldn't we leave alone oct() and hex() (there is another issue for deprecation warning for __oct__ and __hex__), and let people use the versions from future_builtins? |
|||
| msg65859 - (view) | Author: Benjamin Peterson (benjamin.peterson) * (Python committer) | Date: 2008年04月27日 00:31 | |
This is what I'd like to do: In builtin oct/hex check if the special method is declared. If it is, Py3k warn and use it. If not, check if we can do it the Py3k way (with PyNumber_ToBase). Sound good? |
|||
| msg65863 - (view) | Author: Brett Cannon (brett.cannon) * (Python committer) | Date: 2008年04月27日 01:23 | |
@Georg: That is a possibility. Would need to add the proper Py3K warning to the current builtins, though. @Benjamin: You don't want to warn if it will work for Py3K, so don't warn if __index__ is used. |
|||
| msg65865 - (view) | Author: Benjamin Peterson (benjamin.peterson) * (Python committer) | Date: 2008年04月27日 01:26 | |
I meant not to. Sorry, that wasn't clear. |
|||
| msg65881 - (view) | Author: Georg Brandl (georg.brandl) * (Python committer) | Date: 2008年04月27日 09:36 | |
I don't assume there are too many people using oct() and hex() with custom types anyway :) Since PyNumber_ToBase and the new oct() format octal numbers with "0o" instead of "0", I still think it's better if you need to import the new oct() from future_builtins. For hex(), I have no preference. |
|||
| msg65892 - (view) | Author: Benjamin Peterson (benjamin.peterson) * (Python committer) | Date: 2008年04月27日 19:04 | |
Here's a patch for that. It warns for hex() when __hex__ is used, otherwise it uses __index__. (This doesn't work for old style classes because ob_tp->tp_as_number->tp_hex is filled.) Use of oct() just gets a warning. The __hex__ and __oct__ methods of builtin number objects should probably be removed. |
|||
| msg67008 - (view) | Author: Georg Brandl (georg.brandl) * (Python committer) | Date: 2008年05月17日 18:49 | |
The warning message for oct() should include that the output will be different too. Else this is fine with me. |
|||
| msg67013 - (view) | Author: Benjamin Peterson (benjamin.peterson) * (Python committer) | Date: 2008年05月17日 19:23 | |
Done in r63425. |
|||
| msg67015 - (view) | Author: Benjamin Peterson (benjamin.peterson) * (Python committer) | Date: 2008年05月17日 20:11 | |
I have reverted this. See mail.python.org/pipermail/python-checkins/2008-May/069843.html. |
|||
| msg67768 - (view) | Author: Benjamin Peterson (benjamin.peterson) * (Python committer) | Date: 2008年06月06日 14:18 | |
This was rejected by Guido. |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022年04月11日 14:56:31 | admin | set | github: 46590 |
| 2008年06月06日 14:18:08 | benjamin.peterson | set | status: pending -> closed resolution: rejected messages: + msg67768 |
| 2008年05月17日 20:36:02 | eric.smith | set | nosy: + eric.smith |
| 2008年05月17日 20:11:48 | benjamin.peterson | set | status: closed -> pending resolution: fixed -> (no value) messages: + msg67015 |
| 2008年05月17日 19:23:32 | benjamin.peterson | set | status: open -> closed resolution: fixed messages: + msg67013 |
| 2008年05月17日 18:49:32 | georg.brandl | set | messages: + msg67008 |
| 2008年04月27日 19:08:36 | benjamin.peterson | link | issue2352 superseder |
| 2008年04月27日 19:04:45 | benjamin.peterson | set | files:
+ oct_and_hex_py3k.patch keywords: + patch messages: + msg65892 |
| 2008年04月27日 09:36:27 | georg.brandl | set | messages: + msg65881 |
| 2008年04月27日 01:26:51 | benjamin.peterson | set | messages: + msg65865 |
| 2008年04月27日 01:23:42 | brett.cannon | set | messages: + msg65863 |
| 2008年04月27日 00:31:25 | benjamin.peterson | set | nosy:
+ benjamin.peterson messages: + msg65859 |
| 2008年03月21日 20:13:50 | georg.brandl | set | nosy:
+ georg.brandl messages: + msg64270 |
| 2008年03月17日 20:10:36 | brett.cannon | set | priority: release blocker -> critical |
| 2008年03月17日 17:51:06 | brett.cannon | create | |