Suppress ResourceWarning spew under Py3k.
| | |
| | | secretfile = os.path.abspath(os.path.expanduser(secretfile)) |
| | | if not os.path.exists(secretfile): |
| | | raise ValueError("No such 'secretfile': %s" % secretfile) |
| | | secret = open(secretfile).read().strip() |
| | | with open(secretfile) as f: |
| | | secret = f.read().strip() |
| | | if timeout: |
| | | timeout = int(timeout) |
| | | if reissue_time: |
| | |
| | | # assumed to have a readline |
| | | self.filename.seek(0) |
| | | f = self.filename |
| | | must_close = False |
| | | else: |
| | | try: |
| | | f = open(self.filename, 'r') |
| | | must_close = True |
| | | except IOError: |
| | | environ['repoze.who.logger'].warn('could not open htpasswd ' |
| | | 'file %s' % self.filename) |
| | |
| | | maybe_user = username |
| | | to_check = hashed |
| | | |
| | | if must_close: |
| | | f.close() |
| | | |
| | | # Check *something* here, to mitigate a timing attack. |
| | | password_ok = self.check(password, to_check) |
| | | |