-
Notifications
You must be signed in to change notification settings - Fork 191
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
Loaded datetimes with timezone offset cannot be pickled correctly #407
Comments
I'm encountering the same error message when trying to read a toml file with Ansible. To install both
FROM python:3-slim
COPY requirements.txt .
RUN pip install -r requirements.txt With this file at #!/usr/bin/python
DOCUMENTATION = '''
---
module: to_toml, from_toml
version_added: "2.8"
short_description: Converts Python data to TOML and TOML to Python data.
author:
- "Samy Coenen ([email protected])"
'''
import toml
def to_toml(data):
''' Convert the value to TOML '''
return toml.dumps(data)
def from_toml(data):
''' Convert TOML to Python data '''
return toml.loads(data)
class FilterModule(object):
''' Ansible TOML jinja2 filters '''
def filters(self):
return {
# toml
'to_toml': to_toml,
'from_toml': from_toml
} Then I try to read a toml file and set its content as a fact with the following tasks using my custom - name: Slurp existing runner config again after registration
slurp:
src: "/etc/gitlab-runner/config.toml"
register: config_file
when: runner_registration.changed
- set_fact:
runner_config: "{{ config_file.content | b64decode | from_toml }}"
when: runner_registration.changed The file I'm trying to read ( concurrent = 1
check_interval = 0
[session_server]
session_timeout = 1800
[[runners]]
name = "zenyatta"
url = "[REDACTED]"
id = 176
token = "[REDACTED]"
token_obtained_at = 2022-11-03T14:23:18Z
token_expires_at = 0001-01-01T00:00:00Z
executor = "shell"
[runners.custom_build_dir]
[runners.cache]
[runners.cache.s3]
[runners.cache.gcs]
[runners.cache.azure] I assume |
Funny, I hit the same issue with the Salt-stack and |
I've tried pickling an object loaded from a toml file that contains a datetime with a timezone offset.
Here is a minimal example:
I have not looked deeper into the pickle data or how pickle accesses sub-objects. And yes, I know that this is a great combination, TOML+pickle.
The text was updated successfully, but these errors were encountered: