Issue12317
Created on 2011-06-11 19:18 by giampaolo.rodola, last changed 2022-04-11 14:57 by admin.
| Pull Requests | |||
|---|---|---|---|
| URL | Status | Linked | Edit |
| PR 11786 | closed | corona10, 2019-02-08 03:15 | |
| PR 11786 | closed | corona10, 2019-02-08 03:15 | |
| PR 11786 | closed | corona10, 2019-02-08 03:15 | |
| Messages (8) | |||
|---|---|---|---|
| msg138558 - (view) | Author: Terry J. Reedy (terry.reedy) * ![]() |
Date: 2011-06-17 22:58 | |
>>> help(inspect.getabsfile) could be copied
getabsfile(object, _filename=None)
Return an absolute path to the source or compiled file for an object.
The idea is for each object to have a unique origin, so this routine
normalizes the result as much as possible.
|
|||
| msg197332 - (view) | Author: Antoine Pitrou (pitrou) * ![]() |
Date: 2013-09-08 22:21 | |
This shouldn't be a dependency. The function is already implemented, it just needs to be documented. |
|||
| msg197334 - (view) | Author: Brett Cannon (brett.cannon) * ![]() |
Date: 2013-09-08 22:49 | |
It technically doesn't need to be a dependency, but if __file__ goes absolute then the point of the function becomes moot and thus shouldn't get documented as it is then pointless (and honestly I don't trust any code that tries to guess at what the cwd was when a module was imported). |
|||
| msg335051 - (view) | Author: Dong-hee Na (corona10) * ![]() |
Date: 2019-02-08 01:43 | |
@pitrou Hi, Can I work on this issue? |
|||
| msg335052 - (view) | Author: Rémi Lapeyre (remi.lapeyre) * | Date: 2019-02-08 01:48 | |
Hi @corona10, Antoine's message is from 2013 and inspect.getabsfile() is still not documented, I think it's safe to say he's not working on it. You can work on the issue and open a new PR on GitHub when you think it is ready for review :) |
|||
| msg335055 - (view) | Author: Terry J. Reedy (terry.reedy) * ![]() |
Date: 2019-02-08 03:55 | |
3.6 is also on security-fix-only status |
|||
| msg335152 - (view) | Author: Dong-hee Na (corona10) * ![]() |
Date: 2019-02-10 13:01 | |
@terry.reedy I submited the PR 11786 for this issue. If you are okay can you take a look please? Thanks! |
|||
| msg335179 - (view) | Author: Terry J. Reedy (terry.reedy) * ![]() |
Date: 2019-02-10 23:20 | |
Given the absence of agreement among core-devs, a PR is a bit premature. Looking again at the existing docstring, I think it must be revised before copying and *not* copied as is. 0. The existing first sentence mislead me. The 'source or compiled file' must be a Python source or compiled Python (.pyc) file. An object in a compiled C file gives a TypeError. Change 'an object' to 'a Python-coded object'. 1. The 'object' argument cannot be just any Python-coded object (class object instance). Based on the exception message, add this second sentence: "The object must be a module, class, method, function, traceback, frame, or code object." Otherwise, TypeError. 2. The second paragraph is garbled. All objects in a module have a common origin, not a unique origin. I think the idea is that the name for the origin should be a standardized full path. I think that this paragraph adds so little that it should be deleted rather than revised. What paused this issue was Brett's opinion that getabsfile is untrustworthy and, with __file__ absolute, 'pointless', to a degree that it should not be documented. (If that were true, it should be deprecated.) I read the 3.7.2 source for getabsfile, getsourcefile, and getfile. The returned name is based on either module.__file__ or code.co_filename. I think the function should be kept and documented. 1. Assuming that both __file__ and co_filename are now normcased and normalized absolute paths, (and identical for functions,) then "os.path.normcase(os.path.abspath(_filename))" is a no-op returning _filename as is, and should be dropped. There is no longer a "guess at what the cwd was when a module was imported" in getabsfile itself. 2. getfile and getsourcefile do non-trivial switching and name processing that users would not get right if getabsfile were not present. |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022-04-11 14:57:18 | admin | set | github: 56526 |
| 2019-02-14 23:34:13 | giampaolo.rodola | set | keywords:
patch, patch, patch nosy: - giampaolo.rodola |
| 2019-02-14 20:46:37 | brett.cannon | set | keywords:
patch, patch, patch nosy: - brett.cannon |
| 2019-02-10 23:20:29 | terry.reedy | set | keywords:
patch, patch, patch messages: + msg335179 |
| 2019-02-10 13:01:55 | corona10 | set | messages: + msg335152 |
| 2019-02-08 03:55:33 | terry.reedy | set | keywords:
patch, patch, patch messages:
+ msg335055 |
| 2019-02-08 03:16:04 | corona10 | set | keywords:
+ patch stage: needs patch -> patch review pull_requests: + pull_request11778 |
| 2019-02-08 03:15:50 | corona10 | set | keywords:
+ patch stage: needs patch -> needs patch pull_requests: + pull_request11777 |
| 2019-02-08 03:15:36 | corona10 | set | keywords:
+ patch stage: needs patch -> needs patch pull_requests: + pull_request11776 |
| 2019-02-08 01:48:02 | remi.lapeyre | set | nosy:
+ remi.lapeyre messages:
+ msg335052 |
| 2019-02-08 01:43:20 | corona10 | set | nosy:
+ corona10 messages: + msg335051 |
| 2014-06-14 15:06:19 | giampaolo.rodola | set | assignee: giampaolo.rodola -> |
| 2013-09-08 22:49:34 | brett.cannon | set | messages: + msg197334 |
| 2013-09-08 22:21:22 | pitrou | set | nosy:
+ pitrou dependencies: - Move to absolute file paths for module.__file__ messages: + msg197332 |
| 2013-09-08 22:13:53 | brett.cannon | set | dependencies: + Move to absolute file paths for module.__file__ |
| 2013-09-08 17:05:17 | pitrou | set | nosy:
+ brett.cannon versions: + Python 3.4, - Python 3.2 |
| 2013-09-08 16:10:25 | akitada | set | nosy:
+ akitada |
| 2012-10-25 22:57:16 | hieu.nguyen | set | nosy:
+ hieu.nguyen |
| 2011-06-17 22:58:28 | terry.reedy | set | versions:
- Python 2.6, Python 3.1 nosy: + terry.reedy messages: + msg138558 components:
+ Documentation |
| 2011-06-11 19:18:14 | giampaolo.rodola | create | |
