mirror of
https://github.com/python/cpython.git
synced 2025-07-23 19:25:40 +00:00
'mkpath()' now detects non-string 'name' arguments -- this is a fairly common
bug when adding new code, so I thought I'd make it blow up earlier than deep in posix.py.
This commit is contained in:
parent
46380906d1
commit
2d238c56a6
1 changed files with 7 additions and 1 deletions
|
@ -7,7 +7,8 @@ Utility functions for manipulating directories and directory trees."""
|
||||||
__revision__ = "$Id$"
|
__revision__ = "$Id$"
|
||||||
|
|
||||||
import os
|
import os
|
||||||
from distutils.errors import DistutilsFileError
|
from types import *
|
||||||
|
from distutils.errors import DistutilsFileError, DistutilsInternalError
|
||||||
|
|
||||||
|
|
||||||
# cache for by mkpath() -- in addition to cheapening redundant calls,
|
# cache for by mkpath() -- in addition to cheapening redundant calls,
|
||||||
|
@ -29,6 +30,11 @@ def mkpath (name, mode=0777, verbose=0, dry_run=0):
|
||||||
|
|
||||||
global PATH_CREATED
|
global PATH_CREATED
|
||||||
|
|
||||||
|
# Detect a common bug -- name is None
|
||||||
|
if type(name) is not StringType:
|
||||||
|
raise DistutilsInternalError, \
|
||||||
|
"mkpath: 'name' must be a string (got %s)" % `name`
|
||||||
|
|
||||||
# XXX what's the better way to handle verbosity? print as we create
|
# XXX what's the better way to handle verbosity? print as we create
|
||||||
# each directory in the path (the current behaviour), or only announce
|
# each directory in the path (the current behaviour), or only announce
|
||||||
# the creation of the whole path? (quite easy to do the latter since
|
# the creation of the whole path? (quite easy to do the latter since
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue