From: Robert W. B. <rb...@di...> - 2001-08-29 18:25:28
|
Hello Chris, Probably not pickle, but PyFile. Even without pickle, the following file is empty: open('junk.txt', 'w').write('This is a test') Currently, an explicit close() or flush() is required on the file. e.g. f = open('junkpickle.txt', 'w') pickle.dump(range(10), f) f.close() # or flush() This makes the following usage a bad idea <g> pickle.dump(range(10), open("pickle.txt", "w")) Yes, this was not required in 2.0, but this is the scoop since 2.1a1. Unfortuately, a search on PyFile in the checkins list doesn't return any hits (crummy Geocrawler). However, The diff between the 2.0 and 2.1a1 PyFile is sizable. I don't know if this change in autoflushing is intentional or not. It's worthy of a FAQ entry or a patch depending on the answer to that. -rb On Wed, 29 Aug 2001, Chris Meyers wrote: > Is there a problem with the pickle module in jython2.1a3 (or actually any of the 2.1 versions)? This program: > > f=open('junkpickle.txt','w') > j=[] > for i in range(10): > j.append(i) > pickle.dump(j,f) > > makes the junkpickle.txt file, but nothing gets dumped to it. The same > code works fine with jython 2.0, but doesn't work with 2.1a1 or 2.1a3. > > Sorry if this is an old problem, but I did a search of the mailing list > archives and nothing showed up there, so I thought I'd ask. > > Thanks, > Chris > > _______________________________________________ > Jython-users mailing list > Jyt...@li... > http://lists.sourceforge.net/lists/listinfo/jython-users > |