Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Nullable<Decimal> comparisons #2527

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

Open
briandesarmo opened this issue Dec 9, 2024 · 0 comments
Open

Nullable<Decimal> comparisons #2527

briandesarmo opened this issue Dec 9, 2024 · 0 comments

Comments

@briandesarmo
Copy link

briandesarmo commented Dec 9, 2024

Environment

  • Pythonnet version: 3.0.3
  • Python version: 3.12
  • Operating System: Windows
  • .NET Runtime: 4.8

Details

  • Describe what you were trying to get done.

We have python embedded in C# and are putting into scope objects that have Nullable<Decimal> properties and running (user provided python) code which tests for null(None). This fails when the property has a value and we compare the value to None using the == and != operators. It appears to work when we use the pythonic syntax not x or x is not None. We have upgraded from 2.5.2 to 3.0.3, also went from from Python 3.8 to 3.12. This code worked in previous versions.

## This does not work
x = None
print(x == None)
x = System.Decimal(1.23)
print(x == None)

## This works
x = None
print(not x)
x = System.Decimal(1.23)
print(not x)

## This also works
x = None
print(x is not None)
x = System.Decimal(1.23)
print(x is not None)
  • If there was a crash, please include the traceback here.
True
No method matches given arguments for Decimal.op_Equality: (<class 'NoneType'>)   File "<string>", line 5, in <module>
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

No branches or pull requests

1 participant