mirror of
				https://github.com/python/cpython.git
				synced 2025-10-31 05:31:20 +00:00 
			
		
		
		
	Bug #1550983: emit better error messages for erroneous relative
imports (if not in package and if beyond toplevel package).
This commit is contained in:
		
							parent
							
								
									74bb783c2f
								
							
						
					
					
						commit
						98775dfebc
					
				
					 2 changed files with 6 additions and 2 deletions
				
			
		|  | @ -2114,7 +2114,7 @@ get_parent(PyObject *globals, char *buf, Py_ssize_t *p_buflen, int level) | |||
| 		size_t len; | ||||
| 		if (lastdot == NULL && level > 0) { | ||||
| 			PyErr_SetString(PyExc_ValueError, | ||||
| 					"Relative importpath too deep"); | ||||
| 				"Attempted relative import in non-package"); | ||||
| 			return NULL; | ||||
| 		} | ||||
| 		if (lastdot == NULL) | ||||
|  | @ -2133,7 +2133,8 @@ get_parent(PyObject *globals, char *buf, Py_ssize_t *p_buflen, int level) | |||
| 		char *dot = strrchr(buf, '.'); | ||||
| 		if (dot == NULL) { | ||||
| 			PyErr_SetString(PyExc_ValueError, | ||||
| 					"Relative importpath too deep"); | ||||
| 				"Attempted relative import beyond " | ||||
| 				"toplevel package"); | ||||
| 			return NULL; | ||||
| 		} | ||||
| 		*dot = '\0'; | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Georg Brandl
						Georg Brandl