Skip to content

Commit d40079c

Browse files
committed
update
Reset the lexical state when switching to a new input source so a source filename at the end of its parent stream does not cause the child stream to be skipped. Co-Authored-By: lipengyu <lipengyu@kylinos.cn>
1 parent aa48004 commit d40079c

1 file changed

Lines changed: 3 additions & 4 deletions

File tree

Lib/shlex.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,7 @@ def push_source(self, newstream, newfile=None):
7777
"Push an input source onto the lexer's input source stack."
7878
if isinstance(newstream, str):
7979
newstream = StringIO(newstream)
80-
self.filestack.appendleft((self.infile, self.instream, self.lineno,
81-
self.state))
80+
self.filestack.appendleft((self.infile, self.instream, self.lineno))
8281
self.infile = newfile
8382
self.instream = newstream
8483
self.lineno = 1
@@ -92,11 +91,11 @@ def push_source(self, newstream, newfile=None):
9291
def pop_source(self):
9392
"Pop the input source stack."
9493
self.instream.close()
95-
(self.infile, self.instream, self.lineno,
96-
self.state) = self.filestack.popleft()
94+
(self.infile, self.instream, self.lineno) = self.filestack.popleft()
9795
if self.debug:
9896
print('shlex: popping to %s, line %d' \
9997
% (self.instream, self.lineno))
98+
self.state = ' '
10099

101100
def get_token(self):
102101
"Get a token from the input stream (or from stack if it's nonempty)"

0 commit comments

Comments
 (0)