Skip to content

Commit

Permalink
type check for Integral, bool by value (#675)
Browse files Browse the repository at this point in the history
  • Loading branch information
mmckerns authored Sep 9, 2024
1 parent a9d136b commit 9bf8ca7
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion dill/logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ def trace(arg: Union[bool, TextIO, str, os.PathLike] = None, *, mode: str = 'a')
arg: a boolean value, or an optional file-like or path-like object for the context manager
mode: mode string for ``open()`` if a file name is passed as the first argument
"""
if not isinstance(arg, bool):
if repr(arg) not in ('False', 'True'):
return TraceManager(file=arg, mode=mode)
logger.setLevel(logging.INFO if arg else logging.WARNING)

Expand Down
3 changes: 2 additions & 1 deletion dill/source.py
Original file line number Diff line number Diff line change
Expand Up @@ -481,7 +481,8 @@ def _isstring(object): #XXX: isstringlike better?
def indent(code, spaces=4):
'''indent a block of code with whitespace (default is 4 spaces)'''
indent = indentsize(code)
if type(spaces) is int: spaces = ' '*spaces
from numbers import Integral
if isinstance(spaces, Integral): spaces = ' '*spaces
# if '\t' is provided, will indent with a tab
nspaces = indentsize(spaces)
# blank lines (etc) need to be ignored
Expand Down

0 comments on commit 9bf8ca7

Please sign in to comment.