Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

datetime_strptime is 'NoneType' when restart cpython #117914

Copy link
Copy link
Closed
@marin-man

Description

@marin-man
Issue body actions

Bug report

Bug description:

When executing the following code, it will appear TypeError: 'NoneType' object is not callable

#include "Python.h"
#include <iostream>

void py_test() {
    Py_Initialize();
    auto pName = PyUnicode_DecodeFSDefault("datetime");
    auto pModule = PyImport_Import(pName);
    auto datetime = PyObject_GetAttrString(pModule, "datetime");
    auto strptime = PyObject_GetAttrString(datetime, "strptime");
    auto args = PyTuple_New(2);
    PyTuple_SetItem(args, 0, PyUnicode_FromString("2000-01"));
    PyTuple_SetItem(args, 1, PyUnicode_FromString("%Y-%m"));
    auto res = PyObject_CallObject(strptime, args);
    PyObject_Print(res, stdout, 0);
    Py_Finalize();
}

int main() {
    py_test();
    std::cout << "========" << std::endl;
    py_test();
    return 0;
}

CPython versions tested on:

3.11

Operating systems tested on:

macOS

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    type-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.