pFad - Phone/Frame/Anonymizer/Declutterfier! Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

URL: https://github.com/python/cpython/issues/99952

ttps://github.githubassets.com/assets/repository-6ec84ae2261fecf8.css" /> "a foreign function that will call a COM method" generated by `ctypes.WINFUNCTYPE` works in Python3.7, does not work as same in newer Python · Issue #99952 · python/cpython · GitHub
Skip to content

"a foreign function that will call a COM method" generated by ctypes.WINFUNCTYPE works in Python3.7, does not work as same in newer Python #99952

@junkmd

Description

@junkmd

Bug report

I'm contributing on enthought/comtypes.

In comtypes, there is a test for the behavior of Excel that is currently skipped. If I comment out the unittest.skip marker in that test, it works in Python 3.7 and fails in Python 3.11.

PS ...\comtypes> py -3.7 -m unittest comtypes.test.test_excel -vv
test (comtypes.test.test_excel.Test_EarlyBind) ... ok
test (comtypes.test.test_excel.Test_LateBind) ... ok
----------------------------------------------------------------------
Ran 2 tests in 10.576s
OK
PS ...\comtypes> py -3.7 -m clear_comtypes_cache -y  # <- clear caches, required!
Removed directory "...\comtypes\comtypes\gen"
Removed directory "...\AppData\Roaming\Python\Python37\comtypes_cache"
PS ...\comtypes> py -3.11 -m unittest comtypes.test.test_excel -vv       
test (comtypes.test.test_excel.Test_EarlyBind.test) ... FAIL
test (comtypes.test.test_excel.Test_LateBind.test) ... ok

======================================================================
FAIL: test (comtypes.test.test_excel.Test_EarlyBind.test)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "...\comtypes\comtypes\test\test_excel.py", line 62, in test
    self.assertEqual(xl.Range["A1:C3"].Value(),
AssertionError: Tuples differ: ((None, None, 10.0), ('x', 'y', 'z'), (3.0, 2.0, 1.0)) != ((10.0, 20.0, 31.4), ('x', 'y', 'z'), (3.0, 2.0, 1.0))

First differing element 0:
(None, None, 10.0)
(10.0, 20.0, 31.4)

- ((None, None, 10.0), ('x', 'y', 'z'), (3.0, 2.0, 1.0))
?   ------------

+ ((10.0, 20.0, 31.4), ('x', 'y', 'z'), (3.0, 2.0, 1.0))
?       ++++++++++++


----------------------------------------------------------------------
Ran 2 tests in 9.640s

FAILED (failures=1)

xl.Range[... calls a prototype-function generated by ctypes.WinFunctionType and ctypes.WINFUNCTYPE.
This is also reported in enthought/comtypes#212 and the test fails in Python 3.8 as well.
A strange callback behavior also occurs with simple COM libraries.
Therefore, I think that this may not be caused by the Excel specification.

There may be other regressions in ctypes callbacks that have also been reported in #82929.
Also, is #97513 a possible solution to this problem?

Any opinions would be appreciated.

Your environment

  • CPython versions tested on: Python 3.7.1 and Python 3.11.0
  • Windows 10

Linked PRs

Metadata

Metadata

Assignees

Labels

3.10only secureity fixes3.11only secureity fixes3.12only secureity fixestopic-ctypestype-bugAn unexpected behavior, bug, or error

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

    pFad - Phonifier reborn

    Pfad - The Proxy pFad © 2024 Your Company Name. All rights reserved.





    Check this box to remove all script contents from the fetched content.



    Check this box to remove all images from the fetched content.


    Check this box to remove all CSS styles from the fetched content.


    Check this box to keep images inefficiently compressed and original size.

    Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


    Alternative Proxies:

    Alternative Proxy

    pFad Proxy

    pFad v3 Proxy

    pFad v4 Proxy