* pdb.py: set 'privileged' property when evaluating expressions
* string.py: change whitespace to include \r, \v and \f. When importing strop succeeds, re-evaluate meaning of letters.
This commit is contained in:
parent
1fc238a813
commit
8e2ec56cbc
|
@ -66,6 +66,7 @@ class Pdb(bdb.Bdb, cmd.Cmd):
|
||||||
if line[:1] == '!': line = line[1:]
|
if line[:1] == '!': line = line[1:]
|
||||||
locals = self.curframe.f_locals
|
locals = self.curframe.f_locals
|
||||||
globals = self.curframe.f_globals
|
globals = self.curframe.f_globals
|
||||||
|
globals['__privileged__'] = 1
|
||||||
try:
|
try:
|
||||||
exec(line + '\n', globals, locals)
|
exec(line + '\n', globals, locals)
|
||||||
except:
|
except:
|
||||||
|
@ -175,12 +176,14 @@ class Pdb(bdb.Bdb, cmd.Cmd):
|
||||||
do_rv = do_retval
|
do_rv = do_retval
|
||||||
|
|
||||||
def do_p(self, arg):
|
def do_p(self, arg):
|
||||||
|
self.curframe.f_globals['__privileged__'] = 1
|
||||||
try:
|
try:
|
||||||
value = eval(arg, self.curframe.f_globals, \
|
value = eval(arg, self.curframe.f_globals, \
|
||||||
self.curframe.f_locals)
|
self.curframe.f_locals)
|
||||||
except:
|
except:
|
||||||
print '***', sys.exc_type + ':', `sys.exc_value`
|
print '***', sys.exc_type + ':', `sys.exc_value`
|
||||||
return
|
return
|
||||||
|
|
||||||
print `value`
|
print `value`
|
||||||
|
|
||||||
def do_list(self, arg):
|
def do_list(self, arg):
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
# functions imported from built-in module "strop".
|
# functions imported from built-in module "strop".
|
||||||
|
|
||||||
# Some strings for ctype-style character classification
|
# Some strings for ctype-style character classification
|
||||||
whitespace = ' \t\n'
|
whitespace = ' \t\n\r\v\f'
|
||||||
lowercase = 'abcdefghijklmnopqrstuvwxyz'
|
lowercase = 'abcdefghijklmnopqrstuvwxyz'
|
||||||
uppercase = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
|
uppercase = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
|
||||||
letters = lowercase + uppercase
|
letters = lowercase + uppercase
|
||||||
|
@ -181,10 +181,13 @@ def expandtabs(s, tabsize):
|
||||||
|
|
||||||
# Try importing optional built-in module "strop" -- if it exists,
|
# Try importing optional built-in module "strop" -- if it exists,
|
||||||
# it redefines some string operations that are 100-1000 times faster.
|
# it redefines some string operations that are 100-1000 times faster.
|
||||||
|
# It also defines values for whitespace, lowercase and uppercase
|
||||||
|
# that match <ctype.h>'s definitions.
|
||||||
# The manipulation with index_error is needed for compatibility.
|
# The manipulation with index_error is needed for compatibility.
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from strop import *
|
from strop import *
|
||||||
|
letters = lowercase + uppercase
|
||||||
from strop import index
|
from strop import index
|
||||||
index_error = ValueError
|
index_error = ValueError
|
||||||
except ImportError:
|
except ImportError:
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
# functions imported from built-in module "strop".
|
# functions imported from built-in module "strop".
|
||||||
|
|
||||||
# Some strings for ctype-style character classification
|
# Some strings for ctype-style character classification
|
||||||
whitespace = ' \t\n'
|
whitespace = ' \t\n\r\v\f'
|
||||||
lowercase = 'abcdefghijklmnopqrstuvwxyz'
|
lowercase = 'abcdefghijklmnopqrstuvwxyz'
|
||||||
uppercase = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
|
uppercase = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
|
||||||
letters = lowercase + uppercase
|
letters = lowercase + uppercase
|
||||||
|
@ -181,10 +181,13 @@ def expandtabs(s, tabsize):
|
||||||
|
|
||||||
# Try importing optional built-in module "strop" -- if it exists,
|
# Try importing optional built-in module "strop" -- if it exists,
|
||||||
# it redefines some string operations that are 100-1000 times faster.
|
# it redefines some string operations that are 100-1000 times faster.
|
||||||
|
# It also defines values for whitespace, lowercase and uppercase
|
||||||
|
# that match <ctype.h>'s definitions.
|
||||||
# The manipulation with index_error is needed for compatibility.
|
# The manipulation with index_error is needed for compatibility.
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from strop import *
|
from strop import *
|
||||||
|
letters = lowercase + uppercase
|
||||||
from strop import index
|
from strop import index
|
||||||
index_error = ValueError
|
index_error = ValueError
|
||||||
except ImportError:
|
except ImportError:
|
||||||
|
|
Loading…
Reference in New Issue