Skip to content

msvc9compiler.py: TypeError: can't use a string pattern on a bytes-like object #51805

Closed

Description

@srid
mannequin
BPO 7556
Nosy @loewis, @tarekziade, @skrah
Files
  • 3.1-byte-string.diff
  • 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/tarekziade'
    closed_at = <Date 2009-12-21.23:45:26.384>
    created_at = <Date 2009-12-21.18:59:17.290>
    labels = ['type-bug', 'library']
    title = "msvc9compiler.py: TypeError: can't use a string pattern on a bytes-like object"
    updated_at = <Date 2009-12-21.23:45:26.382>
    user = 'https://bugs.python.org/srid'

    bugs.python.org fields:

    activity = <Date 2009-12-21.23:45:26.382>
    actor = 'tarek'
    assignee = 'tarek'
    closed = True
    closed_date = <Date 2009-12-21.23:45:26.384>
    closer = 'tarek'
    components = ['Distutils']
    creation = <Date 2009-12-21.18:59:17.290>
    creator = 'srid'
    dependencies = []
    files = ['15653']
    hgrepos = []
    issue_num = 7556
    keywords = ['patch']
    message_count = 9.0
    messages = ['96763', '96764', '96765', '96766', '96775', '96776', '96779', '96780', '96784']
    nosy_count = 4.0
    nosy_names = ['loewis', 'tarek', 'srid', 'skrah']
    pr_nums = []
    priority = 'normal'
    resolution = None
    stage = None
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue7556'
    versions = ['Python 3.1', 'Python 3.2']

    Activity

    1. srid commented on Dec 21, 2009

      sridmannequin
      MannequinAuthor

      While building pywin32 with Py3k trunk (not release version), I get this
      traceback:

         Creating library build\temp.win32-
      3.1\Release\win32\src\pywintypes31.lib and object buil
      d\temp.win32-3.1\Release\win32\src\pywintypes31.exp
      Traceback (most recent call last):
        File "setup3.py", line 16, in <module>
          exec(str(got))
      ...skipping...
        File "<string>", line 2194, in <module>
        File 
      "C:\HOME\as\apy\branches\nightly\build\pyhg_branches_release3_1_maint-
      win32-x86-hgti
      \core.py", line 149, in setup
          dist.run_commands()
        File 
      "C:\HOME\as\apy\branches\nightly\build\pyhg_branches_release3_1_maint-
      win32-x86-hgti
      \dist.py", line 919, in run_commands
          self.run_command(cmd)
        File 
      "C:\HOME\as\apy\branches\nightly\build\pyhg_branches_release3_1_maint-
      win32-x86-hgti
      \dist.py", line 938, in run_command
          cmd_obj.run()
        File "<string>", line 619, in run
        File 
      "C:\HOME\as\apy\branches\nightly\build\pyhg_branches_release3_1_maint-
      win32-x86-hgti
      \command\build.py", line 128, in run
          self.run_command(cmd_name)
        File 
      "C:\HOME\as\apy\branches\nightly\build\pyhg_branches_release3_1_maint-
      win32-x86-hgti
      \cmd.py", line 315, in run_command
          self.distribution.run_command(command)
        File 
      "C:\HOME\as\apy\branches\nightly\build\pyhg_branches_release3_1_maint-
      win32-x86-hgti
      \dist.py", line 938, in run_command
          cmd_obj.run()
        File 
      "C:\HOME\as\apy\branches\nightly\build\pyhg_branches_release3_1_maint-
      win32-x86-hgti
      \command\build_ext.py", line 347, in run
      p31-rrun\python\lib\distutils\ccompiler.py", line 791, in 
      link_shared_object
          extra_preargs, extra_postargs, build_temp, target_lang)
        File "<string>", line 1384, in link
      p31-rrun\python\lib\distutils\msvc9compiler.py", line 663, in link
          manifest_buf = re.sub(pattern, "", manifest_buf)
      p31-rrun\python\lib\re.py", line 166, in sub
          return _compile(pattern, flags).sub(repl, string, count)
      TypeError: can't use a string pattern on a bytes-like object
    2. added
      stdlibStandard Library Python modules in the Lib/ directory
      type-bugAn unexpected behavior, bug, or error
      on Dec 21, 2009
    3. srid commented on Dec 21, 2009

      sridmannequin
      MannequinAuthor

      Uh, cmd.exe seemed to have stripped some chars. Here's the full traceback:
      http://gist.github.com/261153

    4. srid commented on Dec 21, 2009

      sridmannequin
      MannequinAuthor

      Correction: I found this in branches/release3.1-maint (not trunk - which I
      never tried)

    5. skrah commented on Dec 21, 2009

      skrahmannequin
      Mannequin

      I also raised this issue at the end of bpo-4120 (which is closed).
      I'll post the diff here, too.

    6. tarekziade commented on Dec 21, 2009

      tarekziademannequin
      Mannequin

      Stefan's patch will do the trick. I am adding a test to make sure this
      part is covered before I apply the patch

    7. loewis commented on Dec 21, 2009

      loewismannequin
      Mannequin

      I'd rather prefer if the manifest was opened in text mode. It should be
      UTF-8 encoded (although ASCII would work as well).

    8. tarekziade commented on Dec 21, 2009

      tarekziademannequin
      Mannequin

      sure, that's even simpler. I am adding a test and this simple fix.

      Notice that this code could be replaced with some code that uses an xml
      parser. I find the regexp patterns a bit inappropriate here because it
      removes "<dependentAssembly></dependentAssembly>" in a second call, but
      may leave an empty "<dependency></dependency>" as far as I understand

    9. loewis commented on Dec 21, 2009

      loewismannequin
      Mannequin

      As for using proper XML processing: that would be fine as well.

      As for leaving an empty dependency element: in the original report, MAL
      says that this is conforming. I found a schema file (from MS) which
      agrees, and a textual documentation page that disagrees. The actual
      implementation (atleast in Win7) also seems to agree: the loader would
      (apparently) recognize the entire manifest even though it had this empty
      dependency in it.

    10. tarekziade commented on Dec 21, 2009

      tarekziademannequin
      Mannequin

      Ok thanks for the detailed info, Martin

      I guess we could refactor it to an xml reader/writer if we need to do
      more things in the future with these files.

      I'll close this issue, as the mentioned problem is now fixed by using a
      text mode. The test in test_msvc9compiler will make sure the XML file
      gets cleaned up by the regexp.

      • done in r76993, r76995
      • backported in r76996 and r76998 so the trunk behaves the same way.
      • 2.6 stays unchanged, and keep using a binary mode.

      Thanks all !

    11. 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

    stdlibStandard Library Python modules in the Lib/ directorytype-bugAn unexpected behavior, bug, or error

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions