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 2012年06月19日 15:42 by Ken.Cheung, last changed 2022年04月11日 14:57 by admin. This issue is now closed.
| Files | ||||
|---|---|---|---|---|
| File name | Uploaded | Description | Edit | |
| errors_clone.txt | Ken.Cheung, 2012年06月19日 15:42 | |||
| Messages (4) | |||
|---|---|---|---|
| msg163181 - (view) | Author: Ken Cheung (Ken.Cheung) | Date: 2012年06月19日 15:42 | |
I observed a code clone from the following files. function : PyErr_Restore @ (file: "Python-3.3.0a4/Python/errors.c", line: 27)~49 function : PyErr_SetExcInfo @ (file: "Python-3.3.0a4/Python/errors.c", line: 341)~353 The function PyErr_Restore performs some checking on traceback while PyErr_SetExcInfo does not. I wonder if this is necessary in the function PyErr_SetExcInfo. The source code is included in the attachment. Hope it helps. |
|||
| msg223486 - (view) | Author: Mark Lawrence (BreamoreBoy) * | Date: 2014年07月19日 23:05 | |
From what I can see the code is completely the same in default but does this matter or not? As a matter of interest is there an official policy regarding code clones, whether in C or pure Python? |
|||
| msg384248 - (view) | Author: Irit Katriel (iritkatriel) * (Python committer) | Date: 2021年01月03日 01:06 | |
The code is not really cloned - note that PyErr_Restore is operating on tstate->curexc (the exception currently being handled) while PyErr_SetExcInfo is operating on tstate->exc_info (the earliest exception currently on the exception stack). If there is a bug here, I think it is the silent conversion of traceback to NULL in the case where it is neither NULL nor Py_None. (The case in PyErr_Restore that the comment says should not happen). Otherwise, the difference is that PyErr_Restore transforms Py_None to NULL for the traceback, and PyErr_SetExcInfo doesn't. That conversion seems neither necessary nor wrong. |
|||
| msg384251 - (view) | Author: Pablo Galindo Salgado (pablogsal) * (Python committer) | Date: 2021年01月03日 01:57 | |
Adding extra checks to PyErr_SetExcInfo doesn't have a lot of value because is already out of of contract. If you pass an invalid object (let's say a list) to any of the specific APIs (like PyDict_GetItem) it will crash anyway. We could add some assert, though. |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022年04月11日 14:57:31 | admin | set | github: 59311 |
| 2021年01月03日 02:01:22 | pablogsal | set | status: open -> closed resolution: not a bug stage: resolved |
| 2021年01月03日 01:57:55 | pablogsal | set | nosy:
+ pablogsal messages: + msg384251 |
| 2021年01月03日 01:06:44 | iritkatriel | set | nosy:
+ iritkatriel messages: + msg384248 versions: + Python 3.10, - Python 3.4 |
| 2019年04月26日 20:03:20 | BreamoreBoy | set | nosy:
- BreamoreBoy |
| 2014年07月19日 23:05:11 | BreamoreBoy | set | nosy:
+ BreamoreBoy messages: + msg223486 |
| 2013年04月24日 14:22:41 | ezio.melotti | set | nosy:
+ ezio.melotti, serhiy.storchaka components: + Interpreter Core, - None versions: + Python 3.4, - Python 3.3 |
| 2012年06月19日 15:42:52 | Ken.Cheung | create | |