Skip to content

Conversation

@jmansilla
Copy link
Contributor

This pull request is an answer to the submitted ticket #40.
making possible to use extra subtypes like the ones defined on future.bu...

@keleshev
Copy link
Owner

Could you articulate in a better way, what are you trying to do. Maybe with some examples. I don't know what is future.builtins.types.newstr.BaseNewStr.

@jmansilla
Copy link
Contributor Author

Sure I can. Thanks for reviewing this pull request.

What I'm trying to do is to have some code (that uses Schema) working under Python 2 and 3. For such thing, I'm using a popular portability library named Future (https://pypi.python.org/pypi/future).

For example, a common detail that needs to be reviewed when wanting to have python2&3 code, is the meaning of the type str, which differs on both pythons. What Future provides is a way of overwriting some builtins with something else that works uniformly between python versions. In this example, you just add to the top of your file:

from future.builtins import str

and that will behave like the builtin unicode of the python2 interpreter, and as the builtin str of the python3 interpreter.

The conflict here is that the type of this future.builtin.str thing is not type, but another class that inherits from type.

That's why that when using this "str" on a schema definition, instead of having it treated as a type, is treated as a simple callable.

I believe that the changes proposed on this Pull Request are very small, and the impact they produce in Schema are minimal, but useful, making the library a bit robuster. I'm convinced also that incorporating this changes shouldn't affect existent legacy code already using Schema.

@keleshev
Copy link
Owner

I can see now. Thanks.

keleshev pushed a commit that referenced this pull request Apr 13, 2014
making possible to use extra subtypes like the ones defined on future.bu...
@keleshev keleshev merged commit 3497b70 into keleshev:master Apr 13, 2014
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.

2 participants