bpo-22273: Update ctypes to correctly handle arrays in small structur… by vsajip · Pull Request #15839 · python/cpython (original) (raw)

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 andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Conversation19 Commits2 Checks0 Files changed

Conversation

This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters

[ Show hidden characters]({{ revealButtonHref }})

vsajip

@vsajip

@vsajip

@eryksun Would appreciate your comments on this PR. Here, I only added support for arrays in small structures - I will address the union and bitfield issues in bpo-16575 and bpo-16576 in a separate PR.

ZackerySpytz

StgDictObject *dict;
int bitsize = 0;
if (!pair |

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to PEP 7, lines should be limited to 79 chars.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO we shouldn't apply this rule too strictly - it's intended to avoid too-deep nesting in code. In just about all cases in this file, the longer lines are due to verbose error messages or long variable names (neither of which are a bad thing).

@vsajip

@miss-islington

Thanks @vsajip for the PR 🌮🎉.. I'm working now to backport this PR to: 3.7.
🐍🍒⛏🤖

@miss-islington

Thanks @vsajip for the PR 🌮🎉.. I'm working now to backport this PR to: 3.8.
🐍🍒⛏🤖

@bedevere-bot

@bedevere-bot

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request

Sep 25, 2019

@vsajip @miss-islington

pythonGH-15839)

(cherry picked from commit 12f209e)

Co-authored-by: Vinay Sajip vinay_sajip@yahoo.co.uk

@bedevere-bot

⚠️⚠️⚠️ Buildbot failure ⚠️⚠️⚠️

Hi! The buildbot ARMv7 Debian buster 3.x has failed when building commit 12f209e.

