This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author pepalogik
Recipients ezio.melotti, flox, georg.brandl, loewis, mark.dickinson, pepalogik, vstinner
Date 2013-02-06.12:24:44
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1360153485.13.0.651793958142.issue17137@psf.upfronthosting.co.za>
In-reply-to
Content
Here is a part of my code (with some comments added):

    for struct in ini_structures:
        dirname = wrkdir+os.sep+struct.name
        if not os.path.isdir(dirname):  # This works fine. If the directory doesn't exist,...
            try:
                os.mkdir(dirname)       # ... it is created here.
            except OSError:
                raise AutoLEEDError('Cannot create directory "'+dirname+'".')
        dirname += os.sep+'bulk'        # This defines a subdirectory.
        if not os.path.isdir(dirname): ## Though it doesn't exist, os.path.isdir returns True,...
            try:
                os.mkdir(dirname)       # ... so it is not created here.
            except OSError:
                raise AutoLEEDError('Cannot create directory "'+dirname+'".')
        fn = dirname+os.sep+'cluster.i' # This defines a filename.
        print('Writing file "'+fn+'"...')
        straos = struct.write_bulk_cluster(fn,at_rad) # Here it fails (cannot write to file).

According to Victor's post, I have inserted these lines before the line marked ## (and added necessary imports):

        print('dirname =', dirname)
        print('os.path.isdir(dirname) =', os.path.isdir(dirname))
        print('nt._isdir(dirname) =', nt._isdir(dirname))
        print('stat.S_ISDIR(os.stat(dirname).st_mode) =', stat.S_ISDIR(os.stat(dirname).st_mode))
        print(ascii(dirname.encode("unicode_internal")))
        print(ascii(dirname.encode("utf-8")))

Here is the output of these lines (that directory really does not exist but its parent directory does):

dirname = D:\Bug reports\Python\AutoLEED\default\sub-fcc\bulk
os.path.isdir(dirname) = True
nt._isdir(dirname) = True
stat.S_ISDIR(os.stat(dirname).st_mode) = True
b'D\x00:\x00\\\x00B\x00u\x00g\x00 \x00r\x00e\x00p\x00o\x00r\x00t\x00s\x00\\\x00P\x00y\x00t\x00h\x00o\x00n\x00\\\x00A\x00u\x00t\x00o\x00L\x00E\x00E\x00D\x00\\\x00d\x00e\x00f\x00a\x00u\x00l\x00t\x00\\\x00s\x00u\x00b\x00-\x00f\x00c\x00c\x00\x00\x002\x00\x03\x00\x00\x00\x00\x00'
b'D:\\Bug reports\\Python\\AutoLEED\\default\\sub-fcc\\bulk'

Yeah, the result of ascii(dirname.encode("unicode_internal")) seems to be wrong (at the end).
History
Date User Action Args
2013-02-06 12:24:45pepalogiksetrecipients: + pepalogik, loewis, georg.brandl, mark.dickinson, vstinner, ezio.melotti, flox
2013-02-06 12:24:45pepalogiksetmessageid: <1360153485.13.0.651793958142.issue17137@psf.upfronthosting.co.za>
2013-02-06 12:24:45pepalogiklinkissue17137 messages
2013-02-06 12:24:44pepalogikcreate