[p4python] P4.fetch_client() and pickle

Tony Whitley (Hotmail) tony_whitley at hotmail.com
Wed Sep 17 10:26:09 PDT 2008

(At the risk of having another trivial error pointed out!) I'm seeing problems with fetch_client() and pickle.dump() and put together this test script

  import P4, pickle, marshal

  p4c = P4.P4()


  info = p4c.run("info") # Run "p4 info" (returns a dict)
  version = info[0]['serverVersion'] # Get server version
  print version

  p4client_archive = open( r'c:\p4clients\twhitley_qtf_bits.text', 'wb')

  client = "twhitley_qtf_bits"
  spec = p4c.fetch_client(client)
  print spec

  # work-round using marshal
  str = marshal.dumps(spec)
  spec = marshal.loads(str)

  pickle.dump(spec, p4client_archive)
  print "pickle.dump works after marshalling/unmarshalling"
  print "but try it without and...\n"
  spec = p4c.fetch_client(client)
  pickle.dump(spec, p4client_archive)            (line 24)

It results in

  P4D/LINUX26X86_64/2008.1/164042 (2008/09/07)
  {'Description': 'Created by twhitley.\n', 'Host': 'twhitley2', 'Client': 'twhitley_qtf_bits', 'Owner': 'twhitley', 'LineEnd': 'local', 'View': ['//thi
  rdparty/... //twhitley_qtf_bits/thirdparty/...', '//source/... //twhitley_qtf_bits/source/...', '//depot/... //twhitley_qtf_bits/depot/...', '//deploy
  /... //twhitley_qtf_bits/deploy/...'], 'Root': 'c:\\tools\\p4\\P4Python\\MyClients', 'Options': 'noallwrite noclobber nocompress unlocked nomodtime no
  rmdir', 'SubmitOptions': 'submitunchanged'}
  pickle.dump works after marshalling/unmarshalling
  but try it without and...

  Traceback (most recent call last):
    File "pickletest.py", line 24, in <module>
      pickle.dump(spec, p4client_archive)
    File "c:\utils\python\lib\pickle.py", line 1362, in dump
      Pickler(file, protocol).dump(obj)
    File "c:\utils\python\lib\pickle.py", line 224, in dump
    File "c:\utils\python\lib\pickle.py", line 306, in save
      rv = reduce(self.proto)

>python --version
Python 2.5.2

(I upgraded from 2.5.1 in case something had been fixed)

Running on Windows XP. P4python 2008.1. 

Completely consistent, whichever client spec I read.


It was never a problem with the earlier "unofficial" p4python. I can use the data in 'spec' without any problems.

Tony Whitley
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://maillist.perforce.com/pipermail/p4python/attachments/20080917/2c0b31fa/attachment-0001.html>

More information about the p4python mailing list