leisurelicht/wtfpython-cn

字符串缓存中注释存在错误?

pruidong opened this issue · 5 comments

>>>a, b = "wtf!", "wtf!"
>>>a is b # 仅适用于3.7版本以下, 3.7以后的返回结果为False.
True

上述代码在Python 3.8中运行同样为True.注释存在错误.

运行环境: IDLE / Python 3.8.0 (tags/v3.8.0:fa919fd, Oct 14 2019, 19:37:50) [MSC v.1916 64 bit (AMD64)] on win32

相关连接地址.

https://github.com/leisurelicht/wtfpython-cn#-strings-can-be-tricky-sometimes%E5%BE%AE%E5%A6%99%E7%9A%84%E5%AD%97%E7%AC%A6%E4%B8%B2-

我本地下载个3.8试一下

>>> [(yield x) for x in some_iterable]
SyntaxError: 'yield' inside list comprehension
>>> [(yield x) for x in some_iterable]
SyntaxError: 'yield' inside list comprehension
>>> list([(yield x) for x in some_iterable])
SyntaxError: 'yield' inside list comprehension
>>> list((yield x) for x in some_iterable)
SyntaxError: 'yield' inside generator expression
>>> list(some_func((yield x)) for x in some_iterable)
SyntaxError: 'yield' inside generator expression

3.8中的idle运行上面的语句报错.

https://github.com/leisurelicht/wtfpython-cn#-yielding-none%E7%94%9F%E6%88%90-none

>>> [(yield x) for x in some_iterable]
SyntaxError: 'yield' inside list comprehension
>>> [(yield x) for x in some_iterable]
SyntaxError: 'yield' inside list comprehension
>>> list([(yield x) for x in some_iterable])
SyntaxError: 'yield' inside list comprehension
>>> list((yield x) for x in some_iterable)
SyntaxError: 'yield' inside generator expression
>>> list(some_func((yield x)) for x in some_iterable)
SyntaxError: 'yield' inside generator expression

3.8中的idle运行上面的语句报错.

https://github.com/leisurelicht/wtfpython-cn#-yielding-none%E7%94%9F%E6%88%90-none

3.8中把这个bug修复了,看这里.

>>>a, b = "wtf!", "wtf!"
>>>a is b # 仅适用于3.7版本以下, 3.7以后的返回结果为False.
True

上述代码在Python 3.8中运行同样为True.注释存在错误.

运行环境: IDLE / Python 3.8.0 (tags/v3.8.0:fa919fd, Oct 14 2019, 19:37:50) [MSC v.1916 64 bit (AMD64)] on win32

相关连接地址.

https://github.com/leisurelicht/wtfpython-cn#-strings-can-be-tricky-sometimes%E5%BE%AE%E5%A6%99%E7%9A%84%E5%AD%97%E7%AC%A6%E4%B8%B2-

我觉得应该是3.8中ast的实现方式有更新,不过我没在 new list 中找到说明。

好的,谢谢.