
This issue trackerhas been migrated toGitHub, and is currentlyread-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.
Created on2006-12-11 21:16 byantroy, last changed2022-04-11 14:56 byadmin. This issue is nowclosed.
| Files | ||||
|---|---|---|---|---|
| File name | Uploaded | Description | Edit | |
| fileinput_lib_doc_test.diff | antroy,2006-12-11 21:16 | Diff file of the changes described above. | review | |
| Pull Requests | |||
|---|---|---|---|
| URL | Status | Linked | Edit |
| PR 12986 | merged | berker.peksag,2019-04-27 18:12 | |
| Messages (6) | |||
|---|---|---|---|
| msg51510 -(view) | Author: Anthony Roy (antroy) | Date: 2006-12-11 21:16 | |
The current implementation of the fileinput module allows an optional 'mode' keyword argumant to the FileInput initializer and the input() convenience function.The attached patch provides a similar write_mode keyword argument with which to specify the write mode when the 'inplace' option is used.Included in the patch file are:1) Changes to the fileinput module to accomodate the optional write mode option2) Additions to the fileinput tex documentation.3) A refactored test module, where the tests have been reorganised into TestCase subclasses, and new tests added for the new functionality. | |||
| msg51511 -(view) | Author: Martin Kammerhofer (mkam) | Date: 2006-12-15 13:10 | |
The restriction that you cannot use inplace and openhook together seems somewhatarbitrary to me. Have you considered lifting it? From looking at the source itseems not too hard to do. There are uses for e.g. inplace editing compressed files.This would fit nicely with your patch. | |||
| msg51512 -(view) | Author: Anthony Roy (antroy) | Date: 2006-12-18 19:33 | |
The restriction isn't entirely arbitrary as far as I can see. If you allow the combination of inplace and openhook, then you will also need a writehook option, or the ability to specify a pair of hook function for the openhook. For example, there is a function provided for opening a compressed file for reading. In order to do an inplace edit, you would need to provide a write hook to compress the data on the way back in.I think that the implementation of such a change would be open for discussion, and is beyond the scope of a minor change as suggested in this patch. (Perhaps the topic for a future PEP). | |||
| msg110506 -(view) | Author: Mark Lawrence (BreamoreBoy)* | Date: 2010-07-16 21:43 | |
This looks like a sizeable patch but the bulk of the changes are to test_fileinput.py. Assigning to myself to take forward, I've got to start sometime. Before I really start moving are there any basic objections to either the original proposal or me having a bash? | |||
| msg182899 -(view) | Author: R. David Murray (r.david.murray)*![]() | Date: 2013-02-24 22:16 | |
As far as I can see from a quick look, the problem this patch addresses still exists in Python3, and in Python3 it be (more of?) a bug. That is, the output file is opened in text mode, regardless of whether the input mode was text or bytes. I'm not sure about the solution; it seems like it makes more sense to deduce the output mode from the input mode.The test changes, though, are obsolete. | |||
| msg341089 -(view) | Author: Berker Peksag (berker.peksag)*![]() | Date: 2019-04-29 14:55 | |
New changesetbe6dbfb43b89989ccc83fbc4c5234f50f44c47ad by Berker Peksag in branch 'master':bpo-1613500: Don't hardcode output file mode in fileinput.FileInput (GH-12986)https://github.com/python/cpython/commit/be6dbfb43b89989ccc83fbc4c5234f50f44c47ad | |||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022-04-11 14:56:21 | admin | set | github: 44329 |
| 2019-04-29 14:56:18 | berker.peksag | set | status: open -> closed stage: patch review -> resolved resolution: fixed versions: + Python 3.8, - Python 3.5 |
| 2019-04-29 14:55:59 | berker.peksag | set | nosy: +berker.peksag messages: +msg341089 |
| 2019-04-27 18:12:12 | berker.peksag | set | pull_requests: +pull_request12909 |
| 2014-02-03 18:39:58 | BreamoreBoy | set | nosy: -BreamoreBoy |
| 2013-02-24 22:16:38 | r.david.murray | set | versions: + Python 3.5, - Python 3.2 nosy: +r.david.murray messages: +msg182899 assignee:BreamoreBoy -> |
| 2010-07-16 21:43:45 | BreamoreBoy | set | versions: + Python 3.2, - Python 3.1, Python 2.7 nosy: +BreamoreBoy messages: +msg110506 assignee:BreamoreBoy |
| 2009-03-30 18:00:45 | ajaksu2 | set | stage: patch review type: enhancement versions: + Python 3.1, Python 2.7 |
| 2006-12-11 21:16:56 | antroy | create | |