Hi all,

connParser.py -> fileRef() not working as expected.

if isinstance(ref, str):
        if os.path.exists(ref):
            with open(ref) as ff:

return ff

PEP 352 has the following statement


Some standard Python objects now support the context management protocol and can be used with the 'with' statement. File objects are one example: with open('/etc/passwd', 'r') as f: for line in f: print line ... more processing code ...

After this statement has executed, the file object infwill have been automatically closed, even if theforloop raised an exception part-way through the block.


Notice that the 'fwill have been automatically closed' and that is the reason that later use of the return value 'f' is closed and can't be used.  Maybe the old 'try...finally' block should be used or maybe just use the open().


Johnf





--- StripMime Report -- processed MIME parts ---
multipart/alternative
 text/plain (text body -- kept)
 text/html
---

_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://mail.leafe.com/mailman/listinfo/dabo-dev
Searchable Archives: https://leafe.com/archives
This message: 
https://leafe.com/archives/byMID/[email protected]

Reply via email to