diff --git a/pymarc/record.py b/pymarc/record.py index c7b8c5f..9f74cf1 100644 --- a/pymarc/record.py +++ b/pymarc/record.py @@ -28,6 +28,7 @@ isbn_regex = re.compile(r'([0-9\-xX]+)') +@six.python_2_unicode_compatible class Record(Iterator): """ A class for representing a MARC record. Each Record object is made up of @@ -82,7 +83,7 @@ def __str__(self): """ # join is significantly faster than concatenation text_list = ['=LDR %s' % self.leader] - text_list.extend([str(field) for field in self.fields]) + text_list.extend([six.text_type(field) for field in self.fields]) text = '\n'.join(text_list) + '\n' return text diff --git a/test/diacritic.dat b/test/diacritic.dat new file mode 100644 index 0000000..7676318 --- /dev/null +++ b/test/diacritic.dat @@ -0,0 +1 @@ +02710cam a22003018a 45000010009000000050017000090080041000269060045000679250104001129550080002160100017002960200029003130200026003420400013003680500023003810820017004042450099004212600052005202630009005723000011005815040041005925051531006336500039021646500028022036500035022317000024022669630118022901709126920131029120147.0111220s2012 enk b 000 0 eng  a7bcbccorignewd1eecipf20gy-gencatlg0 aacquireb2 shelf copiesxpolicy defaulteclaim1 2012-10-24eclaim2 2013-06-13eto CAD 2013-10-29 bxg08 2011-12-20ixg08 2011-12-20axg09 2011-12-21 to Deweywrd05 2011-12-23 a 2011052495 a9780415782654 (hardback) a9780203112021 (ebook) aDLCcDLC00aK564.C6bA835 201200a302.23/122300aAmateur media :bsocial, cultural and legal perspectives /cedited by Dan Hunter ... [et al.]. aAbingdon, Oxon ;aN.Y., NY :bRoutledge,c2012. a1206 ap. cm. aIncludes bibliographical references.0 aHistories of user-generated content: between formal and informal media economies / Ramon Lobato, Julian Thomas and Dan Hunter -- Competing myths of informal economies / Megan Richardson and Jake Goldenfein -- Start with the household / John Quiggin -- Amateur digital content and proportional commerce / Steven Hetcher -- YouTube and the formalisation of amateur media / Jean Burgess -- The relationship between user-generated content and commerce / Kimberlee Weatherall -- The manufacture of 'authentic' buzz and the legal relations of MasterChef / Kathy Bowrey -- Harry Potter and the transformation wand : fair use, canonicity and fan activity / David Tan -- The simulation of 'authentic' buzz : T-mobile and the flash mob dance / Marc Trabsky -- Prestige and professionalisation at the margins of the journalistic field : the case of music writers / Ramon Lobato and Lawson Fletcher -- Swedish subtitling strike called off! : fan-to-fan piracy, translation, and the primacy of authorisation / Eva Hemmungs Wirtén -- Have amateur media enhanced the possibilities for good media work? / David Hesmondhalgh -- Minecraft as Web 2.0 : amateur creativity and digital games / Greg Lastowka -- Cosplay, creativity and immaterial labours of love / Melissa de Zwart -- Web Zero: the amateur and the indie game developer / Christian McCrea -- Anonymous speech on the internet / Brian Murchison -- The privacy interest in anonymous blogging / Lisa Austin -- 'Privacy' of social networking texts / Megan Richardson and Julian Thomas. 0aSocial mediaxLaw and legislation. 0aUser-generated content. 0aInternetxLaw and legislation.1 aHunter, Dan,d1966- aStephen Gutierrez; phone: +44-2070176003; email: stephen.gutierrez@informa.com; bc: stephen.gutierrez@informa.com \ No newline at end of file diff --git a/test/utf8_test.py b/test/utf8_test.py index 2c36189..971f06b 100644 --- a/test/utf8_test.py +++ b/test/utf8_test.py @@ -35,6 +35,13 @@ def process_xml(record): # remove it os.remove('test/write-utf8-test.dat') + def test_combining_diacritic(self): + """issue 74: raises UnicodeEncodeError on Python 2""" + reader = pymarc.MARCReader(open('test/diacritic.dat', 'rb')) + record = next(reader) + str(record) + + def suite(): test_suite = unittest.makeSuite(MARCUnicodeTest, 'test') return test_suite