Skip to content
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 and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cleanup warnings and failures in tests. #62

Closed
wants to merge 1 commit into from

Conversation

jeffdav
Copy link
Contributor

@jeffdav jeffdav commented Aug 19, 2024

There were two warnings.

Warning #1:

Users/jeffdav/src/jeffdav-PythonKit/PythonKit/NumpyConversion.swift:140:34: warning: 'assign(from:count:)' is deprecated: renamed to 'update(from:count:)'
            buffPtr.baseAddress!.assign(from: ptr, count: scalarCount)
                                 ^
/Users/jeffdav/src/jeffdav-PythonKit/PythonKit/NumpyConversion.swift:140:34: note: use 'update(from:count:)' instead
            buffPtr.baseAddress!.assign(from: ptr, count: scalarCount)
                                 ^~~~~~
                                 update

Warning #2:

/Users/jeffdav/src/jeffdav-PythonKit/Tests/PythonKitTests/PythonFunctionTests.swift:207:13: warning: initialization of immutable value 'testFunction' was never used; consider replacing with assignment to '_' or removing it
        let testFunction = PythonFunction { _ in
        ~~~~^~~~~~~~~~~~
        _

This fixes both warnings in the obvious ways.

There was one failure when I ran the test suite locally:

/Users/jeffdav/src/jeffdav-PythonKit/Tests/PythonKitTests/PythonRuntimeTests.swift:197: error: -[PythonKitTests.PythonRuntimeTests testErrors] : XCTAssertEqual failed: ("str") is not equal to ("ZeroDivisionError")

Investigation shows that something changed between Python 3.11 and 3.12 in this area:

--> Python 3.11.9:
po exception
 division by zero
po exception.__class__
 <class 'str'>
po exception.__class__.__name__
 str

--> Python 3.12.4:
po exception
 division by zero
po exception.__class__
 <class 'ZeroDivisionError'>
po exception.__class__.__name__
 ZeroDivisionError

We're still using 3.11.9 locally and this was annoying me so I added a check to make it work in both scenarios. If there's a better way, I'm happy to do something else.

@compnerd
Copy link
Collaborator

The whitespace changes really make it difficult to identify the actual change from the whitespace change. Could you please split that out into a separate change? We can get that in trivially, the other change, I'd like to understand a bit further.


// Something changed between Python 3.11 and 3.12 that causes the
// __class__ type to be different.
if (exception.__class__.__name__ == "str") {
Copy link
Collaborator

Choose a reason for hiding this comment

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

This seems like there is a deeper issue. Python 3.8, 3.9, 3.10 all report ZeroDivisionError when testing locally. This is the snippet that I used:

import sys
print(sys.version)
try:
  1/0
except Exception as e:
  print(e.__class__.__name__)

@jeffdav
Copy link
Contributor Author

jeffdav commented Aug 25, 2024

@compnerd #63

@jeffdav
Copy link
Contributor Author

jeffdav commented Aug 25, 2024

Will reopen.

@jeffdav jeffdav closed this Aug 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants