Ticket #145 (closed defect: fixed)

Opened 4 years ago

Last modified 2 years ago

Problem with literals and boolean operators

Reported by: dagss Owned by: scoder
Priority: minor Milestone: 0.13
Component: Code Generation Keywords:
Cc:

Description

Currently,

print False or 5

prints True, which doesn't agree with Python. However

def f(): return 5
print False or f()

correctly prints 5 (since 5 is now a Python object).

The reason this happens is that the 5 literal is typed as a C int which is then coerced into a boolean.

Change History

Changed 4 years ago by scoder

  • milestone changed from 0.11 to 1.0

deferred to 1.0 - a minor issue in .pyx files

Changed 3 years ago by scoder

  • priority changed from major to minor

The above works for me in current cython-devel. However, this doesn't:

print True or 5

This prints '1', since the result is the bint 'True', which evaluates to the integer 1 at the end.

Changed 3 years ago by scoder

  • owner changed from somebody to scoder
  • status changed from new to assigned

Changed 3 years ago by scoder

  • status changed from assigned to closed
  • resolution set to fixed

Changed 2 years ago by robertwb

  • milestone changed from 1.0 to 0.13
Note: See TracTickets for help on using tickets.