简体   繁体   中英

Why is QDate.daysTo( ) segfaulting?

I'm puzzled why this crashes. I can paste these two lines into a python shell and reliably get a segfault and be kicked out of the Python session:

from PyQt5.QtCore import QDate
QDate(2011, 1, 2).daysTo(QDate(2012, 1, 1))

Adding try/except won't catch anything.

Versions I'm using:

Python 3.10.6 (main, Aug 3 2022, 17:39:45) [GCC 12.1.1 20220730] on linux

from PyQt5.QtCore import QT_VERSION_STR
from PyQt5.Qt import PYQT_VERSION_STR
print(QT_VERSION_STR)              # 5.15.4
print(PYQT_VERSION_STR)            # 5.15.7

Solved. The script I'm running was named datetime.py in the directory, Bad idea. even if I'm only using the PyQt's date and time stuff. It's probably pulling in Python's datetime module behind the scenes.

Changing the name to "trydatetime.py" or "timedate.py" made the problem go away.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM