MeteoSwiss / MeteoSwiss/yaconfigobject

copy and deepcopy trouble

Open
#3 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
1
Forks
1
PR merge metrics
No merged PRs in 30d

Description

Hello !

I'm having some trouble using `copy.deepcopy` and `copy.copy` with yaconfigobject. Here's a MWE. Running:
```
from copy import deepcopy
from yaconfigobject import Config

# Create a dummy Config instance
config = Config(name='dummy_config.yml')

# Try to get a deepcopy of some_dict
dc = deepcopy(config.some_dict)
```
with `dummy_config.yml` containing:
```
some_dict:
a: 14
```
crashes with the following error:
```
---------------------------------------------------------------------------
KeyError Traceback (most recent call last)
in
----> 1 deepcopy(config.some_dict)

~/opt/miniconda3/envs/amaroc/lib/python3.8/copy.py in deepcopy(x, memo, _nil)
149 y = _deepcopy_atomic(x, memo)
150 else:
--> 151 copier = getattr(x, "__deepcopy__", None)
152 if copier is not None:
153 y = copier(memo)

~/opt/miniconda3/envs/amaroc/lib/python3.8/site-packages/yaconfigobject.py in __getattr__(self, key)
70
71 def __getattr__(self, key):
---> 72 return self.__getitem__(key)
73
74 def __add__(self, other):

KeyError: '__deepcopy__'
```

At a quick glance, it looks like this may be related to [this SO question](https://stackoverflow.com/questions/33387801/) ?

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the minimal example with Python's copy and deepcopy operations, then inspect yaconfigobject.py, especially __getattr__ and the lookup path shown in the traceback. Done means copying config.some_dict succeeds without a KeyError and preserves the expected dictionary contents; add or run a focused regression test if the repository provides a test suite.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
tooling
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.