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

Change Namespace to handle null values as Python does for None #38

Merged
merged 1 commit into from Jan 4, 2013

Conversation

hpaulj
Copy link

@hpaulj hpaulj commented Jan 4, 2013

TestPositionalsNargsOptional adapted from test_argparse.py gives an error
'AssertionError: {} deepEqual {"foo":null}'

A dozen other classes in the py test file give similar errors.
The problem is that the JS Namespace class treats null differently than the python None.

Python gives every dest at least a None value.
The JS Namespace tries to treat a null value as the same as undefined.
However, because sometimes values are set with Namespace.set(), and other
times with ordinary object assignment, sometimes a null value appears in
a namespace.

These tests do pass if a modified deepEqual is used, one that ignores
differences between {bar: null} and {}

Python has a special Namespace class because its base Object class does
not directly accept attributes. It also defines a nice display method.
The resulting class is essentially the same as the Javascript object.

To better match the Python:

  • change namespace.isset() to use _.has() instead of !! (!!null is false)
  • remove the null test in namespace.set()
  • the _.extend() alternative is not used.
  • namespace.get() is not used

…rror

'AssertionError: {} deepEqual {"foo":null}'
A dozen other classes in the py test file give similar errors.
The problem is that the JS Namespace class treads null differently than
the python None.

Python gives every 'dest' at least a None value.
The JS Namespace tries to treat a null value as the same as undefined.
However, because sometimes values are set with Namespace.set(), and other
times with ordinary object assignment, sometimes a null value appears in
a namespace.

These tests do pass if a modified deepEqual is used, one that ignores
differences between {bar: null} and {}

Python has a special Namespace class because its base Object class does
not directly accept attributes.  It also defines a nice display method.
The resulting class is essentially the same as the Javascript object.

To better match the Python:
- change namespace.isset() to use _.has() instead of !! (!!null is false)
- remove the null test in namespace.set()
- the _.extend() alternative is not used.
- namespace.get() is not used
puzrin pushed a commit that referenced this pull request Jan 4, 2013
Change Namespace to handle null values as Python does for None
@puzrin puzrin merged commit c552034 into nodeca:master Jan 4, 2013
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.

None yet

2 participants