Ticket #5811 enhancement closed wontfix

Opened 10 months ago

Last modified 6 months ago

replace usage of file with FilePath in twisted.test

Reported by: thijs Owned by: thijs
Priority: low Milestone: Python-3.x
Component: core Keywords:
Cc: thijs Branch:
Author: Launchpad Bug:

Description (last modified by thijs) (diff)

The usage of file should be replaced with FilePath in twisted.test and it's tests for Python 3 compatibility.

twisted/test/test_sob.py:116:        f = file(filename, 'w')
twisted/test/test_sob.py:134:        f = file(filename, 'w')
twisted/test/test_sob.py:152:        f = file(filename, 'w')
twisted/test/test_ftp.py:632:            fObj = file(os.path.join(self.directory, '%d.txt' % (size,)), 'wb')
twisted/test/test_fdesc.py:218:        fObj = file(self.mktemp(), 'w')
twisted/test/test_fdesc.py:230:        fObj = file(self.mktemp(), 'w')
twisted/test/test_threads.py:376:        progfile = file(progname, 'w')
twisted/test/test_process.py:2382:            f = file(name, "w")
twisted/test/test_pb.py:829:        self.pager = util.FilePager(collector, file(self.filename),
twisted/test/test_pb.py:845:        fd = file(self.filename, 'w')
twisted/test/test_pb.py:890:        fd = file(filenameEmpty, 'w')
twisted/test/test_twistd.py:358:        f = file(self.tapfile, 'wb')
twisted/test/test_twistd.py:682:        fObj = file(pidfile)
twisted/test/test_twistd.py:696:        fObj = file(pidfile)
twisted/test/test_twistd.py:793:        file(pidfile, "w").close()
twisted/test/test_twistd.py:920:        data = file(config["profile"]).read()
twisted/test/test_twistd.py:1024:        data = file(config["profile"]).read()
twisted/test/test_twistd.py:1109:        data = file(config["profile"]).read()
twisted/test/test_iutils.py:34:        scriptFile = file(script, 'wt')
twisted/test/test_rebuild.py:48:        file(os.path.join(self.fakelibPath, '__init__.py'), 'w').close()
twisted/test/test_stdio.py:140:            for line in file(errorLogFile):
twisted/test/test_stdio.py:264:        junkFile = file(junkPath, 'w')
twisted/test/test_stdio.py:312:            self.assertEqual(p.data[1], file(junkPath).read())
twisted/test/test_strcred.py:531:        file(self.filename, 'w').write('admin:asdf\nalice:foo\n')
twisted/test/test_ssl.py:219:        fObj = file(fName, 'w')
twisted/test/test_logfile.py:205:        f = file(self.path, "w")

Attachments

test-open-5811.patch Download (12.5 KB) - added by thijs 10 months ago.
test-open-5811-2.patch Download (30.4 KB) - added by thijs 10 months ago.

Change History

Changed 10 months ago by thijs

1

  Changed 10 months ago by thijs

  • keywords review added

2

follow-up: ↓ 3   Changed 10 months ago by antoine

  • keywords review removed
  • owner set to thijs

Patch looks fine to me. You might also want to replace xrange(1024) with range(1024), and 0707 with 0o707 (Python 3-compatible octal notation).

3

in reply to: ↑ 2   Changed 10 months ago by thijs

Replying to antoine:

Patch looks fine to me. You might also want to replace xrange(1024) with range(1024), and 0707 with 0o707 (Python 3-compatible octal notation).

Feel free to open a separate ticket(s) for that type of change, thanks.

4

  Changed 10 months ago by thijs

  • status changed from new to assigned

5

  Changed 10 months ago by thijs

  • summary changed from replace usage of file with open in twisted.test to replace usage of file with FilePath in twisted.test

6

  Changed 10 months ago by thijs

  • description modified (diff)

Changed 10 months ago by thijs

7

  Changed 10 months ago by thijs

  • keywords review added
  • owner thijs deleted
  • status changed from assigned to new

Attached patch uses FilePath instead; meaning this should never happen again. ;)

8

  Changed 8 months ago by cyli

  • owner set to thijs
  • keywords review removed

Hi thijs! Thanks for working on this.

  1. test_fdesc has change so that it no longer uses file - instead it uses open, so the patch is probably out of date by now
  2. There seem to be several other usages of file that were missed?
stdio_test_consumer.py
26:        d = basic.FileSender().beginFileTransfer(file(self.junkPath), self.transport)

stdio_test_halfclose.py
61:    log.startLogging(file(sys.argv[2], 'w'))

stdio_test_loseconn.py
43:    log.startLogging(file(sys.argv[2], 'w'))

test_newcred.py
184:        f = file(dbfile, 'w')
196:        f = file(dbfile, 'w')
207:        f = file(dbfile, 'w')
220:        f = file(dbfile, 'w')
246:        f = file(dbfile, 'w')
408:            fObj = file(fn, 'w')
415:            fObj = file(fn, 'w')
422:            fObj = file(fn, 'w')

test_ssl.py
288:        cert = ssl.PrivateCertificate.loadPEM(file(certPath).read())

9

  Changed 6 months ago by therve

  • status changed from new to closed
  • resolution set to wontfix

Following Plan/Python3 I'm closing this ticket. Sorry for the inconvenience.

Note: See TracTickets for help on using tickets.