cmath.log(0, base) returns (-inf+nanj) instead of raising ValueError

Abierto
#161,972 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
3/5
Tiempo estimado
1-2 días
Aptitud para principiantes
68/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Activo
Stack tecnológico
c, python
Área
backend

Línea de trabajo

Start at cmath_log_impl, where the issue says c_log(z)'s domain error is lost when c_log(base) resets errno. Read the existing tests for cmath.log and run the focused cmath tests. Done means cmath.log(0, base) raises ValueError: math domain error while existing base-related behavior remains covered.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

Bug report

cmath.log(0) raises ValueError, but cmath.log(0, base) returns a value such as (-inf+nanj) for most bases. In cmath_log_impl, the domain error from c_log(z) is stored in errno, and the second call c_log(base) resets errno to 0 before it is checked.

import cmath, math

cmath.log(0)       # ValueError: math domain error
cmath.log(0, 2)    # (-inf+nanj)
cmath.log(0, -1)   # (nan+infj)
math.log(0, 2)     # ValueError: expected a positive input

Expected: cmath.log(0, base) raises ValueError: math domain error, the same as cmath.log(0) and math.log(0, 2). A zero or one base already raises (cmath.log(2, 0), cmath.log(2, 1)), because there the error comes from the second call or from the division.

CPython versions tested on:

3.15, CPython main branch

Operating systems tested on:

Linux


Found while building a Lean 4 model of CPython (https://broyojo.com/python-formalization/). AI tools (Claude) helped investigate the findings and prepare this report. The examples were rerun on CPython 3.15.2 and main, and the report received technical review. Record: mathint-cmath-log-base-errno

Lenguaje dominante
Python
Estrellas
78.2k
Forks
36.6k
Merge medio
19 h 57 min
PR fusionados (30 d)
630

Preparar el entorno

Abrir en Codespaces

Inicia el contenedor de desarrollo del proyecto en tu navegador, con tu propia cuenta de GitHub.

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de python/cpython

Todos los issues de python/cpython

Issues similares

Más issues de Python

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.