Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commita90d643

Browse files
committed
add fallback modes for importing the json module
1 parent522e0af commita90d643

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

‎zencoder/zencoder.py

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,25 @@
33
"""
44

55
importos
6-
importjson
76
importhttplib2
87
fromurllibimporturlencode
98

9+
# Note: I've seen this pattern for dealing with json in different pythons
10+
# in a lot of modules -- if there's a better way, I'd love to use it.
11+
try:
12+
# python 2.6 and greater
13+
importjson
14+
exceptImportError:
15+
try:
16+
# python 2.5
17+
importsimplejson
18+
json=simplejson
19+
exceptImportError:
20+
# if we're in django or Google AppEngine land
21+
# use this as a last resort
22+
fromdjango.utilsimportsimplejson
23+
json=simplejson
24+
1025
classZencoderError(Exception):
1126
pass
1227

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp