Skip to content

Commit

Permalink
Move deepcopy fix to Reddit class
Browse files Browse the repository at this point in the history
  • Loading branch information
LilSpazJoekp committed Jul 6, 2021
1 parent 2ffe6d8 commit cf2316b
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 29 deletions.
6 changes: 6 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ Async PRAW follows `semantic versioning <http://semver.org/>`_.
Unreleased
----------

**Changed**

- :class:`.Reddit` will now be shallow copied when a deepcopy is preformed on it as
``asyncprawcore.Session`` (more specifically, :py:class:`asyncio.AbstractEventLoop`)
does not support being deepcopied.

**Fixed**

- Fixed an issue where some :class:`.RedditBase` objects would be sent in a request as
Expand Down
10 changes: 10 additions & 0 deletions asyncpraw/reddit.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import configparser
import os
import re
from copy import copy
from itertools import islice
from logging import getLogger
from typing import (
Expand Down Expand Up @@ -144,6 +145,15 @@ async def __aexit__(self, *_args):
"""Handle the context manager close."""
await self.close()

def __deepcopy__(self, memodict={}):
"""Shallow copy on deepcopy.
A shallow copied is performed on deepcopy as
:py:class:`asyncio.AbstractEventLoop` cannot be deepcopied.
"""
return copy(self)

def __enter__(self):
"""Handle the context manager open.
Expand Down
29 changes: 0 additions & 29 deletions tests/unit/models/reddit/test_base.py

This file was deleted.

0 comments on commit cf2316b

Please sign in to comment.