GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — shutil.copyfile does not raise SpecialFileError for socket files · Issue #81881 · python/cpython

shutil.copyfile does not raise SpecialFileError for socket files #81881

New issue
Copy link
New issue
Copy link
Closed
Closed
shutil.copyfile does not raise SpecialFileError for socket files#81881
Copy link
Labels
stdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error

Description

chrahunt
mannequin
opened on Jul 29, 2019
Issue body actions
BPO 37700
Nosy @cjerdonek, @chrahunt, @potomak
PRs
  • gh-81881: Raise a shutil.SpecialFileError when copying a Unix socket #16575
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = None
    closed_at = None
    created_at = <Date 2019-07-29.04:22:16.840>
    labels = ['type-bug', 'library', '3.9', '3.10', '3.11']
    title = 'shutil.copyfile does not raise SpecialFileError for socket files'
    updated_at = <Date 2021-12-11.18:41:20.112>
    user = 'https://github.com/chrahunt'

    bugs.python.org fields:

    activity = <Date 2021-12-11.18:41:20.112>
    actor = 'iritkatriel'
    assignee = 'none'
    closed = False
    closed_date = None
    closer = None
    components = ['Library (Lib)']
    creation = <Date 2019-07-29.04:22:16.840>
    creator = 'chrahunt'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 37700
    keywords = ['patch']
    message_count = 3.0
    messages = ['348595', '348596', '348602']
    nosy_count = 3.0
    nosy_names = ['chris.jerdonek', 'chrahunt', 'potomak']
    pr_nums = ['16575']
    priority = 'normal'
    resolution = None
    stage = 'patch review'
    status = 'open'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue37700'
    versions = ['Python 3.9', 'Python 3.10', 'Python 3.11']

    Linked PRs

    • GH-81881: Raise SpecialFileError for sockets and devices in shutil.copyfile #142693

    Activity

    1. chrahunt commented on Jul 29, 2019

      @chrahunt
      chrahuntmannequin
      on Jul 29, 2019
      MannequinAuthor
      More actions

      Currently shutil.copyfile only raises SpecialFileError for named pipes. When trying to use the function to copy a socket file, the exception raised depends on the platform, for example:

      macOS: "[Errno 102] Operation not supported on socket: '/Users/guido/src/mypy/dmypy.sock'"
      HP-UX: "[Errno 223] Operation not supported: 'example/foo'"
      Solaris: "[Errno 122] Operation not supported on transport endpoint: 'example/foo'"
      AIX: "[Errno 64] Operation not supported on socket: '../../example/foo'"
      Linux: "[Errno 6] No such device or address: 'example/foo'"

      This can be reproduced like:

          import os
          import shutil
          import socket
          import tempfile
      
          d = tempfile.mkdtemp()
          src = os.path.join(d, "src")
          dest = os.path.join(d, "dest")
          sock = socket.socket(socket.AF_UNIX)
          sock.bind(src)
      
          shutil.copyfile(src, dest)

      Making shutil.copyfile raise SpecialFileError for socket files would improve the interface of this function since the same class of error could be ignored. This is mostly useful with shutil.copytree, which defaults to copyfile for its copy function.

    2. chrahunt
      added
      3.7 (EOL)end of lifeend of life
      3.8 (EOL)end of lifeend of life
      stdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directory
      type-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
      on Jul 29, 2019
    3. chrahunt commented on Jul 29, 2019

      @chrahunt
      chrahuntmannequin
      on Jul 29, 2019
      MannequinAuthor
      More actions

      See also: the comment from

      cpython/Lib/shutil.py

      Line 245 in e1b9002

      # XXX What about other special files? (sockets, devices...)
      :

      XXX What about other special files? (sockets, devices...)

    4. cjerdonek commented on Jul 29, 2019

      @cjerdonek
      cjerdonek
      on Jul 29, 2019
      Member
      More actions

      This issue is being filed after coming up in pip's tracker here (in a comment by Guido): pypa/pip#5306 (comment)

    5. iritkatriel
      added
      3.9 (EOL)end of lifeend of life
      3.10 (EOL)end of lifeend of life
      3.11only security fixesonly security fixes
      and removed
      3.7 (EOL)end of lifeend of life
      3.8 (EOL)end of lifeend of life
      on Dec 11, 2021
    6. ezio-melotti
      transferred this issue fromon Apr 10, 2022
    7. picnixz
      removed
      3.11only security fixesonly security fixes
      3.10 (EOL)end of lifeend of life
      3.9 (EOL)end of lifeend of life
      on Dec 14, 2025
    8. savannahostrowski
      added a commit that references this issue on Jun 30, 2026

      GH-81881: Raise `SpecialFileError` for sockets and devices in `shutil…

      040002c
    9. maurycy
      added a commit that references this issue on Jul 1, 2026

      Merge branch 'main' into maurycy/bye-abba

      da7d768
    10. hugovk
      closed this as completedon Oct 23, 2026
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

    Metadata

    Metadata

    Assignees

    No one assigned

      Labels

      stdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error

      Projects

      No projects

        Milestone

        No milestone

        Relationships

        None yet

        Development

        No branches or pull requests

        Issue actions

        You are visitor 01402503 — GeezerVison does not store the pages you look up.
        Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.