@@ -975,24 +975,27 @@ def _complete_expression(self, text, line, begidx, endidx):
975975        # complete builtins, and they clutter the namespace quite heavily, so we 
976976        # leave them out. 
977977        ns  =  {** self .curframe .f_globals , ** self .curframe .f_locals }
978-         if  text .startswith ("$" ):
979-             # Complete convenience variables 
980-             conv_vars  =  self .curframe .f_globals .get ('__pdb_convenience_variables' , {})
981-             return  [f"${ name }   for  name  in  conv_vars  if  name .startswith (text [1 :])]
982978        if  '.'  in  text :
983979            # Walk an attribute chain up to the last part, similar to what 
984980            # rlcompleter does.  This will bail if any of the parts are not 
985981            # simple attribute access, which is what we want. 
986982            dotted  =  text .split ('.' )
987983            try :
988-                 obj  =  ns [dotted [0 ]]
984+                 if  dotted [0 ].startswith ('$' ):
985+                     obj  =  self .curframe .f_globals ['__pdb_convenience_variables' ][dotted [0 ][1 :]]
986+                 else :
987+                     obj  =  ns [dotted [0 ]]
989988                for  part  in  dotted [1 :- 1 ]:
990989                    obj  =  getattr (obj , part )
991990            except  (KeyError , AttributeError ):
992991                return  []
993992            prefix  =  '.' .join (dotted [:- 1 ]) +  '.' 
994993            return  [prefix  +  n  for  n  in  dir (obj ) if  n .startswith (dotted [- 1 ])]
995994        else :
995+             if  text .startswith ("$" ):
996+                 # Complete convenience variables 
997+                 conv_vars  =  self .curframe .f_globals .get ('__pdb_convenience_variables' , {})
998+                 return  [f"${ name }   for  name  in  conv_vars  if  name .startswith (text [1 :])]
996999            # Complete a simple name. 
9971000            return  [n  for  n  in  ns .keys () if  n .startswith (text )]
9981001
0 commit comments