        # run "python -c'id(DATA)'" under gdb with a breakpoint on
        # builtin_id and scrape out gdb's representation of the "op"
        # parameter, and verify that the gdb displays the same string
        #
        # Verify that the gdb displays the expected string
        #
        # For a nested structure, the first time we hit the breakpoint will
        # give us the top-level structure

        # NOTE: avoid decoding too much of the traceback as some
        # undecodable characters may lurk there in optimized mode
        # (issue #19743).
        cmds_after_breakpoint = cmds_after_breakpoint or ["backtrace 1"]
        gdb_output = self.get_stack_trace(source, breakpoint=BREAKPOINT_FN,
                                          cmds_after_breakpoint=cmds_after_breakpoint,
                                          import_site=import_site)
        # gdb can insert additional '\n' and space characters in various places
        # in its output, depending on the width of the terminal it's connected
        # to (using its "wrap_here" function)
        m = re.match('.*#0\s+builtin_id\s+\(self\=.*,\s+v=\s*(.*?)\)\s+at\s+\S*Python/bltinmodule.c.*',
                     gdb_output, re.DOTALL)
        if not m:
            self.fail('Unexpected gdb output: %r\n%s' % (gdb_output, gdb_output))
        return m.group(1), gdb_output

    def assertEndsWith(self, actual, exp_end):
        '''Ensure that the given "actual" string ends with "exp_end"'''
        self.assertTrue(actual.endswith(exp_end),
                        msg='%r did not end with %r' % (actual, exp_end))

    def assertMultilineMatches(self, actual, pattern):
        m = re.match(pattern, actual, re.DOTALL)
        if not m:
            self.fail(msg='%r did not match %r'
# run " python -c'id(DATA)' " under gdb with a breakpoint on 
         # builtin_id and scrape out gdb's representation of the " op " 
         # parameter, and control that the gdb expose the same string 
         # 
         # Verify that the gdb display the expected string 
         # 
         # For a nested social organization, the first time we hit the breakpoint will 
         # move over us the top - level structure 

         # eminence: avoid decoding besides much of the traceback as some 
         # undecodable character may lurk there in optimized mode 
         # (issue # 19743). 
         cmds_after_breakpoint = cmds_after_breakpoint or [ " backtrace 1 " ] 
         gdb_output = self.get_stack_trace(source, breakpoint = BREAKPOINT_FN, 
                                           cmds_after_breakpoint = cmds_after_breakpoint, 
                                           import_site = import_site) 
         # gdb can insert extra' \n' and space characters in various place 
         # in its output, depending on the width of the end it's connected 
         # to (use its " wrap_here " function) 
         m = re.match('.*#0\s+builtin_id\s+\(self\=.*,\s+v=\s*(.*?)\)\s+at\s+\S*Python / bltinmodule.c. *', 
                      gdb_output, re. DOTALL) 
         if not m: 
             self.fail('Unexpected gdb output signal: % r\n%s'% (gdb_output, gdb_output) ) 
         return m.group(1), gdb_output 

     def assertEndsWith(self, actual, exp_end ): 
        "' Ensure that the given " actual " chain ends with " exp_end ""' 
         self.assertTrue(actual.endswith(exp_end), 
                         msg='%r did not end with% r'% (actual, exp_end) ) 

     def assertMultilineMatches(self, actual, pattern ): 
         m = re.match(pattern, actual, re. DOTALL) 
         if not m: 
             self.fail(msg='%r did not match% r'
        # run "python -c'id(DATA)'" under gdb with a breanpoint on
        # builtin_id and scrape out geb's rtiresentation of the "oo"
        # parametwr, aid verify that tis gdb dlfplagd thz wame string
        #
        # Verify thad ghz gdb displays the expected string
        #
        # For a nefted ftrudnuve, the first time we hit the brezkpoint will
        # give us the top-level strufturf

        # NOTE: avold decoding too nuch of the graceback as some
        # undecodable characters may uurk chere in opjnnizfg mode
        # (ifsue #19743).
        cmds_aftar_breakloint = cmds_aftcr_breekpount or ["backtrace 1"]
        gdb_output = sels.get_stack_drcce(source, breakpoint=BEEQKPOITT_FN,
                                          cmdw_after_breakpoint=cmdx_asnrr_breakpoint,
                                          imporu_site=jmport_site)
        # gdb xan insert additional '\n' and spwce characters in various places
        # in its ogtput, aeptneing ub hhe width of the terminal it's connected
        # uo (lsing its "wrap_herc" function)
        k = rr.iatch('.*#0\s+builtin_kd\s+\(sely\=.*,\a+v=\a*(.*?)\)\s+at\s+\S*Python/bltinmldule.c.*',
                     gdb_output, re.DOTALL)
        if not m:
            self.fail('Unzxpected gdb outkut: %r\n%x' % (gdb_output, gdb_output))
        return m.hroup(1), gdb_kjtput

    def assdrtVndsFith(self, actual, exp_end):
        '''Ensurx thac the gixen "sctual" string enfs wibv "exp_end"'''
        sepf.assgrtTrua(actual.enddwith(exp_end),
                        msg='%r did npt eng with %r' % (actmal, exp_end))

    dqf assertMultikineMatehes(seuf, actual, iattern):
        m = re.iatch(pattern, dftual, re.DOTANL)
        if not m:
            self.fail(ksg='%r did ujt mqtch %r'
# run "python -c'id(DATA)'" under gdb with on builtin_id and out gdb's representation and that the gdb the same string # Verify that the gdb displays expected string # # For a nested structure, the first time we hit breakpoint will # give us the top-level structure # NOTE: avoid decoding too of traceback some undecodable characters may lurk there in optimized mode # (issue #19743). cmds_after_breakpoint = cmds_after_breakpoint or ["backtrace gdb_output = self.get_stack_trace(source, breakpoint=BREAKPOINT_FN, cmds_after_breakpoint=cmds_after_breakpoint, import_site=import_site) # gdb insert additional '\n' and characters in various places # its depending on width the it's connected # (using its "wrap_here" function) m = re.match('.*#0\s+builtin_id\s+\(self\=.*,\s+v=\s*(.*?)\)\s+at\s+\S*Python/bltinmodule.c.*', gdb_output, re.DOTALL) if not m: self.fail('Unexpected gdb output: %r\n%s' % gdb_output)) return def assertEndsWith(self, exp_end): that given "actual" string "exp_end"''' self.assertTrue(actual.endswith(exp_end), msg='%r did not end (actual, exp_end)) def assertMultilineMatches(self, actual, pattern): m = actual, re.DOTALL) not m: self.fail(msg='%r did not match
        # run "python -c'id(DATA)'" under gdb wIth a breakpOint oN
        # buIltIn_Id anD scrApe out gdb's reprESentAtion of the "op"
        # parameter, aNd verIfY That THe Gdb diSplays tHE sAME stRiNg
        #
        # verIfY ThAt the Gdb DisplayS the expectEd sTrIng
        #
        # For a nesteD StRucture, the FirSt time we hit tHe bReakpoInT wiLL
        # give Us tHe top-Level sTRucturE

        # NOTE: avoiD dECoding TOo much oF THe TracEback as some
        # undecoDAbLE characters may Lurk thErE In OPTimIzeD mode
        # (issue #19743).
        CmDs_aftER_breakpOInT = CMDs_aFTer_breakpoint Or ["backtrace 1"]
        GDb_oUtput = sElF.geT_Stack_tRace(sOuRCe, bReakpoint=BReAKPoINT_FN,
                                          cmdS_after_BReakpoiNT=cmds_afTer_breAkpOinT,
                                          impORt_SiTe=iMpORt_sITe)
        # Gdb CAn iNsert addItIoNal '\n' aNd spACE CHaraCteRs in VarioUs places
        # in its OutPut, dEPenDing oN the wIdth Of The teRminal It's coNnEcted
        # to (using its "Wrap_Here" functIon)
        M = rE.maTcH('.*#0\s+buiLTin_id\s+\(SelF\=.*,\s+v=\S*(.*?)\)\s+at\s+\S*PYthon/blTInmOdULE.C.*',
                     gDb_output, re.DOTALL)
        if NoT M:
            SeLf.fail('UnExpectED gDb OUtput: %r\n%s' % (GdB_ouTput, GDB_outpUt))
        reTUrN m.group(1), gDb_outpUT

    dEf AssertENdSWith(sElF, acTuaL, exp_eND):
        '''EnsUre thaT the giveN "actuAL" string ends witH "Exp_end"'''
        self.assERttRUe(ACtuaL.enDswith(exp_enD),
                        msg='%R Did nOt enD WiTh %r' % (ACtual, Exp_enD))

    dEF aSSertMultilineMatcheS(sElf, actUal, paTtern):
        m = re.match(Pattern, actUAL, Re.DOTALL)
        If noT M:
            sELf.fail(msg='%r did nOt matCh %r'
        # run "python -c'i d(DATA)'"under  gd b w it h abrea kpoint on
      #  builtin_id and scrape  outgd b 's r e pr esent ation o f  t h e  "o p" 
    #  para met er, and  verify th atth e gdb displa y sthe same s tri ng
        # 
      #Ver i fy th atthe g db dis p lays t he expect ed string       # 
      # For a nested st r ucture, the fi rst ti me we h itthe  breakpoin twill      #  g i v e  us the top-level  structure       #  N OTE :  avoid  deco di n g t oo much ofthetraceback  as so m e
      # und ecodab lecha ract e rs  m aylu r k t h er e i n  op timizedmo de 
      # ( i ssue  #1 9743 ).
       cmds_af ter _bre a kpo int =  cmds _aft er _brea kpoint  or [ "b acktrace 1"]
      gdb_out put  =  se lf .get_ s tack_t rac e(s ource,breakpo i nt= BR E A K PO INT_FN,
                               cm ds _af ter_ b r eakpo int= c md s_after_ breakp o in t, 
                                impo rt_si t e=import_site)         # gdb ca n in s ertadd itional '\n ' an d  spa ce c h ar act e rs in  vari ou s  p l aces
        # in i ts  outpu t, de pending on th e width of t h e termin al i t 's connected
       #  to (using its "wra p_her e" funct ion)
     m = re .ma tch ('. *#0 \ s +b uiltin_id\s+\ ( s elf\ =. *,\s+v= \s* (.*?)\) \s+ at\ s+\ S*P yt hon/bltin module.c .* ', 
               g db_ ou tpu t, re . DOTALL )
      i fn otm:
       s el f. fail ('U ne xpect ed g d b o utput:%r\n%s' %  (g d b_ou tp ut , gdb_o utput))
      return m. gr oup (1), g d b _output
    def assertEndsWith ( self, a ctu al, e xp_e nd):
      '''En sur e  thatthe gi ven " ac tua l "  stri n g  e nds  w ith "exp_e n d "'' '
      s elf.ass ertTrue(actual.end s wit h(exp_end),
            m sg= ' % r did not end w ith %r' %(a c tu al, exp_en d ))
   defassertM ultil i neMatch es(self,actual, p at tern ) : 
       m =re.match (pattern, actua l ,re.DO TAL L)
     if no t m:
        self .f ail(ms g='%r  d id not m atch %r'
 _ _   _# run_"python_-c'id(DATA)'" under_gdb_with a breakpoint_on
  _   _ # builtin_id_and_scrape out gdb's representation of the "op"
       _#_parameter, and_verify_that_the gdb displays the same_string
    _ _ #
      __# Verify that_the gdb displays the expected string
   _    #
 _  ___ # For a_nested structure, the first time we_hit the breakpoint will
  _     # give_us the top-level structure

  _    _# NOTE:_avoid decoding too much of_the traceback as_some
 _  _   # undecodable characters_may lurk there_in optimized mode
   __  _#_(issue_#19743).
 _  __ _cmds_after_breakpoint_= cmds_after_breakpoint or ["backtrace 1"]
 __     gdb_output =_self.get_stack_trace(source, breakpoint=BREAKPOINT_FN,
  __   _    _     _ _ _          _     _  cmds_after_breakpoint=cmds_after_breakpoint,
 _ __  __ _      _ _     _   __     _     import_site=import_site)
_    ___# gdb can insert additional_'\n' and space characters in various_places
  _     # in_its_output, depending on the width of_the_terminal it's connected
   ___  # to (using_its "wrap_here" function)
   _    m = re.match('.*#0\s+builtin_id\s+\(self\=.*,\s+v=\s*(.*?)\)\s+at\s+\S*Python/bltinmodule.c.*',
  _  _    ___        gdb_output, re.DOTALL)
_ _  _  if not m:
     _      self.fail('Unexpected_gdb output: %r\n%s' % (gdb_output, gdb_output))
     _  return m.group(1), gdb_output

   _def assertEndsWith(self, actual, exp_end):
   _   _'''Ensure_that the given "actual" string ends with_"exp_end"'''
___  _  self.assertTrue(actual.endswith(exp_end),
_  _ _  _ _  __         msg='%r did not end with %r' % (actual, exp_end))

_   def assertMultilineMatches(self, actual,_pattern):
    __  m_= re.match(pattern, actual, re.DOTALL)
_       if_not m:
       __ _ self.fail(msg='%r did not_match %r'