Skip to content

packaging uses wrong line endings in RECORD files on Windows #57384

Closed

Description

@pfmoore
BPO 13175
Nosy @pfmoore, @vsajip, @tarekziade, @merwok
Dependencies
  • bpo-13198: Remove duplicate definition of write_record_file
  • Files
  • recordfix.patch: Patch for this issue
  • 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 = 'https://github.com/merwok'
    closed_at = <Date 2014-03-12.09:45:46.363>
    created_at = <Date 2011-10-13.22:47:01.617>
    labels = ['type-bug']
    title = 'packaging uses wrong line endings in RECORD files on Windows'
    updated_at = <Date 2014-03-12.09:45:46.361>
    user = 'https://github.com/pfmoore'

    bugs.python.org fields:

    activity = <Date 2014-03-12.09:45:46.361>
    actor = 'eric.araujo'
    assignee = 'eric.araujo'
    closed = True
    closed_date = <Date 2014-03-12.09:45:46.363>
    closer = 'eric.araujo'
    components = ['Distutils2']
    creation = <Date 2011-10-13.22:47:01.617>
    creator = 'paul.moore'
    dependencies = ['13198']
    files = ['23416']
    hgrepos = []
    issue_num = 13175
    keywords = ['patch']
    message_count = 17.0
    messages = ['145488', '145533', '145553', '145595', '145597', '145619', '145620', '145688', '145700', '145723', '152961', '153011', '153028', '153105', '153118', '161035', '213232']
    nosy_count = 5.0
    nosy_names = ['paul.moore', 'vinay.sajip', 'tarek', 'eric.araujo', 'alexis']
    pr_nums = []
    priority = 'normal'
    resolution = 'out of date'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue13175'
    versions = ['3rd party', 'Python 3.3']

    Activity

    1. pfmoore commented on Oct 13, 2011

      @pfmoore
      MemberAuthor

      On Windows, packaging seems to create RECORD files with an additional CR at the end of the line. (So the line end is CR CR LF). This does not seem to be consistent, but it is likely to be because a file is being opened in text mode rather than binary.

      I am trying to develop a reproducible test case, but am having difficulty at the moment. I have opened this bug in any case as a place holder and in case someone else can reproduce the issue.

    2. merwok commented on Oct 14, 2011

      @merwok
      Member

      packaging.util creates a RECORD file with OS-specific line endings and csv.writerow; packaging.command.install_distinfo uses LF everywhere and csv.writerow. I’m not sure this is related to binary vs. text I/O; maybe it’s some other code like the RESOURCES system that’s giving lines with endings to install_distinfo, which then adds CRLF. Do you have a RECORD file to upload for inspection?

    3. pfmoore commented on Oct 14, 2011

      @pfmoore
      MemberAuthor

      Unfortunately, no. I have been unable to get this in a reproducible form - but I have seen it a few times now. I will keep trying to reproduce.

      The worst thing is that packaging fails to recognise the data in RECORD and won't uninstall the package. It would be helpful if packaging were a little more permissive in how it handles this sort of problem in RECORD.

    4. vsajip commented on Oct 15, 2011

      @vsajip
      Member

      I'm trying to reproduce this too, but have failed so far. Which version(s) of Windows did the problems appear on?

    5. pfmoore commented on Oct 15, 2011

      @pfmoore
      MemberAuthor

      Windows 7, 32 bit.

    6. pfmoore commented on Oct 16, 2011

      @pfmoore
      MemberAuthor

      I found the problem - it's in packaging.util.write_record_file. The
      file passed to csv.writer should be opened with newline=''.

    7. pfmoore commented on Oct 16, 2011

      @pfmoore
      MemberAuthor

      Here's a patch. It includes a test, but I don't expect the test will catch the issue except on Windows...

    8. merwok commented on Oct 17, 2011

      @merwok
      Member

      I found the problem - it's in packaging.util.write_record_file.
      We have two functions that write RECORD files; I’ve opened a report to kill one.

      The file passed to csv.writer should be opened with newline=''.
      How will we port this to 2.x?

      I don't expect the test will catch the issue except on Windows...
      Do you mean that the test will fail or be a no-op on other OSes? We can mark it as Windows-specific (@unittest.skipIf(sys.platform != 'win32', 'test only relevant on win32')) or just let it run if it’s harmless. The important point is: does it fail before the fix, does it pass after?

    9. assigned and unassigned on Oct 17, 2011
    10. pfmoore commented on Oct 17, 2011

      @pfmoore
      MemberAuthor

      On 17 October 2011 14:15, Éric Araujo <report@bugs.python.org> wrote:

      > The file passed to csv.writer should be opened with newline=''.
      How will we port this to 2.x?

      No idea :-( The 2.7 documentation says use the 'b' flag, but that
      probably doesn't allow an encoding parameter (it doesn't on 3.x).

      > I don't expect the test will catch the issue except on Windows...
      Do you mean that the test will fail or be a no-op on other OSes?  We can mark it as Windows-specific (@unittest.skipIf(sys.platform != 'win32', 'test only relevant on win32')) or just let it run if it’s harmless.  The important point is: does it fail before the fix, does it pass after?

      The test fails before the fix, passes after. It's a no-op on platforms
      where text and binary files are the same, (i.e., non-Windows systems).
      So it's harmless.

    11. merwok commented on Oct 17, 2011

      @merwok
      Member

      >> The file passed to csv.writer should be opened with newline=''.
      > How will we port this to 2.x?
      No idea :-( The 2.7 documentation says use the 'b' flag, but that
      probably doesn't allow an encoding parameter (it doesn't on 3.x).

      Ah, I see that newline controls newline translation. We use codecs.open in distutils2; I think it uses universal newlines mode. We’ll figure it out, the important part is to have good tests.

      The test fails before the fix, passes after. It's a no-op on platforms
      where text and binary files are the same, (i.e., non-Windows systems).
      So it's harmless.

      Great. I’ll look at your patch and try to port it to distutils2.

    12. pfmoore commented on Feb 9, 2012

      @pfmoore
      MemberAuthor

      Any progress on this one?

      I tried to reproduce using distutils2, but don't know how distutils2 works - there's no pysetup and python -m distutils2.run doesn't work the same as python -m packaging.run.

      Can we at least get packaging working in time for 3.3, even if it leaves an issue with distutils2 to sort out?

    13. merwok commented on Feb 10, 2012

      @merwok
      Member

      I tried to reproduce using distutils2, but don't know how distutils2
      works - there's no pysetup and python -m distutils2.run doesn't work
      the same as python -m packaging.run.

      Maybe you’re using the old PyPI release or Tarek’s outdated Bitbucket repository. http://hg.python.org/distutils is current, contains pysetup and supports -m distutils2.run.

      I’ll port your patch to d2 this week.

    14. pfmoore commented on Feb 10, 2012

      @pfmoore
      MemberAuthor

      Maybe you’re using the old PyPI release or Tarek’s outdated Bitbucket repository.  http://hg.python.org/distutils is current, contains pysetup and supports -m distutils2.run.

      I just did pip install distutils2 in a virtualenv. If that doesn't
      work then yes, I got the wrong one :-(

      Do I need to hg clone then do some magic pip incantation to get it
      installed? I'm new to pip/viirtualenv. I'll have a look.

    15. merwok commented on Feb 11, 2012

      @merwok
      Member

      I just did pip install distutils2 in a virtualenv. If that doesn't work then yes,
      I got the wrong one :-(
      You need to get a development repo to make patches, not a released version, just like for CPython.

      Do I need to hg clone then do some magic pip incantation to get it installed?
      Why would you want to install it? Clone it, hack on it in place, run tests in place. :)

      FTR, “bin/pip install -e .” is the command to “install” a project in develop (or editable) mode with pip in a virtualenv.

    16. pfmoore commented on Feb 11, 2012

      @pfmoore
      MemberAuthor

      > Do I need to hg clone then do some magic pip incantation to get it installed?
      Why would you want to install it?  Clone it, hack on it in place, run tests in place.  :)

      FTR, “bin/pip install -e .” is the command to “install” a project in develop (or editable) mode with pip in a virtualenv.

      Thanks, that's what I needed. I'm new to pip and know little more than
      "pip install" :-)

    17. merwok commented on May 18, 2012

      @merwok
      Member

      I should be able to run a VM to test and commit this soon. Keep faith!

    18. merwok commented on Mar 12, 2014

      @merwok
      Member

      This issue is now obsolete for distutils2. Other projects that write RECORD files are hopefully more robust in their code and tests.

    19. transferred this issue fromon Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

    Metadata

    Metadata

    Assignees

    Labels

    type-bugAn unexpected behavior, bug, or error

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions