[Bug]: `socket.socketpair()` uses the loopback fallback and rejects `AF_UNIX`

Abierto
#1,365 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
4/5
Tiempo estimado
3-5 días
Aptitud para principiantes
35/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Activo
Stack tecnológico
java, macos, python

Línea de trabajo

Start with SocketModuleBuiltins.java, where _socket lacks a socketpair entry, and the socket.py fallback _fallback_socketpair that rejects non-AF_INET families. Compare with the native socket implementation in PosixSupport.java to see how a new socketpair(family, type, proto) would be wired into the POSIX backends and the emulated one. Done when socket.socketpair(socket.AF_UNIX) returns two AF_UNIX sockets and hasattr(_socket, 'socketpair') is True.

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

Descripción

bug
Describe the bug

_socket has no socketpair, so socket.socketpair() falls back to connecting two AF_INET sockets over loopback: it rejects AF_UNIX with ValueError and returns AF_INET sockets by default. CPython on POSIX calls the native socketpair and defaults to AF_UNIX.

Operating system

macOS

CPU architecture

ARM64

GraalPy version

master 3289197e63 (Python 3.13.14), built with mx python-jvm

JDK version

No response

Context configuration

No response

Steps to reproduce
import socket, _socket
Expression GraalPy CPython
socket.socketpair(socket.AF_UNIX) ValueError: Only AF_INET and AF_INET6 socket address families are supported (<socket.socket fd=3, family=1, type=1, proto=0>, <socket.socket fd=4, family=1, type=1, proto=0>)
socket.socketpair()[0].family <AddressFamily.AF_INET: 2> <AddressFamily.AF_UNIX: 1>
hasattr(_socket, 'socketpair') False True
Expected behavior

The CPython column above (3.12.13 and 3.13.14).

Stack trace

Additional context
Root Cause

SocketModuleBuiltins has no socketpair, so socket.py takes _fallback_socketpair, which connects two AF_INET sockets over loopback and rejects other families. On POSIX CPython provides _socket.socketpair and defaults to AF_UNIX. GraalPy can create AF_UNIX sockets with socket.socket.

Fix Suggestion

Add socketpair(family, type, proto) to PosixSupport and its backends, next to socket, and expose it as _socket.socketpair in SocketModuleBuiltins, returning two PSocket objects. The emulated backend can raise the unsupported-feature error it already raises for AF_UNIX.

Lenguaje dominante
Python
Estrellas
1.7k
Forks
167
Merge medio
3 d 11 h
PR fusionados (30 d)
68

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 oracle/graalpython

Todos los issues de oracle/graalpython

Issues similares

Más issues de Python

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.