This fixes a DeepSource alert:
Unguarded next inside generator
Calls to `next()` should be inside `try-except` block.
When the iterator is exhausted, `StopIteration` exception is raised. When
used inside a generator, this can cause unexpected behavior. If not
handled, it will propagate out of the generator causing termination.
PEP-479 has been accepted to fix this problem. It will modify the
behavior of `StopIteration` in generators.
Each call to `next()` should be wrapped in a `try-except` block to explicitly
handle `StopIteration` exceptions.
Signed-off-by: Dimitri Papadopoulos <3350651-DimitriPapadopoulos@users.noreply.gitlab.com>
Veuillez saisir le message de validation pour vos modifications. Les lignes
# Build openconnect --cookie argument from the result:
url = urlparse(res.url)
-if any(c.name == 'MRHSession' for c in s.cookies) and url.path.startswith('/vdesk/'):
- cookie = next(c.value for c in s.cookies if c.name == 'MRHSession')
+cookie = next((c.value for c in s.cookies if c.name == 'MRHSession'), None)
+if cookie and url.path.startswith('/vdesk/'):
if args.verbose:
if cert:
cert_and_key = ' \\\n ' + ' '.join('%s "%s"' % (opt, quote(fn)) for opt, fn in zip(('-c', '-k'), cert) if fn)
# Build openconnect --cookie argument from the result:
url = urlparse(res.url)
-if any(c.name == 'SVPNCOOKIE' and c.value for c in s.cookies):
- cookie = next(c.value for c in s.cookies if c.name == 'SVPNCOOKIE')
+cookie = next(c.value for c in s.cookies if c.name == 'SVPNCOOKIE' and c.value, None)
+if cookie:
if args.verbose:
if cert:
cert_and_key = ' \\\n ' + ' '.join('%s "%s"' % (opt, quote(fn)) for opt, fn in zip(('-c', '-k'), cert) if fn)