Skip to content

Commit 763f293

Browse files
author
Tomasz bla Fortuna
committed
Bugfix: Passing config contents from variable in Python3.
Didn't worked previously neither as str nor bytes object.
1 parent 2a29fea commit 763f293

3 files changed

Lines changed: 6 additions & 2 deletions

File tree

examples3/demo_config_genome.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,10 @@ def quad(x):
5959

6060
loader = ConfigLoader(filename="quadratic.ini", require_genes=['x1', 'x2'])
6161

62+
# Check also passing config as an argument
63+
config_contents = open('quadratic.ini', 'r', encoding='utf-8').read()
64+
test_loader = ConfigLoader(filename=None, config_contents=config_contents, require_genes=['x1', 'x2'])
65+
6266
class QuadraticSolver(Organism):
6367
"""
6468
Implements the organism which tries

pygene3/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
new to genetic algorithms.
66
"""
77

8-
version = "0.3.1"
8+
version = "0.3.2"
99

1010
__all__ = [
1111
'gene', 'gamete', 'organism', 'population', 'xmlio', 'prog',

pygene3/config.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ def __init__(self, filename, require_genes=[], config_contents=None):
9393

9494
if filename is None and config_contents is not None:
9595
import io
96-
self.config.readfp(io.BytesIO(config_contents))
96+
self.config.readfp(io.StringIO(config_contents))
9797
else:
9898
self.config.read(filename)
9999

0 commit comments

Comments
 (0)