code: def expand_braces(patterns, flags):
      
  
      if flags & BRACE:
          for p in ([patterns] if isinstance(patterns, (str, bytes)) else patterns):
              try:
                  yield from bracex.iexpand(p, keep_escapes=True)
              except Exception:  # pragma: no cover
                  # We will probably never hit this as `bracex`
                  # doesn't throw any specific exceptions and
                  # should normally always parse, but just in case.
                  yield p
      else:
          for p in ([patterns] if isinstance(patterns, (str, bytes)) else patterns):
              yield p
docs: Expand braces.