Changeset 329


Ignore:
Timestamp:
12/29/08 13:11:08 (6 years ago)
Author:
xi
Message:

Fixed the remaining Python 3 compatibility issues.

Location:
pyyaml/trunk
Files:
2 added
14 edited

Legend:

Unmodified
Added
Removed
  • pyyaml/trunk/lib3/yaml/constructor.py

    r328 r329  
    510510            module_name, object_name = name.rsplit('.', 1) 
    511511        else: 
    512             module_name = '__builtin__' 
     512            module_name = 'builtins' 
    513513            object_name = name 
    514514        try: 
  • pyyaml/trunk/lib3/yaml/emitter.py

    r328 r329  
    181181            self.tag_prefixes = self.DEFAULT_TAG_PREFIXES.copy() 
    182182            if self.event.tags: 
    183                 handles = self.event.tags.keys() 
    184                 handles.sort() 
     183                handles = sorted(self.event.tags.keys()) 
    185184                for handle in handles: 
    186185                    prefix = self.event.tags[handle] 
  • pyyaml/trunk/tests3/data/construct-python-long-short.code

    r144 r329  
    1 123L 
     1123 
  • pyyaml/trunk/tests3/data/construct-python-name-module.code

    r322 r329  
    1 [file, yaml.Loader, yaml.dump, abs, yaml.tokens] 
     1[str, yaml.Loader, yaml.dump, abs, yaml.tokens] 
  • pyyaml/trunk/tests3/data/construct-python-name-module.data

    r146 r329  
    1 - !!python/name:file 
     1- !!python/name:str 
    22- !!python/name:yaml.Loader 
    33- !!python/name:yaml.dump 
  • pyyaml/trunk/tests3/data/construct-python-object.code

    r147 r329  
    88AState(1, 'two', [3,3,3]), 
    99ACustomState(1, 'two', [3,3,3]), 
    10  
    11 InitArgs(1, 'two', [3,3,3]), 
    12 InitArgsWithState(1, 'two', [3,3,3]), 
    1310 
    1411NewArgs(1, 'two', [3,3,3]), 
  • pyyaml/trunk/tests3/data/construct-python-object.data

    r147 r329  
    77- !!python/object:test_constructor.AState { _foo: 1, _bar: two, _baz: [3,3,3] } 
    88- !!python/object/new:test_constructor.ACustomState { state: !!python/tuple [1, two, [3,3,3]] } 
    9  
    10 - !!python/object/new:test_constructor.InitArgs [1, two, [3,3,3]] 
    11 - !!python/object/new:test_constructor.InitArgsWithState { args: [1, two], state: [3,3,3] } 
    129 
    1310- !!python/object/new:test_constructor.NewArgs [1, two, [3,3,3]] 
  • pyyaml/trunk/tests3/data/construct-python-str-utf8.code

    r144 r329  
    1 u'\u042d\u0442\u043e \u0443\u043d\u0438\u043a\u043e\u0434\u043d\u0430\u044f \u0441\u0442\u0440\u043e\u043a\u0430'.encode('utf-8') 
     1'\u042d\u0442\u043e \u0443\u043d\u0438\u043a\u043e\u0434\u043d\u0430\u044f \u0441\u0442\u0440\u043e\u043a\u0430' 
  • pyyaml/trunk/tests3/data/construct-python-unicode-ascii.code

    r144 r329  
    1 u"ascii string" 
     1"ascii string" 
  • pyyaml/trunk/tests3/data/construct-python-unicode-utf8.code

    r144 r329  
    1 u'\u042d\u0442\u043e \u0443\u043d\u0438\u043a\u043e\u0434\u043d\u0430\u044f \u0441\u0442\u0440\u043e\u043a\u0430' 
     1'\u042d\u0442\u043e \u0443\u043d\u0438\u043a\u043e\u0434\u043d\u0430\u044f \u0441\u0442\u0440\u043e\u043a\u0430' 
  • pyyaml/trunk/tests3/data/construct-str-utf8.code

    r144 r329  
    1 u'\u042d\u0442\u043e \u0443\u043d\u0438\u043a\u043e\u0434\u043d\u0430\u044f \u0441\u0442\u0440\u043e\u043a\u0430' 
     1'\u042d\u0442\u043e \u0443\u043d\u0438\u043a\u043e\u0434\u043d\u0430\u044f \u0441\u0442\u0440\u043e\u043a\u0430' 
  • pyyaml/trunk/tests3/data/recursive-set.recursive

    r228 r329  
    1 try: 
    2     set 
    3 except NameError: 
    4     from sets import Set as set 
    51value = set() 
    62value.add(AnInstance(foo=value, bar=value)) 
  • pyyaml/trunk/tests3/test_constructor.py

    r328 r329  
    77 
    88def execute(code): 
     9    global value 
    910    exec(code) 
    1011    return value 
     
    1213def _make_objects(): 
    1314    global MyLoader, MyDumper, MyTestClass1, MyTestClass2, MyTestClass3, YAMLObject1, YAMLObject2,  \ 
    14             AnObject, AnInstance, AState, ACustomState, InitArgs, InitArgsWithState,    \ 
    15             NewArgs, NewArgsWithState, Reduce, ReduceWithState, MyInt, MyList, MyDict,  \ 
    16             FixedOffset, execute 
     15            AnObject, AnInstance, AState, ACustomState, NewArgs, NewArgsWithState,  \ 
     16            Reduce, ReduceWithState, MyInt, MyList, MyDict, FixedOffset, execute 
    1717 
    1818    class MyLoader(yaml.Loader): 
     
    100100                return False 
    101101 
    102     class AnObject(object): 
     102    class AnObject: 
    103103        def __new__(cls, foo=None, bar=None, baz=None): 
    104104            self = object.__new__(cls) 
     
    143143        def __setstate__(self, state): 
    144144            self.foo, self.bar, self.baz = state 
    145  
    146     class InitArgs(AnInstance): 
    147         def __getinitargs__(self): 
    148             return (self.foo, self.bar, self.baz) 
    149         def __getstate__(self): 
    150             return {} 
    151  
    152     class InitArgsWithState(AnInstance): 
    153         def __getinitargs__(self): 
    154             return (self.foo, self.bar) 
    155         def __getstate__(self): 
    156             return self.baz 
    157         def __setstate__(self, state): 
    158             self.baz = state 
    159145 
    160146    class NewArgs(AnObject): 
  • pyyaml/trunk/tests3/test_recursive.py

    r328 r329  
    2424 
    2525def test_recursive(recursive_filename, verbose=False): 
    26     exec(open(recursive_filename, 'rb').read()) 
    27     value1 = value 
     26    context = globals().copy() 
     27    exec(open(recursive_filename, 'rb').read(), context) 
     28    value1 = context['value'] 
    2829    output1 = None 
    2930    value2 = None 
Note: See TracChangeset for help on using the changeset viewer.