What do you need to do:

  1. Don't panic.
  2. Check the buildbot page in the devguide if you don't know what the buildbots are or how they work.
  3. Go to the page of the buildbot that failed (https://buildbot.python.org/all/#builders/176/builds/1331) and take a look at the build logs.
  4. Check if the failure is related to this commit (12f209e) or if it is a false positive.
  5. If the failure is related to this commit, please, reflect that on the issue and make a new Pull Request with a fix.

You can take a look at the buildbot page here:

https://buildbot.python.org/all/#builders/176/builds/1331

Failed tests:

Failed subtests:

Summary of the results of the build (if available):

== Tests result: FAILURE then FAILURE ==

405 tests OK.

10 slowest tests:

1 test failed:
test_ctypes

13 tests skipped:
test_devpoll test_ioctl test_kqueue test_msilib test_ossaudiodev
test_startfile test_tix test_tk test_ttk_guionly test_winconsoleio
test_winreg test_winsound test_zipfile64

1 re-run test:
test_ctypes

Total duration: 14 min 45 sec

Click to see traceback logs

Traceback (most recent call last): File "/ssd/buildbot/buildarea/3.x.gps-ubuntu-exynos5-armv7l/build/Lib/ctypes/test/test_structures.py", line 517, in test_array_in_struct self.assertEqual(result, expected) AssertionError: 2.71828 != 5.85987

@bedevere-bot

⚠️⚠️⚠️ Buildbot failure ⚠️⚠️⚠️

Hi! The buildbot PPC64LE Fedora 3.x has failed when building commit 12f209e.

What do you need to do:

  1. Don't panic.
  2. Check the buildbot page in the devguide if you don't know what the buildbots are or how they work.
  3. Go to the page of the buildbot that failed (https://buildbot.python.org/all/#builders/85/builds/3594) and take a look at the build logs.
  4. Check if the failure is related to this commit (12f209e) or if it is a false positive.
  5. If the failure is related to this commit, please, reflect that on the issue and make a new Pull Request with a fix.

You can take a look at the buildbot page here:

https://buildbot.python.org/all/#builders/85/builds/3594

Failed tests:

Failed subtests:

Summary of the results of the build (if available):

== Tests result: FAILURE then FAILURE ==

405 tests OK.

10 slowest tests:

1 test failed:
test_ctypes

13 tests skipped:
test_devpoll test_ioctl test_kqueue test_msilib test_ossaudiodev
test_startfile test_tix test_tk test_ttk_guionly test_winconsoleio
test_winreg test_winsound test_zipfile64

1 re-run test:
test_ctypes

Total duration: 23 min 52 sec

Click to see traceback logs

Traceback (most recent call last): File "/home/shager/cpython-buildarea/3.x.edelsohn-fedora-ppc64le/build/Lib/ctypes/test/test_structures.py", line 517, in test_array_in_struct self.assertEqual(result, expected) AssertionError: 2.71828 != 5.85987

vsajip pushed a commit that referenced this pull request

Sep 25, 2019

@miss-islington @vsajip

vsajip pushed a commit that referenced this pull request

Sep 25, 2019

@miss-islington @vsajip

@bedevere-bot

⚠️⚠️⚠️ Buildbot failure ⚠️⚠️⚠️

Hi! The buildbot ARMv7 Debian buster 3.8 has failed when building commit ce62dcc.

What do you need to do:

  1. Don't panic.
  2. Check the buildbot page in the devguide if you don't know what the buildbots are or how they work.
  3. Go to the page of the buildbot that failed (https://buildbot.python.org/all/#builders/207/builds/427) and take a look at the build logs.
  4. Check if the failure is related to this commit (ce62dcc) or if it is a false positive.
  5. If the failure is related to this commit, please, reflect that on the issue and make a new Pull Request with a fix.

You can take a look at the buildbot page here:

https://buildbot.python.org/all/#builders/207/builds/427

Failed tests:

Failed subtests:

Summary of the results of the build (if available):

== Tests result: FAILURE then FAILURE ==

409 tests OK.

10 slowest tests:

1 test failed:
test_ctypes

13 tests skipped:
test_devpoll test_ioctl test_kqueue test_msilib test_ossaudiodev
test_startfile test_tix test_tk test_ttk_guionly test_winconsoleio
test_winreg test_winsound test_zipfile64

1 re-run test:
test_ctypes

Total duration: 13 min 43 sec

Click to see traceback logs

Traceback (most recent call last): File "/ssd/buildbot/buildarea/3.8.gps-ubuntu-exynos5-armv7l/build/Lib/ctypes/test/test_structures.py", line 517, in test_array_in_struct self.assertEqual(result, expected) AssertionError: 2.71828 != 5.85987

@bedevere-bot

⚠️⚠️⚠️ Buildbot failure ⚠️⚠️⚠️

Hi! The buildbot PPC64LE Fedora 3.8 has failed when building commit ce62dcc.

What do you need to do:

  1. Don't panic.
  2. Check the buildbot page in the devguide if you don't know what the buildbots are or how they work.
  3. Go to the page of the buildbot that failed (https://buildbot.python.org/all/#builders/228/builds/393) and take a look at the build logs.
  4. Check if the failure is related to this commit (ce62dcc) or if it is a false positive.
  5. If the failure is related to this commit, please, reflect that on the issue and make a new Pull Request with a fix.

You can take a look at the buildbot page here:

https://buildbot.python.org/all/#builders/228/builds/393

Failed tests:

Failed subtests:

Summary of the results of the build (if available):

== Tests result: FAILURE then FAILURE ==

409 tests OK.

10 slowest tests:

1 test failed:
test_ctypes

13 tests skipped:
test_devpoll test_ioctl test_kqueue test_msilib test_ossaudiodev
test_startfile test_tix test_tk test_ttk_guionly test_winconsoleio
test_winreg test_winsound test_zipfile64

1 re-run test:
test_ctypes

Total duration: 20 min 35 sec

Click to see traceback logs

Traceback (most recent call last): File "/home/shager/cpython-buildarea/3.8.edelsohn-fedora-ppc64le/build/Lib/ctypes/test/test_structures.py", line 517, in test_array_in_struct self.assertEqual(result, expected) AssertionError: 2.71828 != 5.85987

@bedevere-bot

⚠️⚠️⚠️ Buildbot failure ⚠️⚠️⚠️

Hi! The buildbot PPC64LE Fedora 3.7 has failed when building commit 16c0f6d.

What do you need to do:

  1. Don't panic.
  2. Check the buildbot page in the devguide if you don't know what the buildbots are or how they work.
  3. Go to the page of the buildbot that failed (https://buildbot.python.org/all/#builders/120/builds/1315) and take a look at the build logs.
  4. Check if the failure is related to this commit (16c0f6d) or if it is a false positive.
  5. If the failure is related to this commit, please, reflect that on the issue and make a new Pull Request with a fix.

You can take a look at the buildbot page here:

https://buildbot.python.org/all/#builders/120/builds/1315

Failed tests:

Failed subtests:

Summary of the results of the build (if available):

== Tests result: FAILURE then FAILURE ==

402 tests OK.

10 slowest tests:

1 test failed:
test_ctypes

13 tests skipped:
test_devpoll test_ioctl test_kqueue test_msilib test_ossaudiodev
test_startfile test_tix test_tk test_ttk_guionly test_winconsoleio
test_winreg test_winsound test_zipfile64

1 re-run test:
test_ctypes

Total duration: 19 min 23 sec

Click to see traceback logs

Traceback (most recent call last): File "/home/shager/cpython-buildarea/3.7.edelsohn-fedora-ppc64le/build/Lib/ctypes/test/test_structures.py", line 478, in test_array_in_struct self.assertEqual(result, expected) AssertionError: 2.71828 != 5.85987

Kentzo

#define MAX_ELEMENTS 16
if (arrays_seen && (size <= 16)) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vsajip Is it intentional that 16 is used here instead of MAX_ELEMENTS?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whoops, no. That's a slip-up. Looks like I'll need to find a fix for the buildbot failures, anyway ... so I'll deal with this soon.

Kentzo

/* Copy over the element's type, length times. */
while (length > 0) {
actual_types[actual_type_index++] = &edict->ffi_type_pointer;
assert(actual_type_index <= MAX_ELEMENTS);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Assertion can be checked just once before the while loop.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But actual_type_index is incremented in the loop, and in theory the increment could take it past the end of the array, which is what the assertion is guarding against.

jacobneiltaylor pushed a commit to jacobneiltaylor/cpython that referenced this pull request

Dec 5, 2019

@vsajip

This was referenced

Apr 10, 2022