fixed bug when python variables are referenced inside the shell-only context

fixed bug when python variables are referenced inside the shell-only context