[p4] Python mMarshalling problem

Robert Cowham robert at vaccaperna.co.uk
Tue Oct 5 07:40:27 PDT 2004


On Windows you have to do popen with mode 'rb' as opposed to just 'r' being
required on unix.

A little gotcha for the unwary.....

      if os.name == 'nt' :
		mstream = os.popen('p4 -G labels', 'rb')
	else:
		mstream = os.popen('p4 -G labels', 'r')

Robert

> -----Original Message-----
> From: perforce-user-admin at perforce.com
> [mailto:perforce-user-admin at perforce.com]On Behalf Of Smith, Jeff
> Sent: Tuesday, October 05, 2004 02:59
> To: perforce-user at perforce.com
> Subject: [p4] Python mMarshalling problem
>
>
> The attached python test script produces interesting results.
>
> When run on our UNIX systems of different flavors, it reports
> 	string lines = 1004
> 	marshaled lines = 1004
>
> On our Windows platforms, we get
> 	string lines = 1004
> 	marshaled lines = 188
>
> This has been run against Python 2.3.3 and 2.3.4 as well as Perforce
> 2002.2 and 2004.2
>
> Any input is appreciated,
> Jeff Smith
>
>
>
> import os
> import marshal
>
> slines = list()
> for line in os.popen('p4 labels'):
>     slines.append(line)
>
> mstream = os.popen('p4 -G labels')
> mlines = list()
> while 1:
>     try:
>         item = marshal.load(mstream)
>         mlines.append(item)
>     except EOFError:
>         break
>
> print 'string lines = ' + str(len(slines))
> print 'marshaled lines = ' + str(len(mlines))
>
> _______________________________________________
> perforce-user mailing list  -  perforce-user at perforce.com
> http://maillist.perforce.com/mailman/listinfo/perforce-user
>
>




More information about the perforce-user mailing list