virtualenv
中有一些代码,这些代码正在绊倒我。 It's this:
path.decode("utf-8") if "__DECODE_PATH__" else path
from
。它可能是一个错误,但是由于它在 virtualenv
中,并且由于 activate_this.py
是当前解释器中激活 virtualenv
的手段,因此似乎不太可能。
另外,还有一个问题有人提到有人遇到这个问题,但是它得到了解决。没有人提到如果“ __decode_path __”
看不正确。
最终,这意味着我在尝试使用 activate_this.py
时,我获得 attributeError:'str'对象没有属性'decode'
。但是,如果我可以说服代码沿 else
路径下去,则可以正常工作。
注意:在Linux Mint 20.3中使用Python 3.8.10
There's some code in virtualenv
that's tripping me up. It's this:
path.decode("utf-8") if "__DECODE_PATH__" else path
from activate_this.py line 28.
How can if "__DECODE_PATH__"
ever be false? It's possible it's a bug, but since it's in virtualenv
and since activate_this.py
is the means of activating virtualenv
in the current interpreter, it's seems unlikely.
Also there is an issue where someone mentions having this problem but it then being resolved. No one mentions if "__DECODE_PATH__"
looking incorrect.
Ultimately it means I get AttributeError: 'str' object has no attribute 'decode'
when I try to use activate_this.py
. However if I could convince the code to go down the else
path it would work fine.
Note: using Python 3.8.10 in Linux Mint 20.3
发布评论
评论(1)
从代码中,看来文件只是一个模板,其中包含一些替换的魔术字符串。换句话说,它们只是模板变量。
您可以在 基类。
然后在 类,您可以看到
“ __ decode_path __”
是这些魔术字符串之一。From the code, it appears that file is just a template which contains some magic strings that are replaced. In other words, they are just template variables.
You can see the replacement in action in the
ViaTemplateActivator
base class.Then in the
PythonActivator
class you can see that"__DECODE_PATH__"
is one of those magic strings.