Changeset 146


Ignore:
Timestamp:
04/21/06 13:31:29 (9 years ago)
Author:
xi
Message:

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

Location:
pyyaml/trunk
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • pyyaml/trunk/lib/yaml/__init__.py

    r137 r146  
    11 
    22from error import * 
    3  
    4 from reader import * 
    5 from scanner import * 
    6 from parser import * 
    7 from composer import * 
    8 from constructor import * 
    9  
    10 from emitter import * 
    11 from serializer import * 
    12 from representer import * 
    13  
    14 from resolver import * 
    153 
    164from tokens import * 
  • pyyaml/trunk/lib/yaml/constructor.py

    r142 r146  
    457457                    "expected non-empty name appended to the tag", mark) 
    458458        if u'.' in name: 
    459             module_name, object_name = name.rsplit('.', 1) 
     459            # Python 2.4 only 
     460            #module_name, object_name = name.rsplit('.', 1) 
     461            items = name.split('.') 
     462            object_name = items.pop() 
     463            module_name = '.'.join(items) 
    460464        else: 
    461465            module_name = '__builtin__' 
  • pyyaml/trunk/tests/data/construct-python-name-module.code

    r144 r146  
    1 [file, Loader, dump, abs, xml.parsers] 
     1[file, Loader, dump, abs, yaml.tokens] 
  • pyyaml/trunk/tests/data/construct-python-name-module.data

    r144 r146  
    33- !!python/name:yaml.dump 
    44- !!python/name:abs 
    5 - !!python/module:xml.parsers 
     5- !!python/module:yaml.tokens 
  • pyyaml/trunk/tests/test_appliance.py

    r137 r146  
    33 
    44from yaml import * 
     5from yaml.composer import * 
     6from yaml.constructor import * 
     7from yaml.resolver import * 
    58 
    69class TestAppliance(unittest.TestCase): 
  • pyyaml/trunk/tests/test_constructor.py

    r144 r146  
    1212from yaml import * 
    1313 
    14 import xml.parsers 
     14import yaml.tokens 
    1515 
    1616class MyLoader(Loader): 
  • pyyaml/trunk/tests/test_errors.py

    r141 r146  
    3737        try: 
    3838            emit(events) 
    39         except EmitterError, exc: 
     39        except YAMLError, exc: 
    4040            #print '.'*70 
    4141            #print "%s:" % exc.__class__.__name__, exc 
  • pyyaml/trunk/tests/test_structure.py

    r136 r146  
    142142TestResolver.add_tests('testResolver', '.data', '.canonical') 
    143143 
    144 class MyConstructor: 
    145  
     144class MyLoader(Loader): 
    146145    def construct_sequence(self, node): 
    147         return tuple(Constructor.construct_sequence(self, node)) 
     146        return tuple(Loader.construct_sequence(self, node)) 
    148147 
    149148    def construct_mapping(self, node): 
     
    155154        return self.construct_scalar(node) 
    156155 
    157 class MyLoader(MyConstructor, Loader): 
    158     pass 
    159156MyLoader.add_constructor(None, MyLoader.construct_undefined) 
    160157 
    161 class MyCanonicalLoader(MyConstructor, test_appliance.CanonicalLoader): 
    162     pass 
     158class MyCanonicalLoader(test_appliance.CanonicalLoader): 
     159 
     160    def construct_sequence(self, node): 
     161        return tuple(test_appliance.CanonicalLoader.construct_sequence(self, node)) 
     162 
     163    def construct_mapping(self, node): 
     164        pairs = self.construct_pairs(node) 
     165        pairs.sort() 
     166        return pairs 
     167 
     168    def construct_undefined(self, node): 
     169        return self.construct_scalar(node) 
     170 
    163171MyCanonicalLoader.add_constructor(None, MyCanonicalLoader.construct_undefined) 
    164172 
Note: See TracChangeset for help on using the changeset viewer.