deepcopy() of class binding results in a name space error

Help
2014-08-26
2014-08-26
  • Richard Neumann

    Richard Neumann - 2014-08-26

    Hi again,

    I need to create an independent copy of a class binding instance.
    Unfortunately deepcopy() results in some strange namespace errors:

    >>> oi2 = deepcopy(oi)
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
      File "/usr/lib/python3.4/copy.py", line 182, in deepcopy
        y = _reconstruct(x, rv, 1, memo)
      File "/usr/lib/python3.4/copy.py", line 300, in _reconstruct
        state = deepcopy(state, memo)
      File "/usr/lib/python3.4/copy.py", line 155, in deepcopy
        y = copier(x, memo)
      File "/usr/lib/python3.4/copy.py", line 246, in _deepcopy_dict
        y[deepcopy(key, memo)] = deepcopy(value, memo)
      File "/usr/lib/python3.4/copy.py", line 182, in deepcopy
        y = _reconstruct(x, rv, 1, memo)
      File "/usr/lib/python3.4/copy.py", line 300, in _reconstruct
        state = deepcopy(state, memo)
      File "/usr/lib/python3.4/copy.py", line 155, in deepcopy
        y = copier(x, memo)
      File "/usr/lib/python3.4/copy.py", line 246, in _deepcopy_dict
        y[deepcopy(key, memo)] = deepcopy(value, memo)
      File "/usr/lib/python3.4/copy.py", line 182, in deepcopy
        y = _reconstruct(x, rv, 1, memo)
      File "/usr/lib/python3.4/copy.py", line 300, in _reconstruct
        state = deepcopy(state, memo)
      File "/usr/lib/python3.4/copy.py", line 155, in deepcopy
        y = copier(x, memo)
      File "/usr/lib/python3.4/copy.py", line 246, in _deepcopy_dict
        y[deepcopy(key, memo)] = deepcopy(value, memo)
      File "/usr/lib/python3.4/copy.py", line 174, in deepcopy
        rv = reductor(2)
      File "/usr/lib/python3.4/site-packages/pyxb/namespace/__init__.py", line 679, in __getnewargs__
        raise pyxb.LogicError('Illegal to serialize absent namespaces')
    pyxb.exceptions_.LogicError: Illegal to serialize absent namespaces
    

    Is there another way to create an independent copy / clone of a class binding recursively?

     
  • Peter A. Bigot

    Peter A. Bigot - 2014-08-26

    Not that I'm aware of. I've added a github issue so this'll be worked next time I'm doing pyxb stuff.

     
  • Richard Neumann

    Richard Neumann - 2014-08-26

    That's unfortunate, but thanks for your quick reply.
    I work around this issue now with a self-made clone method like this:

    def clone(root):
        """
        Clones the class binding node
        """
        try:
            xmldata = root.toxml()
        except:
            return None
        else:
            try:
                clone_ = CreateFromDocument(xmldata)
            except:
                return None
            else:
                return clone_
    
     
    Last edit: Richard Neumann 2014-08-26

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks