title: Python 3.6.3: Multiple "Exception ignored in: <generator object..." in flask app
body: <p>I'm running a flask app, upgraded everything from Python 2.7 to 3 about 5 months ago.</p>
  
  <p>Most things have gone smooth enough, other than this one that's consistently bugging me locally.  I'm on a MacBook on <code>OSX 10.12.6</code>, and a brew install of Python <code>3.6.3</code> under a virtualenv.</p>
  
  <p>When a request comes in from a page that seemingly has multiple static requests (.css, .js, and image files mainly), I seem to be able to get this error just about anywhere that's using generators anywhere in my code.</p>
  
  <p>Some examples (request is a <code>flask.request</code> object):</p>
  
  <p>A place that checks to see if a path starts with '/static' of '/admin/static' (my code), </p>
  
  <pre><code>any(request.path.startswith(k) for k in self._static_paths)
  </code></pre>
  
  <p>.</p>
  
  <pre><code>Exception ignored in: &lt;generator object CustomPrincipal._is_static_route.&lt;locals&gt;.&lt;genexpr&gt; at 0x11450f3b8&gt;
  Traceback (most recent call last):
    File "/Developer/repos/git/betapilibs/lbbsports/flask_monkeypatches.py", line 22, in &lt;genexpr&gt;
      any(_checker(request.path, k) for k in self._static_paths)
  SystemError: error return without exception set
  </code></pre>
  
  <p>If a url path is restricted, check if the logged in user has the proper permissions / role,</p>
  
  <pre><code>return role in (role.name for role in self.roles) 
  </code></pre>
  
  <p>.</p>
  
  <pre><code>Exception ignored in: &lt;generator object UserMixin.has_role.&lt;locals&gt;.&lt;genexpr&gt; at 0x1155a7e08&gt;
  Traceback (most recent call last):
    File "/Developer/virtualenvs/lbb3/lib/python3.6/site-packages/flask_security/core.py", line 386, in &lt;genexpr&gt;
  SystemError: error return without exception set
  </code></pre>
  
  <p>A custom bit of code to ensure their "sub" account id is valid,</p>
  
  <pre><code>(not any(ident == account_id for ident in account_ids))
  </code></pre>
  
  <p>.</p>
  
  <pre><code>Exception ignored in: &lt;generator object CustomSession.get_set_accounts.&lt;locals&gt;.&lt;genexpr&gt; at 0x115ff4fc0&gt;
  Traceback (most recent call last):
    File "/Developer/customflask/flasklogin.py", line 168, in &lt;genexpr&gt;
  SystemError: error return without exception set
  </code></pre>
  
  <p>Now, nothing <em>seems</em> to break in the system, I just get these error messages, and not consistently, only <em>sometimes</em>.  If I set a breakpoint anywhere these errors are being reported to be happening, they don't error any more.</p>
  
  <p>If I do something like, in the first example, break it into <code>request.path.startswith('/static') or request.path.startswith('/admin/static')</code>, I no longer get the error message, and in general, I never have a problem using request all over the place in the rest of the app.</p>