class_docstr: Adapt a range if the subtype doesn't need quotes.
class_docstr_tok: ["Adapt","a","range","if","the","subtype","does","n't","need","quotes","."]
code: def getquoted(self):
      r = self.adapted
      if r.isempty:
          return b"'empty'"
  
      if not r.lower_inf:
          # not exactly: we are relying that none of these object is really
          # quoted (they are numbers). Also, I'm lazy and not preparing the
          # adapter because I assume encoding doesn't matter for these
          # objects.
          lower = adapt(r.lower).getquoted().decode("ascii")
      else:
          lower = ""
  
      if not r.upper_inf:
          upper = adapt(r.upper).getquoted().decode("ascii")
      else:
          upper = ""
  
      return (f"'{r._bounds[0]}{lower},{upper}{r._bounds[1]}'").encode(
          "ascii"
      )
  
imports: import re
  from psycopg2._psycopg import ProgrammingError, InterfaceError
  from psycopg2.extensions import ISQLQuote, adapt, register_adapter
  from psycopg2.extensions import new_type, new_array_type, register_type
label_desc: Use image node_id 1 for calling the NumberRangeAdapter obj's underlying member method code with example usage: obj.getquoted() and returns: str, r, lower, str, upper, r, str, bytes