Comment 5 for bug 428165

Revision history for this message
John A Meinel (jameinel) wrote : Re: [Bug 428165] Re: scanner doesn't flush/close

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Robert Collins wrote:
> As the scanner is given an open object, its the callers responsibility
> to flush and close (going from memory of the code).
>

Which function is being used? The recommended one is:
def dump_all_objects(outf):
...
    if isinstance(outf, basestring):
        opened = True
        outf = open(outf, 'wb')
    else:
        opened = False
    all_objs = gc.get_objects()
    dump_all_referenced(outf, all_objs, is_pending=True)
    del all_objs[:]
    if opened:
        outf.close()
    else:
        outf.flush()

Which I'll note both flushes if handed an object, and closes otherwise.

dump_gc_objects() also does the same.

dump_all_referenced() does not, but

 a) Probably could
 b) Isn't really meant as the top-level function to call.

(Note: I'm not 100% sure what ended up in the release, I generally
recommend running from trunk right now.)
John
=:->
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (Cygwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAkvxwHYACgkQJdeBCYSNAAMjbQCgrE0KyPvlMsvg+NEh5oxsRcmS
M/kAoLPYwl4lkUaTO35XUetO61aKWcZC
=93jT
-----END PGP SIGNATURE-----