Skip to content

Commit

Permalink
Avoid leaving a file unclosed
Browse files Browse the repository at this point in the history
On jenkins in python 3.7 this gives a ResourceWarning:

```
plone/app/customerize/registration.py:157: ResourceWarning: unclosed file <_io.BufferedReader name='plone/app/customerize/tests/standard.pt'>
```
  • Loading branch information
gforcada authored Nov 11, 2018
1 parent 60c576c commit 5b5d19a
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion plone/app/customerize/registration.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,9 @@ def getTemplateCodeFromRegistration(reg):
attr, template = findViewletTemplate(reg.factory)
# TODO: we can't do template.read() here because of a bug in
# Zope 3's ZPT implementation.
return open(template.filename, 'rb').read()
with open(template.filename, 'rb') as template_file:
content = template_file.read()
return content


def getViewPermissionFromRegistration(reg):
Expand Down

1 comment on commit 5b5d19a

@jenkins-plone-org
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gforcada Jenkins CI reporting about code analysis
See the full report here: https://jenkins.plone.org/job/package-plone.app.customerize/32/violations

plone/app/customerize/registration.py:49:15: P002 found "hasattr", consider replacing it
plone/app/customerize/registration.py:51:11: T000 Todo note found.
plone/app/customerize/registration.py:74:15: T000 Todo note found.
plone/app/customerize/registration.py:112:35: C812 missing trailing comma
plone/app/customerize/registration.py:135:31: C812 missing trailing comma
plone/app/customerize/registration.py:155:7: T000 Todo note found.
plone/app/customerize/testing.py:13:9: D001 found xmlconfig.file( replace it with self.loadZCML(
plone/app/customerize/testing.py:16:9: D001 found xmlconfig.file( replace it with self.loadZCML(
plone/app/customerize/testing.py:19:9: D001 found xmlconfig.file( replace it with self.loadZCML(
plone/app/customerize/tests/testDocTests.py:2:1: I001 isort found an import in the wrong position
plone/app/customerize/tests/testDocTests.py:4:1: I001 isort found an import in the wrong position
plone/app/customerize/tests/testDocTests.py:34:14: C812 missing trailing comma

Follow these instructions to reproduce it locally.

Please sign in to comment.