Hello ,

If you do mean CPython test suite then it's probably not the best
place to look at because the reference counting *is there* and those
object will be closed at the end of test method. Django doesn't have
this comfort when run with PyPy.

That said, I wouldn't recommend using contextlib.closing() all over
the place. StringIO seems to implement the context manager protocol
just fine[1]. And in Python 3.4+ so does urlopen().

[1]: http://bugs.python.org/issue4039


On 3 July 2015 at 16:09, Andriy Sokolovskiy <[email protected]> wrote:
> My vision of that was to have clean code (even if these are few bytes).
> Python allows to have memory leaks like this, without throwing warnings,
> but if we know that we can close it, I think we should do that.
>
> We're usually writing new tests by copying logic from sibling test (if
> new test need to do similar thing).
> If that test have unclosed stream or file, new test likely also will not
> close streams and files, so this old test is a "bad example",
> which causing more unclean code.
>
> So, it question about code style than about bytes savings.
>
> On 7/3/15 16:59, Tim Graham wrote:
>> Andriy proposed a patch to close objects like StringIO and BytesIO in
>> our test suite [1]. I am not sure how much benefit this gives (frees "a
>> few bytes of RAM" according to [2]) and it seems to add a lot of
>> verbosity. Looking at Python's own test suite, it doesn't appear these
>> objects are closed there (I spot checked BytesIO and StringIO). Any
>> thoughts on this?
>>
>> [1] https://github.com/django/django/pull/4938
>> [2] https://github.com/django/django/pull/4248
>>
>> --
>> You received this message because you are subscribed to the Google
>> Groups "Django developers (Contributions to Django itself)" group.
>> To unsubscribe from this group and stop receiving emails from it, send
>> an email to [email protected]
>> <mailto:[email protected]>.
>> To post to this group, send email to [email protected]
>> <mailto:[email protected]>.
>> Visit this group at http://groups.google.com/group/django-developers.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/django-developers/7579ee1c-ecc6-48d1-9002-733810e64754%40googlegroups.com
>> <https://groups.google.com/d/msgid/django-developers/7579ee1c-ecc6-48d1-9002-733810e64754%40googlegroups.com?utm_medium=email&utm_source=footer>.
>> For more options, visit https://groups.google.com/d/optout.
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Django developers  (Contributions to Django itself)" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to [email protected].
> To post to this group, send email to [email protected].
> Visit this group at http://groups.google.com/group/django-developers.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/django-developers/559697A3.2010002%40asokolovskiy.com.
> For more options, visit https://groups.google.com/d/optout.



-- 
Łukasz Rekucki

-- 
You received this message because you are subscribed to the Google Groups 
"Django developers  (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/django-developers.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-developers/CAEZs-ELtiFRdGEyeXcde8L315tXO-BkcGLPCEiTPFmNMS1BM9g%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to