Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pathlib.Path.write_text should include a newline argument #67894

Closed
danielugra mannequin opened this issue Mar 19, 2015 · 7 comments
Closed

pathlib.Path.write_text should include a newline argument #67894

danielugra mannequin opened this issue Mar 19, 2015 · 7 comments
Labels
3.10 only security fixes easy stdlib Python modules in the Lib dir type-feature A feature request or enhancement

Comments

@danielugra
Copy link
Mannequin

danielugra mannequin commented Mar 19, 2015

BPO 23706
Nosy @pitrou, @methane, @serhiy-storchaka, @uranusjr, @miss-islington, @tirkarthi, @skilaren
PRs
  • bpo-23706: Add newline parameter to pathlib.Path.write_text (GH-22420) #22420
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = None
    closed_at = <Date 2020-10-21.02:19:28.211>
    created_at = <Date 2015-03-19.09:32:41.143>
    labels = ['easy', 'type-feature', 'library', '3.10']
    title = 'pathlib.Path.write_text should include a newline argument'
    updated_at = <Date 2020-10-21.02:19:28.210>
    user = 'https://bugs.python.org/danielugra'

    bugs.python.org fields:

    activity = <Date 2020-10-21.02:19:28.210>
    actor = 'methane'
    assignee = 'none'
    closed = True
    closed_date = <Date 2020-10-21.02:19:28.211>
    closer = 'methane'
    components = ['Library (Lib)']
    creation = <Date 2015-03-19.09:32:41.143>
    creator = 'daniel.ugra'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 23706
    keywords = ['patch', 'easy']
    message_count = 7.0
    messages = ['238498', '326096', '377575', '377577', '377693', '379180', '379181']
    nosy_count = 9.0
    nosy_names = ['pitrou', 'methane', 'daniel.ugra', 'THRlWiTi', 'serhiy.storchaka', 'uranusjr', 'miss-islington', 'xtreak', 'maksvenberv']
    pr_nums = ['22420']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'enhancement'
    url = 'https://bugs.python.org/issue23706'
    versions = ['Python 3.10']

    @danielugra
    Copy link
    Mannequin Author

    danielugra mannequin commented Mar 19, 2015

    The new pathlib.Path [read|write]_[binary|text] methods will be very useful, one thing I miss badly is the newline argument for write_text.

    In some cases text files need a specific line ending (independent from the platform the code is being executed on.) In my mind this is analogous to passing an explicit encoding argument.

    Of course, one can always use built-in open for this scenario. It would be a nice addition anyway :)

    @danielugra danielugra mannequin added stdlib Python modules in the Lib dir type-feature A feature request or enhancement labels Mar 19, 2015
    @tirkarthi
    Copy link
    Member

    It seems a similar API was suggested in the initial stages at https://bugs.python.org/issue20218#msg209017 . But looking at the reference library in the comment https://github.com/jaraco/path.py I think it's more about converting newlines in the given text with respect to the platform instead of adding one at the end.

    Thanks

    @serhiy-storchaka serhiy-storchaka added easy 3.10 only security fixes labels Sep 12, 2020
    @skilaren
    Copy link
    Mannequin

    skilaren mannequin commented Sep 27, 2020

    For the newline parameter, what is the expected behaviour? To work as newline from io.open() which supports only so called "legal" newlines which are: None, '', '\n', '\r', and '\r\n', or to allow users use any sequence as newline hence do replacing before passing text to io.open()?

    @serhiy-storchaka
    Copy link
    Member

    It should work exactly as the newline argument of open(). Anything else would be surprising.

    @skilaren
    Copy link
    Mannequin

    skilaren mannequin commented Sep 30, 2020

    CLA signed now and PR is ready :)

    @miss-islington
    Copy link
    Contributor

    New changeset 5f22741 by Максим in branch 'master':
    bpo-23706: Add newline parameter to pathlib.Path.write_text (GH-22420) (GH-22420)
    5f22741

    @methane
    Copy link
    Member

    methane commented Oct 21, 2020

    Thank you

    @methane methane closed this as completed Oct 21, 2020
    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    3.10 only security fixes easy stdlib Python modules in the Lib dir type-feature A feature request or enhancement
    Projects
    None yet
    Development

    No branches or pull requests

    4 participants