GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — datetime UTC deprecation warnings use the name "datetime" inconsistently · Issue #106392 · python/cpython Closed Labels stdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error DescriptionBug reportThe UTC deprecation warnings (added in #103858) use the name >>> import datetime >>> datetime.datetime.utcnow() <stdin>:1: DeprecationWarning: datetime.utcnow() is deprecated and scheduled for removal in a future version. Use timezone-aware objects to represent datetimes in UTC: datetime.now(datetime.UTC). datetime.datetime(2023, 7, 3, 23, 35, 25, 850070) >>> datetime.now(datetime.UTC) # <-- Copy-pasted but doesn't work ... AttributeError: module 'datetime' has no attribute 'now' >>> datetime.datetime.now(datetime.UTC) # Fixed datetime.datetime(2023, 7, 3, 23, 35, 32, 898186, tzinfo=datetime.timezone.utc) >>> >>> timestamp = 0 >>> datetime.datetime.utcfromtimestamp(timestamp) <stdin>:1: DeprecationWarning: datetime.utcfromtimestamp() is deprecated and scheduled for removal in a future version. Use timezone-aware objects to represent datetimes in UTC: datetime.fromtimestamp(timestamp, datetime.UTC). datetime.datetime(1970, 1, 1, 0, 0) >>> datetime.fromtimestamp(timestamp, datetime.UTC) # <-- Copy-pasted but doesn't work ... AttributeError: module 'datetime' has no attribute 'fromtimestamp' >>> datetime.datetime.fromtimestamp(timestamp, datetime.UTC) # Fixed datetime.datetime(1970, 1, 1, 0, 0, tzinfo=datetime.timezone.utc) To fix it, I'd just put By the way#104542 brought up the same thing about the deprecated names, but I think it's fine personally:
#105544 might also be relevant, I'm not sure. Your environment
Linked PRs
Activity
MetadataMetadataAssigneesLabelsstdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error ProjectsMilestoneRelationshipsDevelopmentIssue actions |
| You are visitor 01402503 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |