Skip to content

Build _testembed on Windows #63638

Closed
Closed

Description

@zware
BPO 19439
Nosy @loewis, @ncoghlan, @pitrou, @tjguk, @briancurtin, @zware
Files
  • windows_testembed.diff: Build _testembed on Windows
  • issue19439.v2.diff: Match pipe encoding
  • 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 2013-11-03.06:57:07.076>
    created_at = <Date 2013-10-29.20:58:13.127>
    labels = ['type-feature', 'tests', 'OS-windows']
    title = 'Build _testembed on Windows'
    updated_at = <Date 2013-11-06.04:03:51.775>
    user = 'https://github.com/zware'

    bugs.python.org fields:

    activity = <Date 2013-11-06.04:03:51.775>
    actor = 'python-dev'
    assignee = 'none'
    closed = True
    closed_date = <Date 2013-11-03.06:57:07.076>
    closer = 'ncoghlan'
    components = ['Tests', 'Windows']
    creation = <Date 2013-10-29.20:58:13.127>
    creator = 'zach.ware'
    dependencies = []
    files = ['32412', '32471']
    hgrepos = []
    issue_num = 19439
    keywords = ['patch']
    message_count = 7.0
    messages = ['201671', '201674', '201911', '201996', '201999', '202000', '202254']
    nosy_count = 7.0
    nosy_names = ['loewis', 'ncoghlan', 'pitrou', 'tim.golden', 'brian.curtin', 'python-dev', 'zach.ware']
    pr_nums = []
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'enhancement'
    url = 'https://bugs.python.org/issue19439'
    versions = ['Python 3.4']

    Activity

    1. zware commented on Oct 29, 2013

      @zware
      MemberAuthor

      Here's a patch that builds _testembed on Windows and adjusts test_capi to not skip EmbeddingTests on Windows. The .vcxproj is based on _freeze_importlib, with "when to build" settings lifted from _testimportmultiple.

      The patch also adjusts test_capi.EmbeddingTests.test_forced_io_encoding such that it doesn't blow up completely on Windows (and should still pass anywhere it does currently, though I haven't been able to test anywhere but on Windows yet). The test still fails, though; here's the relevant output I get:

      """
      ======================================================================
      FAIL: test_forced_io_encoding (test.test_capi.EmbeddingTests)
      ----------------------------------------------------------------------

      Traceback (most recent call last):
        File "P:\Projects\OSS\Python\_cpython\lib\test\test_capi.py", line 298, in test_forced_io_encoding
          self.assertEqual(out.strip(), expected_output)
      AssertionError: '--- [106 chars]t: cp1252:strict\r\nstderr: cp1252:backslashre[575 chars]lace' != '--- [106 chars]t: cp437:strict\r\nstderr:
       cp437:backslashrepl[571 chars]lace'
        --- Use defaults 

      Expected encoding: default
      Expected errors: default
      stdin: cp437:strict

      • stdout: cp1252:strict
        ? ^^^^
        + stdout: cp437:strict
        ? ^^^
      • stderr: cp1252:backslashreplace
        ? ^^^^
        + stderr: cp437:backslashreplace
        ? ^^^
        --- Set errors only ---
        Expected encoding: default
        Expected errors: surrogateescape
        stdin: cp437:surrogateescape
      • stdout: cp1252:surrogateescape
        ? ^^^^
        + stdout: cp437:surrogateescape
        ? ^^^
      • stderr: cp1252:backslashreplace
        ? ^^^^
        + stderr: cp437:backslashreplace
        ? ^^^
        --- Set encoding only ---
        Expected encoding: latin-1
        Expected errors: default
        stdin: latin-1:strict
        stdout: latin-1:strict
        stderr: latin-1:backslashreplace
        --- Set encoding and errors ---
        Expected encoding: latin-1
        Expected errors: surrogateescape
        stdin: latin-1:surrogateescape
        stdout: latin-1:surrogateescape
        stderr: latin-1:backslashreplace

      ----------------------------------------------------------------------
      """

      I'm not sure whether this is a bug in the way _testembed is built or otherwise. EmbeddingTests.test_subinterps passes, though.

      Due to my ongoing inability to get a 64-bit build to work, this has only been tested on 32-bit Windows 7.

    2. ncoghlan commented on Oct 29, 2013

      @ncoghlan
      Contributor

      Nice! I wonder if there might a difference between the default console
      encoding and the default pipe encoding (that test assumes the default
      standard stream encodings will be the same in the current process as they
      are in the child).

    3. zware commented on Nov 1, 2013

      @zware
      MemberAuthor

      That appears to be the case:

      """
      P:\Projects\OSS\Python\cpython\ $ chcp
      Active code page: 437

      P:\Projects\OSS\Python\cpython\ $ PCbuild\python_d.exe
      Python 3.4.0a4+ (default:995173ed248a+, Nov  1 2013, 09:12:43) [MSC v.1600 32 bit (Intel)] on win32
      Type "help", "copyright", "credits" or "license" for more information.
      >>> import os, sys
      >>> rfd, wfd = os.pipe()
      >>> r = os.fdopen(rfd, 'r')
      >>> w = os.fdopen(wfd, 'w')
      >>> sys.stdin.encoding, sys.stdout.encoding
      ('cp437', 'cp437')
      >>> r.encoding, w.encoding
      ('cp1252', 'cp1252')
      """

      The test passes as patched if I do 'chcp 1252' before running. Is it reasonable to patch the test to expect the default stdout and stderr encoding to equal os.fdopen(os.pipe[1], 'w').encoding? Doing so passes on Windows, don't know about various Unixes.

    4. zware commented on Nov 3, 2013

      @zware
      MemberAuthor

      This patch's changes to test_capi seem to work for Windows and keeps at least Gentoo and FreeBSD 10 happy.

    5. python-dev commented on Nov 3, 2013

      python-devmannequin
      Mannequin

      New changeset c8c6c007ade3 by Nick Coghlan in branch 'default':
      Close bpo-19439: execute embedding tests on Windows
      http://hg.python.org/cpython/rev/c8c6c007ade3

    6. ncoghlan commented on Nov 3, 2013

      @ncoghlan
      Contributor

      I checked that test_capi still passed on Fedora as well.

      Only tweak I made before committing was to ensure that the read end of the test pipe used to determine the default pipe encoding was also closed.

    7. python-dev commented on Nov 6, 2013

      python-devmannequin
      Mannequin

      New changeset 99640494ca7f by Zachary Ware in branch 'default':
      bpo-19439: Update PCbuild/readme.txt with new sub-project
      http://hg.python.org/cpython/rev/99640494ca7f

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

    No one assigned

      Labels

      OS-windowstestsTests in the Lib/test dirtype-featureA feature request or enhancement

      Projects

      No projects

        Milestone

        No milestone

        Relationships

        None yet

        Development

        No branches or pull requests

        Issue actions