Index: Lib/shlex.py =================================================================== --- Lib/shlex.py (revision 77224) +++ Lib/shlex.py (working copy) @@ -209,14 +209,11 @@ else: continue elif nextchar in self.commenters: - self.instream.readline() - self.lineno = self.lineno + 1 if self.posix: - self.state = ' ' - if self.token or (self.posix and quoted): - break # emit current token - else: - continue + self.token = self.token + nextchar + else: + self.instream.readline() + self.lineno = self.lineno + 1 elif self.posix and nextchar in self.quotes: self.state = nextchar elif self.posix and nextchar in self.escape: Index: Lib/test/test_shlex.py =================================================================== --- Lib/test/test_shlex.py (revision 77224) +++ Lib/test/test_shlex.py (working copy) @@ -134,7 +134,7 @@ 'foo\ bar'|foo\ bar| 'foo\\ bar'|foo\\ bar| foo\ bar|foo bar| -foo#bar\nbaz|foo|baz| +foo#bar\nbaz|foo#bar|baz| :-) ;-)|:-)|;-)| αινσϊ|αινσϊ| """