Skip to content
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

Calling built-in locals() and globals() in C++ leads to SystemError #79717

Open
ghost opened this issue Dec 19, 2018 · 3 comments
Open

Calling built-in locals() and globals() in C++ leads to SystemError #79717

ghost opened this issue Dec 19, 2018 · 3 comments
Labels
stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error

Comments

@ghost
Copy link

ghost commented Dec 19, 2018

BPO 35536
Nosy @benjaminp

Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

Show more details

GitHub fields:

assignee = None
closed_at = None
created_at = <Date 2018-12-19.14:54:20.890>
labels = ['type-bug', 'library']
title = 'Calling built-in locals() and globals() in C++ leads to SystemError'
updated_at = <Date 2018-12-20.06:03:51.696>
user = None

bugs.python.org fields:

activity = <Date 2018-12-20.06:03:51.696>
actor = '\xd0\x9d\xd0\xb8\xd0\xba\xd0\xb8\xd1\x82\xd0\xb0 \xd0\xa1\xd0\xb8\xd1\x80\xd0\xb3\xd0\xb8\xd0\xb5\xd0\xbd\xd0\xba\xd0\xbe'
assignee = 'none'
closed = False
closed_date = None
closer = None
components = ['Library (Lib)']
creation = <Date 2018-12-19.14:54:20.890>
creator = '\xd0\x9d\xd0\xb8\xd0\xba\xd0\xb8\xd1\x82\xd0\xb0 \xd0\xa1\xd0\xb8\xd1\x80\xd0\xb3\xd0\xb8\xd0\xb5\xd0\xbd\xd0\xba\xd0\xbe'
dependencies = []
files = []
hgrepos = []
issue_num = 35536
keywords = []
message_count = 3.0
messages = ['332144', '332175', '332178']
nosy_count = 2.0
nosy_names = ['benjamin.peterson', '\xd0\x9d\xd0\xb8\xd0\xba\xd0\xb8\xd1\x82\xd0\xb0 \xd0\xa1\xd0\xb8\xd1\x80\xd0\xb3\xd0\xb8\xd0\xb5\xd0\xbd\xd0\xba\xd0\xbe']
pr_nums = []
priority = 'normal'
resolution = None
stage = None
status = 'open'
superseder = None
type = 'behavior'
url = 'https://bugs.python.org/issue35536'
versions = ['Python 2.7', 'Python 3.6']

@ghost
Copy link
Author

ghost commented Dec 19, 2018

System:
Distributor ID: Ubuntu
Description: Ubuntu 18.04.1 LTS
Release: 18.04
Codename: bionic
Arch: x86_64

Compilier:
g++ (Ubuntu 7.3.0-27ubuntu1~18.04) 7.3.0

Python versions:
Python 3.6.7-1
Python 2.7.15rc1

Description:
This C++ code:

    PyObject* pBuiltin = PyImport_ImportModule("builtins");
    PyObject* py_globals_fun = PyObject_GetAttrString(pBuiltin,"locals");
    PyObject* globals = PyObject_CallObject(py_globals_fun, NULL);

produces "SystemError: frame does not exist".
For function "globals" output is "SystemError: returned NULL without
setting an error". For python2 this code produces similar errors (descriptions
of error little different).

Another functions with arguments, like "abs", works fine.
And calling function with optional argument, like "int", "float"
works with this code (with null parameter) without problem.

Repository owner added stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error labels Dec 19, 2018
@benjaminp
Copy link
Contributor

What behavior are you expecting? If there isn't any Python code in the callback, globals() and locals() are meaningless.

@ghost
Copy link
Author

ghost commented Dec 20, 2018

I run some Python code before this moment, so I expect, that globals variable will be a PyDictObject with results of 'globals()' command: '__name__', '__doc__', global variables, etc.

@ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

2 participants