mirror of
				https://github.com/python/cpython.git
				synced 2025-10-31 05:31:20 +00:00 
			
		
		
		
	Issue #27419: Standard __import__() no longer look up "__import__" in globals
or builtins for importing submodules or "from import". Fixed handling an error of non-string package name.
This commit is contained in:
		
							parent
							
								
									dec25afab1
								
							
						
					
					
						commit
						b3b65e618c
					
				
					 2 changed files with 8 additions and 8 deletions
				
			
		|  | @ -10,6 +10,10 @@ Release date: TBA | |||
| Core and Builtins | ||||
| ----------------- | ||||
| 
 | ||||
| - Issue #27419: Standard __import__() no longer look up "__import__" in globals | ||||
|   or builtins for importing submodules or "from import".  Fixed handling an | ||||
|   error of non-string package name. | ||||
| 
 | ||||
| - Issue #27083: Respect the PYTHONCASEOK environment variable under Windows. | ||||
| 
 | ||||
| - Issue #27514: Make having too many statically nested blocks a SyntaxError | ||||
|  |  | |||
|  | @ -1438,6 +1438,7 @@ PyImport_ImportModuleLevelObject(PyObject *name, PyObject *given_globals, | |||
|             } | ||||
|             else if (!PyUnicode_Check(package)) { | ||||
|                 PyErr_SetString(PyExc_TypeError, "__name__ must be a string"); | ||||
|                 goto error; | ||||
|             } | ||||
|             Py_INCREF(package); | ||||
| 
 | ||||
|  | @ -1525,16 +1526,11 @@ PyImport_ImportModuleLevelObject(PyObject *name, PyObject *given_globals, | |||
|     _PyImport_AcquireLock(); | ||||
| #endif | ||||
|    /* From this point forward, goto error_with_unlock! */ | ||||
|     if (PyDict_Check(globals)) { | ||||
|         builtins_import = _PyDict_GetItemId(globals, &PyId___import__); | ||||
|     } | ||||
|     if (builtins_import == NULL) { | ||||
|         builtins_import = _PyDict_GetItemId(interp->builtins, &PyId___import__); | ||||
|     builtins_import = _PyDict_GetItemId(interp->builtins_copy, &PyId___import__); | ||||
|     if (builtins_import == NULL) { | ||||
|         PyErr_SetString(PyExc_ImportError, "__import__ not found"); | ||||
|         goto error_with_unlock; | ||||
|     } | ||||
|     } | ||||
|     Py_INCREF(builtins_import); | ||||
| 
 | ||||
|     mod = PyDict_GetItem(interp->modules, abs_name); | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Serhiy Storchaka
						Serhiy Storchaka