Ticket #283 (new defect)

Opened 21 months ago

PyYaml does not create logging handler classes correctly in Python 2.7

Reported by: jordi.puigsegur@… Owned by: xi
Priority: normal Component: pyyaml
Severity: normal Keywords: python 2.7 logging handlers


logging.FileHandler? and logging.RotatingFileHandler? (haven't tried other handlers) do not get correctly initialized in python 2.7 when loaded using PyYaml?.

This example reproduces the problem:

import logging
import logging.handlers
import yaml

logger = logging.getLogger() # root logger

# Option 1 - OK
##handler = logging.handlers.RotatingFileHandler(filename = "test.log", maxBytes = 262144, backupCount = 3)

# Option 2 - RotatingFileHandler fails when created through yaml
handler = yaml.load("""
        filename: test.log
        maxBytes: 262144
        backupCount: 3

# Option 3 - FileHandler also fails when created through yaml
##handler = yaml.load("""
##    kwds:
##        filename: test.log


logger.warning("test handler")

The example above works in python 2.6 and 2.5, but fails in python 2.7. In both cases I am using the latest version of PyYaml?: 3.10

I've opened a ticket in python ( and it seems that Logging changed from old-style classes in 2.6 to new-style classes in 2.7 and that may be the reason.



Add a comment

Modify Ticket

Change Properties
<Author field>
as new
as The resolution will be set. Next status will be 'closed'
to The owner will be changed from xi. Next status will be 'new'
The owner will be changed from xi to anonymous. Next status will be 'assigned'

E-mail address and user name can be saved in the Preferences.

Note: See TracTickets for help on using tickets.