Commits

Kirill Simonov  committed 2d77d67

Fix !!python/name for Python 2.3. Clear the yaml module namespace.

  • Participants
  • Parent commits 36f7895

Comments (0)

Files changed (8)

File lib/yaml/__init__.py

 
 from error import *
 
-from reader import *
-from scanner import *
-from parser import *
-from composer import *
-from constructor import *
-
-from emitter import *
-from serializer import *
-from representer import *
-
-from resolver import *
-
 from tokens import *
 from events import *
 from nodes import *

File lib/yaml/constructor.py

             raise ConstructorError("while constructing a Python object", mark,
                     "expected non-empty name appended to the tag", mark)
         if u'.' in name:
-            module_name, object_name = name.rsplit('.', 1)
+            # Python 2.4 only
+            #module_name, object_name = name.rsplit('.', 1)
+            items = name.split('.')
+            object_name = items.pop()
+            module_name = '.'.join(items)
         else:
             module_name = '__builtin__'
             object_name = name

File tests/data/construct-python-name-module.code

-[file, Loader, dump, abs, xml.parsers]
+[file, Loader, dump, abs, yaml.tokens]

File tests/data/construct-python-name-module.data

 - !!python/name:yaml.Loader
 - !!python/name:yaml.dump
 - !!python/name:abs
-- !!python/module:xml.parsers
+- !!python/module:yaml.tokens

File tests/test_appliance.py

 import unittest, os
 
 from yaml import *
+from yaml.composer import *
+from yaml.constructor import *
+from yaml.resolver import *
 
 class TestAppliance(unittest.TestCase):
 

File tests/test_constructor.py

 
 from yaml import *
 
-import xml.parsers
+import yaml.tokens
 
 class MyLoader(Loader):
     pass

File tests/test_errors.py

     def _emit(self, events):
         try:
             emit(events)
-        except EmitterError, exc:
+        except YAMLError, exc:
             #print '.'*70
             #print "%s:" % exc.__class__.__name__, exc
             raise

File tests/test_structure.py

 
 TestResolver.add_tests('testResolver', '.data', '.canonical')
 
-class MyConstructor:
-
+class MyLoader(Loader):
     def construct_sequence(self, node):
-        return tuple(Constructor.construct_sequence(self, node))
+        return tuple(Loader.construct_sequence(self, node))
 
     def construct_mapping(self, node):
         pairs = self.construct_pairs(node)
     def construct_undefined(self, node):
         return self.construct_scalar(node)
 
-class MyLoader(MyConstructor, Loader):
-    pass
 MyLoader.add_constructor(None, MyLoader.construct_undefined)
 
-class MyCanonicalLoader(MyConstructor, test_appliance.CanonicalLoader):
-    pass
+class MyCanonicalLoader(test_appliance.CanonicalLoader):
+
+    def construct_sequence(self, node):
+        return tuple(test_appliance.CanonicalLoader.construct_sequence(self, node))
+
+    def construct_mapping(self, node):
+        pairs = self.construct_pairs(node)
+        pairs.sort()
+        return pairs
+
+    def construct_undefined(self, node):
+        return self.construct_scalar(node)
+
 MyCanonicalLoader.add_constructor(None, MyCanonicalLoader.construct_undefined)
 
 class TestConstructor(test_appliance.TestAppliance):