-
-
Notifications
You must be signed in to change notification settings - Fork 31.6k
shutil uses both os.path.abspath and an 'import from' of abspath #65590
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
If you meant to supply a patch, it is missing. And in any event, you need to describe the issue. |
Use the 'abspath' shortcut instead of 'os.path.abspath' |
Wouldn't it be better to switch uses of abspath to be os.path.abspath? os.path is used elsewhere in the file, after all. Brett added "from os.path import abspath" in http://hg.python.org/cpython/rev/686e5d38be42 but I think that import should be deleted and os.path.abspath used directly. |
IMO either change would not improve the code at all. Suggest closing this. |
I disagree. It took me longer than I'd like to admit to track down the file history and understand it. I'd like to prevent other people from having to try and understand why it works this way. On the other hand, it looks like people have discovered it: If we are going to keep it, we should add a test for it (which actually might exist, I haven't checked yet). |
I'd prefer to get rid of it, otherwise we might get requests to add all the other os.path functions to the shutil namespace, and I don't think having that kind of "more than one way to do it" serves anyone. I suppose we'll have to deprecate it first if we do get rid of it :(. |
Here is a patch to deprecate the shutil.abspath function. |
Shouldn't the existing calls to abspath() be changed to os.path.abspath()? Or are both patches meant to be applied? I don't think the first patch applies cleanly any more. In any event: the deprecation and test look good to me. So assuming we get rid of the import and get rid of direct calls to abspath(), I'm +1. |
Now that I think about it, maybe we don't need a deprecation warning. http://legacy.python.org/dev/peps/pep-0008/#public-and-internal-interfaces says: "Imported names should always be considered an implementation detail. Other modules must not rely on indirect access to such imported names unless they are an explicitly documented part of the containing module's API, such as os.path or a package's __init__ module that exposes functionality from submodules." abspath isn't in __all__, so it's arguably not part of the public API, anyway. |
I'm for get rid of "from import" without deprecation. Definitely this is not part of API. |
New changeset ab369d809200 by Berker Peksag in branch 'default': |
Done. Thanks for the reviews! |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: