scrapy / scrapely

A pure-python HTML screen-scraping library
1.86k stars 315 forks source link

Add python 3 support #67

Closed ruairif closed 9 years ago

pablohoffman commented 9 years ago

thanks for contributing this @ruairif. can someone review & merge this? /cc @kalessin @kmike @dangra

kmike commented 9 years ago

It looks good :+1: I think it can be merged after the following:

  1. make sure __iter__ check is OK;
  2. travis.yml should be fixed to run tests in Python 3.3 and 3.4;
  3. I think it is better to add Python 3.3 to tox.
ruairif commented 9 years ago

Unicode in python2 has no 'iter' so if it's written as

if (isinstance(values, (bytes, str)) or
    not hasattr(values, '__iter__')):

The first check catches str in python2 and bytes, str/unicode in python3 The second check catches unicode and all non iterables in python2 and all non iterables in python3

kmike commented 9 years ago

@ruairif you're right, thanks for the explanation

ruairif commented 9 years ago

With the previous way it was using only python 2.7. What's the best way to set up travis for it?

kmike commented 9 years ago

It doesn't matter which Python version we use to start tox, leaving it equal to 2.7 is fine.

kmike commented 9 years ago

Thanks @ruairif!