[issue35536] Calling built-in locals() and globals() in C++ leads to SystemError

2018-12-19 Thread Никита Сиргиенко

Никита Сиргиенко  added the comment:

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.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue35536] Calling built-in locals() and globals() in C++ leads to SystemError

2018-12-19 Thread Benjamin Peterson


Benjamin Peterson  added the comment:

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

--
nosy: +benjamin.peterson

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue35536] Calling built-in locals() and globals() in C++ leads to SystemError

2018-12-19 Thread Никита Сиргиенко

New submission from Никита Сиргиенко :

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.

--
components: Library (Lib)
messages: 332144
nosy: Никита Сиргиенко
priority: normal
severity: normal
status: open
title: Calling built-in locals() and globals() in C++ leads to SystemError
type: behavior
versions: Python 2.7, Python 3.6

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com