Skip to content
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

aliyun-python-sdk-core 里存在大量胡乱修改 sys.path 的行为 #43

Closed
glasslion opened this issue Nov 5, 2017 · 3 comments
Closed
Assignees

Comments

@glasslion
Copy link

对应的代码片段为:

parentdir = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
sys.path.insert(0, parentdir)

以 aliyunsdkcore/http/http_request.py 为例:

parentdir = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
sys.path.insert(0, parentdir)
import format_type

作者的目的是 import format_type module, 那么通过 from aliyunsdkcore.http import format_type 这种绝对引用方式, 或者 from . import format_type 都能办到。 作者却选择了将 这个目录添加到了 sys.path 的最前面这种不正确的方式。

如果使用者自己代码里含有和 aliyunsdkcore.http 同名的文件, 将导致无法正确 import. 而
·aliyunsdkcore/` module 下就有utils 这种非常常见的 module 名

@pyq19
Copy link

pyq19 commented Nov 14, 2017

遇到同样的问题

@gaort
Copy link

gaort commented Dec 7, 2017

@glasslion @wangrenqi
感谢您的热心反馈,这块的确是我们需要改进的地方
我们会尽快对代码进行一次清洗,彻底消除这种代码
再次感谢,对您带来的不便十分抱歉

@gaort gaort self-assigned this Dec 7, 2017
@gaort
Copy link

gaort commented Dec 15, 2017

@glasslion @wangrenqi
代码已经清洗了,再次感谢您的反馈

@gaort gaort closed this as completed Dec 15, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants