Skip to content
This repository was archived by the owner on Nov 3, 2023. It is now read-only.

Commit 1322f21

Browse files
author
Vladimir Keleshev
committed
Merge pull request #67 from jkrukoff/master
Allow for greater flexibility in parsing __all__.
2 parents a12f427 + 35b1129 commit 1322f21

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

pep257.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,8 @@ def parse_all(self):
235235
sys.stderr.write(msg)
236236
self.consume(tk.OP)
237237
s = '('
238+
while self.current.kind in (tk.NL, tk.COMMENT):
239+
self.stream.move()
238240
if self.current.kind != tk.STRING:
239241
raise AllError('Could not evaluate contents of __all__. ')
240242
while self.current.value not in ')]':

test_definitions.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,12 @@ def nested_3(self):
2929
__all__ = ['a', 'b'
3030
'c',]
3131
'''
32+
source_alt_nl_at_bracket = '''
33+
__all__ = [
34+
35+
# Inconvenient comment.
36+
'a', 'b' 'c',]
37+
'''
3238

3339

3440
def test_parser():
@@ -63,6 +69,11 @@ def test_parser():
6369
assert Module('file_alt.py', _, 1, len(source_alt.split('\n')),
6470
None, _, _, all) == module
6571

72+
module = parse(StringIO(source_alt_nl_at_bracket), 'file_alt_nl.py')
73+
assert Module('file_alt_nl.py', _, 1,
74+
len(source_alt_nl_at_bracket.split('\n')), None, _, _,
75+
all) == module
76+
6677

6778
def _test_module():
6879

0 commit comments

Comments
 (0)