該修改由the unicode
fixer觸發。該固定器將解釋每一個字符串文字的內容,並試圖再次逃跑無效的Unicode序列,並卸下U/U字符串前綴:(?BUG)
def transform(self, node, results):
...
elif node.type == token.STRING:
# 1. Replace the invalid \u sequences.
val = node.value
if not self.unicode_literals and val[0] in '\'"' and '\\' in val:
val = r'\\'.join([
v.replace('\\u', r'\\u').replace('\\U', r'\\U')
for v in val.split(r'\\')
])
# 2. Strip the leading `u` in u"...."
if val[0] in 'uU':
val = val[1:]
# 3. If the whole string is the same, return the original node.
if val == node.value:
return node # <--------------
# 4. Otherwise, create a new node.
new = node.clone()
new.value = val
return new
對於一些未知的原因,即使原始節點在步驟3中返回,lib2to3仍然解釋爲令牌樹被更改,所以它說「需要修改的文件」。但是,實際的源代碼是相同的,所以有「沒有更改foo.py」。
如果第3步返回None,它會真正地說「沒有文件需要修改」。
受影響的文件將被重寫爲原始輸入。所以這個bug是無害的。
作者:「修復者關心的東西」......這是什麼意思?我必須在意嗎? – JETM
@JETM澄清,這意味着該文件被檢查,而不是需要改變 –
而我認爲*我*吸吮在用戶界面。 ;) – JETM