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 51m0n
Recipients 51m0n
Date 2013-11-08.14:58:13
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1383922694.77.0.246440943969.issue19528@psf.upfronthosting.co.za>
In-reply-to
Content
When attempting to use a config file with logging to set up a series of loggers in a script, when running on windows, if the config file name starts with an 'r' then the script fails with the following error:-

 File "C:\Users\simon\Documents\python dev\RepositoryChainPkg\FileLogger.py", line 45, in fileConfig
    logging.config.fileConfig(FileLogger.CONF_FILENAME)
  File "C:\Python27\lib\logging\config.py", line 78, in fileConfig
    handlers = _install_handlers(cp, formatters)
  File "C:\Python27\lib\logging\config.py", line 156, in _install_handlers
    h = klass(*args)
  File "C:\Python27\lib\logging\handlers.py", line 117, in __init__
    BaseRotatingHandler.__init__(self, filename, mode, encoding, delay)
  File "C:\Python27\lib\logging\handlers.py", line 64, in __init__
    logging.FileHandler.__init__(self, filename, mode, encoding, delay)
  File "C:\Python27\lib\logging\__init__.py", line 902, in __init__
    StreamHandler.__init__(self, self._open())
  File "C:\Python27\lib\logging\__init__.py", line 925, in _open
    stream = open(self.baseFilename, self.mode)
IOError: [Errno 22] invalid mode ('a') or filename: 'C:\\Users\\simon\repositoryChainLogging\repo_log.log'

The same script works perfectly on linux and solaris.

Points to note, the config filename (and path) is listed in the error as:-

'C:\\Users\\simon\repositoryChainLogging\repo_log.log'

Yet when it is passed to logging\config.py as parameter fname in function fileConfig it is:-
b'C:\\Users\\simon\\repositoryChainLogging\\repo_log.conf'

In other words the path passed in by the script is correctly seperated and escaped by os.path functions.

However in _install_handlers (line 133 of logging\config.py) the args = eval(args, vars(logging))line (154) gets the path back in this tuple:-

(b'C:\\Users\\snaish.BRIGHTON\repositoryChainLogging\repo_log.log', b'a', 131072,
 10)

Where it has clearly lost some of the escaping, rendering the path useless, since \r is a control character, and therefore invalidates the path.

Therefore at the moment it is impossible to use logging config fiels beginning with r onw windows at the moment.
History
Date User Action Args
2013-11-08 14:58:1451m0nsetrecipients: + 51m0n
2013-11-08 14:58:1451m0nsetmessageid: <1383922694.77.0.246440943969.issue19528@psf.upfronthosting.co.za>
2013-11-08 14:58:1451m0nlinkissue19528 messages
2013-11-08 14:58:1351m0ncreate