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

命名不规范导致在使用ipdb进行debug时报错 #133

Closed
TuuuNya opened this issue Dec 3, 2018 · 7 comments
Closed

命名不规范导致在使用ipdb进行debug时报错 #133

TuuuNya opened this issue Dec 3, 2018 · 7 comments

Comments

@TuuuNya
Copy link

TuuuNya commented Dec 3, 2018

该目录以profile命名:https://github.com/aliyun/aliyun-openapi-python-sdk/tree/master/aliyun-python-sdk-core/aliyunsdkcore/profile

在我们公司的django项目中引入了aliyun-openapi-python-sdk。

随后在django中使用ipdb进行debug,设置断点就会报错。

经过查证是因为ipdb中这个profile和python内置的profile冲突了。

如果可以,希望能修改一下该包里面的profile命名。

@TuuuNya
Copy link
Author

TuuuNya commented Dec 3, 2018

profile属于python内置模块,不应该以内置模块作为目录名。

@TuuuNya TuuuNya changed the title 命名不规范导致在某些情况下会产生BUG。 命名不规范导致在使用ipdb进行debug时报错 Dec 3, 2018
@JacksonTian
Copy link
Contributor

您在导入 profile 模块时,可以使用 as 别名来避免命名冲突。

@TuuuNya
Copy link
Author

TuuuNya commented Dec 13, 2018

我们在使用其他包的时候,包里面调用了系统的profile,所以导致不能和阿里云这个包同时使用。

@Qingtang-SDK
Copy link
Contributor

您好,Python规范并未禁止在顶级命名空间不同的情况下,存在2个相同的包名。对于您遇到的问题,我们建议避免使用相对引用(例如 from . import profile),避免在 aliyunsdkcore 路径下启动您的程序,来防止系统的profile模块和 aliyunsdkcore.profile模块冲突。

如果以上的信息未能解决您的问题,请您提供一下截图、具体报错信息等来让我们知道问题的细节以及如何重现。谢谢!

@TuuuNya
Copy link
Author

TuuuNya commented Dec 13, 2018

在django中接入了core SDK,用做滑块验证码的相关逻辑。

然后在django中,比如某个views中,使用ipdb打断点调试的时候,就会报错。

代码如下:

首先我写了一个utils.py,用来存公用的东西,比如发短信,滑块验证码,其中有一段这样的代码:

image

然后在任何一个views.py里面引入ipdb,django就会报错,无法runserver起来。

如果在重写的get方法里面引入,当请求执行到get方法时,就会报错。

image

随后我使用pdb,进行调试,打印了一下profile,发现引入的不是python自带的,而是sdk下的。

image

总结一下,大概意思就是在django下(其他的也有可能,未测试),用这个包,就会覆盖python自带的profile, 如果其他依赖的包引入了profile模块,并使用, 就会报错。

@Qingtang-SDK Qingtang-SDK reopened this Dec 18, 2018
@Orisdaddy
Copy link
Contributor

您是否还有问题?如果没反馈我们将在3天内关闭,如有疑问请重新打开。

@lagelalegal
Copy link

所以问题的解决方案是啥?
python@3.9/3.9.7/Frameworks/Python.framework/Versions/3.9/lib/python3.9/cProfile.py line 23, in
run.doc = _pyprofile.run.doc

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants