code: def from_unicode(text, origin = root):
      
  
      if not isinstance(text, unicode):
          raise ValueError("input to from_unicode() must be a unicode string")
      if not (origin is None or isinstance(origin, Name)):
          raise ValueError("origin must be a Name or None")
      labels = []
      label = u''
      escaping = False
      edigits = 0
      total = 0
      if text == u'@':
          text = u''
      if text:
          if text == u'.':
              return Name([''])        # no Unicode "u" on this constant!
          for c in text:
              if escaping:
                  if edigits == 0:
                      if c.isdigit():
                          total = int(c)
                          edigits += 1
                      else:
                          label += c
                          escaping = False
                  else:
                      if not c.isdigit():
                          raise BadEscape
                      total *= 10
                      total += int(c)
                      edigits += 1
                      if edigits == 3:
                          escaping = False
                          label += chr(total)
              elif c == u'.' or c == u'\u3002' or \
                   c == u'\uff0e' or c == u'\uff61':
                  if len(label) == 0:
                      raise EmptyLabel
                  labels.append(encodings.idna.ToASCII(label))
                  label = u''
              elif c == u'\\':
                  escaping = True
                  edigits = 0
                  total = 0
              else:
                  label += c
          if escaping:
              raise BadEscape
          if len(label) > 0:
              labels.append(encodings.idna.ToASCII(label))
          else:
              labels.append('')
      if (len(labels) == 0 or labels[-1] != '') and not origin is None:
          labels.extend(list(origin.labels))
      return Name(labels)
docs: Convert unicode text into a Name object.
  
      Lables are encoded in IDN ACE form.
  
      @rtype: dns.name.Name object