Skip to content

Commit 526e051

Browse files
authored
Update README.md - added console outputs
Signed-off-by: Hubert Daniszewski <[email protected]>
1 parent ed6692f commit 526e051

File tree

1 file changed

+21
-0
lines changed
  • docs/Secure-Coding-Guide-for-Python/CWE-697/CWE-595

1 file changed

+21
-0
lines changed

docs/Secure-Coding-Guide-for-Python/CWE-697/CWE-595/README.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,16 @@ print(a is b)
9696

9797
```
9898

99+
**Output of noncompliant01.py:**
100+
101+
```bash
102+
False
103+
False
104+
False
105+
True
106+
False
107+
```
108+
99109
## Compliant Solution
100110

101111
In this compliant solution, the `__eq__` method is implemented and the comparisons that not use `is` now correctly compare the object values, rather than the object reference. The `is` operator does not call `__eq__`, hence the last print will still display `False`.
@@ -138,6 +148,17 @@ b = Integer(12)
138148
# Since the 'is' operator does not call __eq__, print below will still return False
139149
print(a is b)
140150

151+
```
152+
153+
**Output of compliant01.py:**
154+
155+
```bash
156+
True
157+
True
158+
True
159+
True
160+
True
161+
False
141162
```
142163

143164
## Automated Detection

0 commit comments

Comments
 (0)