Skip to content

Commit e18a0d8

Browse files
committed
Fix of overriding variables in general
1 parent 90e34b6 commit e18a0d8

File tree

3 files changed

+10
-5
lines changed

3 files changed

+10
-5
lines changed

CHANGELOG.txt

+5
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
=== 2.4 (unreleased)
2+
3+
* Fix overriding variables (in pattern properties, property names, unique items and contains)
4+
5+
16
=== 2.3 (2018-09-14) ===
27

38
* Fix regex of hostname

fastjsonschema/draft04.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,7 @@ def generate_unique_items(self):
292292
2.1439831256866455
293293
"""
294294
self.create_variable_with_length()
295-
with self.l('if {variable}_len > len(set(str(x) for x in {variable})):'):
295+
with self.l('if {variable}_len > len(set(str({variable}_x) for {variable}_x in {variable})):'):
296296
self.l('raise JsonSchemaException("{name} must contain unique items")')
297297

298298
def generate_items(self):

fastjsonschema/draft06.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -105,11 +105,11 @@ def generate_property_names(self):
105105
self.create_variable_with_length()
106106
with self.l('if {variable}_len != 0:'):
107107
self.l('{variable}_property_names = True')
108-
with self.l('for key in {variable}:'):
108+
with self.l('for {variable}_key in {variable}:'):
109109
with self.l('try:'):
110110
self.generate_func_code_block(
111111
property_names_definition,
112-
'key',
112+
'{}_key'.format(self._variable),
113113
self._variable_name,
114114
clear_variables=True,
115115
)
@@ -143,11 +143,11 @@ def generate_contains(self):
143143
self.l('raise JsonSchemaException("{name} must not be empty")')
144144
else:
145145
self.l('{variable}_contains = False')
146-
with self.l('for key in {variable}:'):
146+
with self.l('for {variable}_key in {variable}:'):
147147
with self.l('try:'):
148148
self.generate_func_code_block(
149149
contains_definition,
150-
'key',
150+
'{}_key'.format(self._variable),
151151
self._variable_name,
152152
clear_variables=True,
153153
)

0 commit comments

Comments
 (0)