Live data from Hacker News

5% of 666 Python repos had comma typo bugs (inc V8, TensorFlow and PyTorch)

codereviewdoctor.medium.com

1–10 of 339 posts

Re: 5% of 666 Python repos had comma typo bugs (inc V8, TensorFlow and PyTorch)

#3
tl;dr: Python concatenates space separated strings, so ['foo' 'bar'] becomes ['foobar'], leading to silent bugs due to typos.

I've been bitten by this one at work, and can't help but think it is an insane behaviour, given that ['foo' + 'bar'] explicitly concatenates the strings, and ['foo', 'bar'] is the much more common desired result.

edit: This also applies to un-separated strings, so ['foo''bar'] also becomes ['foobar']

Re: 5% of 666 Python repos had comma typo bugs (inc V8, TensorFlow and PyTorch)

#4
This seems like not a big deal. It’s a common mistake and is in 5% of repos but it’s not causing major damage.

And there’s no evaluation of importance as to whether these instances are in test files or non-critical code. Packages are big and can have hundreds or thousands of files.

It could be that if these mattered, they would have been detected and fixed.

A good example for unit tests and perhaps checking to see if these bugs are covered or not covered.

I like these kinds of analyses but don’t like the presented like it’s some significant failure.

Re: 5% of 666 Python repos had comma typo bugs (inc V8, TensorFlow and PyTorch)

#5
I really like the idea of automated code review tools that point out unusual or suspicious solutions and code patterns. Kind of like an advanced linter that looks deeper into the code structure. With emerging AI tools like Github Copilot, it seems like the inevitable future. Programming is very pattern-oriented and even though these kinds of tools might not necessarily be able to point out architectural flaws in a codebase, there might be lots of low-hanging fruits in this area and opportunities to add automated value.

Re: 5% of 666 Python repos had comma typo bugs (inc V8, TensorFlow and PyTorch)

#7
post #3

tl;dr: Python concatenates space separated strings, so ['foo' 'bar'] becomes ['foobar'], leading to silent bugs due to typos. I've been bitten by this one at work, and can't help but think it is an insane behaviour, given that ['foo' + 'bar'] explicitly concatenates the strings, and ['foo', 'bar'] is the much more common desired result. edit: This also applies to un-separated strings, so ['foo''bar'] also becomes ['f…

I assume it's based on the C behavior, where it can be handy with macros

I don't think it fits well in python

Re: 5% of 666 Python repos had comma typo bugs (inc V8, TensorFlow and PyTorch)

#10
post #3

tl;dr: Python concatenates space separated strings, so ['foo' 'bar'] becomes ['foobar'], leading to silent bugs due to typos. I've been bitten by this one at work, and can't help but think it is an insane behaviour, given that ['foo' + 'bar'] explicitly concatenates the strings, and ['foo', 'bar'] is the much more common desired result. edit: This also applies to un-separated strings, so ['foo''bar'] also becomes ['f…

I assume it's based on the C behavior, where it can be handy with macros I don't think it fits well in python

I assumed it was borrowed from shell, where everything can just be put next to eachother since it’s all text.
Post reply on HN