Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
satella
Manage
Activity
Members
Labels
Plan
Issues
1
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
public
satella
Commits
c46885c4
Commit
c46885c4
authored
5 years ago
by
Piotr Maślanka
Browse files
Options
Downloads
Patches
Plain Diff
fixes
parent
73c62d3d
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
satella/coding/iterators.py
+4
-8
4 additions, 8 deletions
satella/coding/iterators.py
tests/test_coding/test_iterators.py
+2
-2
2 additions, 2 deletions
tests/test_coding/test_iterators.py
with
6 additions
and
10 deletions
satella/coding/iterators.py
+
4
−
8
View file @
c46885c4
...
...
@@ -10,7 +10,7 @@ def exhaust(iterator: tp.Iterator):
try
:
while
True
:
next
(
iterator
)
except
(
GeneratorExit
,
StopIteration
)
:
except
StopIteration
:
pass
...
...
@@ -42,7 +42,7 @@ class SelfClosingGenerator:
def
__next__
(
self
):
try
:
return
next
(
self
.
generator
)
except
(
StopIteration
,
GeneratorExit
)
:
except
StopIteration
:
self
.
stopped
=
True
raise
...
...
@@ -51,15 +51,11 @@ class SelfClosingGenerator:
try
:
exhaust
(
self
.
generator
)
except
TypeError
:
pass
pass
# we got a generator-generating function as an argument
self
.
stopped
=
True
raise
GeneratorExit
()
def
__del__
(
self
):
try
:
self
.
close
()
except
GeneratorExit
:
pass
self
.
close
()
# noinspection PyPep8Naming
...
...
This diff is collapsed.
Click to expand it.
tests/test_coding/test_iterators.py
+
2
−
2
View file @
c46885c4
...
...
@@ -22,8 +22,8 @@ class TestIterators(unittest.TestCase):
yield
i
a
[
'
done
'
]
=
True
for
i
in
SelfClosingGenerator
(
generator
)():
if
i
==
2
:
for
a
in
SelfClosingGenerator
(
generator
)():
if
a
==
2
:
break
self
.
assertTrue
(
a
[
'
done
'
])
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment