code: def new_context(environment, template_name, blocks, vars=None,
                  shared=None, globals=None, locals=None):
      
      if vars is None:
          vars = {}
      if shared:
          parent = vars
      else:
          parent = dict(globals or (), **vars)
      if locals:
          # if the parent is shared a copy should be created because
          # we don't want to modify the dict passed
          if shared:
              parent = dict(parent)
          for key, value in iteritems(locals):
              if value is not missing:
                  parent[key] = value
      return environment.context_class(environment, parent, template_name,
                                       blocks)
docs: Internal helper to for context creation.