From 4390e0e17cb76618d94523230cfca665aac0c93d Mon Sep 17 00:00:00 2001
From: Steven Michalske <smichalske@gmail.com>
Date: Thu, 5 Aug 2010 00:40:02 -0700
Subject: [PATCH] Fix custom tags in pyyaml interface

---
 lib/yaml/__init__.py  |   11 +++++++++--
 lib3/yaml/__init__.py |   12 ++++++++++--
 2 files changed, 19 insertions(+), 4 deletions(-)

diff --git a/lib/yaml/__init__.py b/lib/yaml/__init__.py
index c0fd1f3..6e461b9 100644
--- a/lib/yaml/__init__.py
+++ b/lib/yaml/__init__.py
@@ -10,9 +10,14 @@ from dumper import *
 
 __version__ = '3.09'
 
+Loaders = [Loader]
+Dumpers = [Dumper]
+
 try:
     from cyaml import *
     __with_libyaml__ = True
+    Loaders.append(CLoader)
+    Dumpers.append(CDumper)
 except ImportError:
     __with_libyaml__ = False
 
@@ -253,8 +258,10 @@ class YAMLObjectMetaclass(type):
     def __init__(cls, name, bases, kwds):
         super(YAMLObjectMetaclass, cls).__init__(name, bases, kwds)
         if 'yaml_tag' in kwds and kwds['yaml_tag'] is not None:
-            cls.yaml_loader.add_constructor(cls.yaml_tag, cls.from_yaml)
-            cls.yaml_dumper.add_representer(cls, cls.to_yaml)
+            for l in Loaders:
+                l.add_constructor(cls.yaml_tag, cls.from_yaml)
+            for d in Dumpers:
+                d.add_representer(cls, cls.to_yaml)
 
 class YAMLObject(object):
     """
diff --git a/lib3/yaml/__init__.py b/lib3/yaml/__init__.py
index cd2ea5a..994c708 100644
--- a/lib3/yaml/__init__.py
+++ b/lib3/yaml/__init__.py
@@ -9,9 +9,15 @@ from .loader import *
 from .dumper import *
 
 __version__ = '3.09'
+
+Loaders = [Loader]
+Dumpers = [Dumper]
+
 try:
     from .cyaml import *
     __with_libyaml__ = True
+    Loaders.append(CLoader)
+    Dumpers.append(CDumper)
 except ImportError:
     __with_libyaml__ = False
 
@@ -251,8 +257,10 @@ class YAMLObjectMetaclass(type):
     def __init__(cls, name, bases, kwds):
         super(YAMLObjectMetaclass, cls).__init__(name, bases, kwds)
         if 'yaml_tag' in kwds and kwds['yaml_tag'] is not None:
-            cls.yaml_loader.add_constructor(cls.yaml_tag, cls.from_yaml)
-            cls.yaml_dumper.add_representer(cls, cls.to_yaml)
+            for l in Loaders:
+                l.add_constructor(cls.yaml_tag, cls.from_yaml)
+            for d in Dumpers:
+                d.add_representer(cls, cls.to_yaml)
 
 class YAMLObject(metaclass=YAMLObjectMetaclass):
     """
-- 
1.7.1.1

