Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

copy.deepcopy os.environ instead of copy #2119

Merged
merged 1 commit into from
Mar 26, 2021

Conversation

NihalHarish
Copy link
Contributor

@NihalHarish NihalHarish commented Mar 26, 2021

Fixes: #2115

  • bug fix: using envrion.copy() returns a dict.
  • using deepcopy(environ) returns an _environ object
  • Changing the datatype of the _environ object can break code, if subsequent libraries perform operations using apis exclusive to the environ object, like environ.getenv() for example.

Testing:

Tested the change on my terminal:

>>> import os
>>> x = deepcopy(os.environ)
>>> y = os.environ
>>> x is y
False
>>> isinstance(x, type(os.environ))
True
>>> z = os.environ.copy()
>>> isinstance(z, type(os.environ))
False
>>> isinstance(z, dict)
True

@NihalHarish NihalHarish changed the title Deep Copy os.environ instead of copy copy.deepcopy os.environ instead of copy Mar 26, 2021
Copy link
Member

@lhoestq lhoestq left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch !
thank you

@lhoestq lhoestq merged commit 0e2563e into huggingface:master Mar 26, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

The datasets.map() implementation modifies the datatype of os.environ object
2 participants