Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: mongodb/mongo-python-driver
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 6a796c8
Choose a base ref
...
head repository: reorx/mongo-python-driver
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 7fb125c
Choose a head ref
  • 1 commit
  • 1 file changed
  • 1 contributor

Commits on Feb 2, 2013

  1. __str__ method of ObjectId return <type 'str'>

    As Python supports both `__str__` and `__unicode__` method for objects' string conversion,
    it is suggested to return `<type 'str'>` for `__str__`, and `<type 'unicode'>` for `__unicode__`.
    
    This is my understanding about the difference between this two methods.
    So I think it would be better to return str explicitly for `__str__`,
    and add `__unicode__` for possible use
    
    I have encountered a problem when I formatting strings with ObjectId:
    
    ```python
    >>> '%s %s' % ('\xe5\x90\x8d\xe5\xad\x97', ObjectId())
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
    UnicodeDecodeError: 'ascii' codec can't decode byte 0xe5 in position 0: ordinal not in range(128)
    ```
    
    The reason why this problem happen is because Python tried to encode every argument since he found an unicode in the arguments, but the first one has already been encoded as utf8, the re-encode action then cause error.
    reorx committed Feb 2, 2013
    Configuration menu
    Copy the full SHA
    7fb125c View commit details
    Browse the repository at this point in the history
Loading